Skip to content

Commit

Permalink
♻️ refactor: 보고서 관련 기능 수정 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxoznge authored Jan 26, 2024
1 parent 78c6f60 commit 8dc1e51
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
13 changes: 13 additions & 0 deletions http/test.http
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ GET http://localhost:8080/api/v1/announcement/1
### 삭제 (생성한 단체만 삭제 가능)
DELETE http://localhost:8080/api/v1/announcement/1
Authorization: Bearer {{matsterToken}}

### 보고서 작성
POST http://localhost:8080/api/v1/reports
Content-Type: application/json

{
"title": "무신사 스폰서십",
"content": "무신사 스폰서십을 진행했습니다.",
"files": []
}

### 보고서 조회
GET http://localhost:8080/api/v1/reports/0
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@ public class ReportController {
private final ReportQueryService reportQueryService;

@PostMapping
public ApiResponse<ReportResponse> create(@Valid @RequestBody ReportRequest request) {
ReportResponse response = reportService.create(request);
return ApiResponse.onSuccess(response);
public ApiResponse<ReportResponse> createReport(@Valid @RequestBody ReportRequest request) {
return ApiResponse.onSuccess(reportService.createReport(request));
}

@PatchMapping("/{reportId}")
public ApiResponse<ReportResponse> update(@PathVariable Long reportId, @Valid @RequestBody ReportRequest request) {
ReportResponse response = reportService.update(reportId, request);
return ApiResponse.onSuccess(response);
public ApiResponse<ReportResponse> updateReport(@PathVariable Long reportId,
@Valid @RequestBody ReportRequest request) {
return ApiResponse.onSuccess(reportService.updateReport(reportId, request));
}

@GetMapping("/{reportId}")
public ApiResponse<ReportResponse> read(@PathVariable Long reportId) {
ReportResponse response = reportQueryService.read(reportId);
return ApiResponse.onSuccess(response);
public ApiResponse<ReportResponse> readReport(@PathVariable Long reportId) {
return ApiResponse.onSuccess(reportQueryService.readReport(reportId));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ReportQueryService {

private final ReportRepository reportRepository;

public ReportResponse read(Long id) {
public ReportResponse readReport(Long id) {
Report report = reportRepository.findById(id)
.orElseThrow(() -> new ReportException(ReportErrorCode.REPORT_NOT_FOUND));
return ReportResponse.from(report);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
public class ReportService {
private final ReportRepository reportRepository;

public ReportResponse create(ReportRequest request) {
public ReportResponse createReport(ReportRequest request) {
final Report report = reportRepository.save(request.toEntity());
return ReportResponse.from(report);
}

public ReportResponse update(Long reportId, ReportRequest request) {
public ReportResponse updateReport(Long reportId, ReportRequest request) {
final Report report = reportRepository.findById(reportId)
.orElseThrow(() -> new ReportException(ReportErrorCode.REPORT_NOT_FOUND));

Expand Down

0 comments on commit 8dc1e51

Please sign in to comment.