-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
차량 wagger tag 수정 반납 보고서 API 개발 기존 인수 보고서 API 반납 보고서와 합쳐 보고서 API로 전환 #50
- Loading branch information
Showing
11 changed files
with
192 additions
and
49 deletions.
There are no files selected for viewing
33 changes: 25 additions & 8 deletions
33
src/main/java/kea/enter/enterbe/api/vehicle/controller/VehicleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,68 @@ | ||
package kea.enter.enterbe.api.vehicle.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.List; | ||
import kea.enter.enterbe.api.vehicle.service.VehicleService; | ||
import kea.enter.enterbe.api.vehicle.service.dto.PostTakeVehicleReportServiceDto; | ||
import kea.enter.enterbe.api.vehicle.service.dto.PostVehicleReportServiceDto; | ||
import kea.enter.enterbe.domain.report.entity.VehicleReportType; | ||
import kea.enter.enterbe.global.common.api.CustomResponseCode; | ||
import kea.enter.enterbe.global.common.exception.CustomException; | ||
import kea.enter.enterbe.global.common.exception.ResponseCode; | ||
import kea.enter.enterbe.global.util.FileUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.util.StringUtils; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Tag(name = "예제", description = "예제 API 명세서") | ||
@Tag(name = "차량", description = "차량 API 명세서") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/vehicles") | ||
@Validated | ||
public class VehicleController { | ||
|
||
private final VehicleService vehicleService; | ||
private final FileUtil fileUtil; | ||
|
||
@Operation(summary = "인수보고서 작성") | ||
@PostMapping(value = "/reports/take", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, | ||
@Operation(summary = "보고서 작성") | ||
@PostMapping(value = "/reports", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, | ||
MediaType.TEXT_PLAIN_VALUE}) | ||
public ResponseEntity<CustomResponseCode> postTakeVehicleReport( | ||
@RequestPart(value = "front_img") MultipartFile front_img, | ||
@RequestPart(value = "right_img") MultipartFile right_img, | ||
@RequestPart(value = "back_img") MultipartFile back_img, | ||
@RequestPart(value = "left_img") MultipartFile left_img, | ||
@RequestPart(value = "dashboard_img") MultipartFile dashboardImg, | ||
@RequestPart(value = "note") String note) { | ||
@RequestPart(value = "note",required = false) String note, | ||
@RequestPart(value = "parking_loc",required = false) String parkingLoc, | ||
@RequestParam(name = "type") @NotNull(message = "보고서 종류를 입력해주세요") | ||
@Schema(description = "보고서 종류 TAKE, RETURN", example = "TAKE") | ||
VehicleReportType type | ||
) { | ||
//todo: spring security 구현 완료 시 token에서 memberId 값 가져오기 | ||
Long memberId = 1L; | ||
if (!fileUtil.isImageFileList( | ||
List.of(front_img, right_img, back_img, left_img, dashboardImg))) { | ||
throw new CustomException(ResponseCode.NOT_IMAGE_FILE); | ||
} | ||
vehicleService.postTakeVehicleReport( | ||
PostTakeVehicleReportServiceDto.of(memberId, front_img, right_img, back_img, left_img, | ||
dashboardImg, note)); | ||
if(type.equals(VehicleReportType.RETURN) && !StringUtils.hasText(note)){ | ||
throw new CustomException(ResponseCode.NEED_PARKING_LOC_FOR_RETURN_REPORT); | ||
} | ||
vehicleService.postVehicleReport( | ||
PostVehicleReportServiceDto.of(memberId, front_img, right_img, back_img, left_img, | ||
dashboardImg, note, parkingLoc, type)); | ||
return ResponseEntity.ok(CustomResponseCode.SUCCESS); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/java/kea/enter/enterbe/api/vehicle/service/VehicleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package kea.enter.enterbe.api.vehicle.service; | ||
|
||
import kea.enter.enterbe.api.vehicle.service.dto.PostTakeVehicleReportServiceDto; | ||
import kea.enter.enterbe.api.vehicle.service.dto.PostVehicleReportServiceDto; | ||
|
||
public interface VehicleService { | ||
|
||
void postTakeVehicleReport(PostTakeVehicleReportServiceDto dto); | ||
void postVehicleReport(PostVehicleReportServiceDto dto); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
public enum VehicleReportType { | ||
TAKE, RETURN | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.