Skip to content

Commit

Permalink
[refac] apply code review
Browse files Browse the repository at this point in the history
  • Loading branch information
kgy1008 committed Jul 10, 2024
1 parent 3ab74d0 commit 9a076e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import lombok.RequiredArgsConstructor;
import org.hankki.hankkiserver.api.dto.HankkiResponse;
import org.hankki.hankkiserver.api.report.service.ReportService;
import org.hankki.hankkiserver.api.report.service.ReportQueryService;
import org.hankki.hankkiserver.api.report.service.response.ReportServiceResponse;
import org.hankki.hankkiserver.common.code.CommonSuccessCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -15,12 +14,11 @@
@RequestMapping("/api/v1")
public class ReportController {

private final ReportService reportService;
private final ReportQueryService reportQueryService;

@GetMapping("/reports/count")
public HankkiResponse<ReportServiceResponse> getReportCounts() {
ReportServiceResponse response = new ReportServiceResponse(reportService.getMyReportSequence());
return HankkiResponse.success(CommonSuccessCode.OK, response);
return HankkiResponse.success(CommonSuccessCode.OK, ReportServiceResponse.of(reportQueryService.getMyReportSequence()));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import org.hankki.hankkiserver.domain.report.repository.ReportRepository;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class ReportService {
public class ReportQueryService {

private static final long REPORT_SEQUENCE = 1;

private final ReportFinder reportFinder;

@Transactional(readOnly = true)
public long getMyReportSequence() {
return reportFinder.getReportCount() + 1;
return reportFinder.getReportCount() + REPORT_SEQUENCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
public record ReportServiceResponse(
long count
) {
public static ReportServiceResponse of(long count) {
return new ReportServiceResponse(count);
}
}

0 comments on commit 9a076e2

Please sign in to comment.