diff --git a/src/main/java/com/testcar/car/domains/auth/AuthController.java b/src/main/java/com/testcar/car/domains/auth/AuthController.java index db905ab..c6ca38a 100644 --- a/src/main/java/com/testcar/car/domains/auth/AuthController.java +++ b/src/main/java/com/testcar/car/domains/auth/AuthController.java @@ -3,6 +3,8 @@ import com.testcar.car.domains.auth.model.LoginRequest; import com.testcar.car.domains.auth.model.TokenResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; @@ -10,12 +12,14 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "[인증]", description = "인증 API") @RestController @RequestMapping("/auth") @RequiredArgsConstructor public class AuthController { private final AuthService authService; + @Operation(summary = "[로그인] 로그인", description = "로그인을 수행합니다.") @PostMapping("/login") public TokenResponse login(@Valid @RequestBody LoginRequest request) { final String accessToken = authService.login(request); diff --git a/src/main/java/com/testcar/car/domains/auth/model/LoginRequest.java b/src/main/java/com/testcar/car/domains/auth/model/LoginRequest.java index a899fea..754ab17 100644 --- a/src/main/java/com/testcar/car/domains/auth/model/LoginRequest.java +++ b/src/main/java/com/testcar/car/domains/auth/model/LoginRequest.java @@ -3,6 +3,7 @@ import com.testcar.car.common.annotation.Password; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,7 +11,8 @@ @Getter @NoArgsConstructor public class LoginRequest { - @NotBlank + @NotBlank(message = "이메일을 입력해주세요.") + @Email(message = "이메일 형식을 확인해주세요.") @Schema(description = "이메일", example = "kls1998@naver.com") private String email; diff --git a/src/main/java/com/testcar/car/domains/car/CarController.java b/src/main/java/com/testcar/car/domains/car/CarController.java index 1172859..f272129 100644 --- a/src/main/java/com/testcar/car/domains/car/CarController.java +++ b/src/main/java/com/testcar/car/domains/car/CarController.java @@ -6,7 +6,6 @@ import com.testcar.car.domains.car.entity.Car; import com.testcar.car.domains.car.model.CarResponse; import com.testcar.car.domains.car.model.RegisterCarRequest; -import com.testcar.car.domains.car.model.TestCarResponse; import com.testcar.car.domains.car.model.vo.CarFilterCondition; import com.testcar.car.domains.member.Role; import io.swagger.v3.oas.annotations.Operation; @@ -43,32 +42,14 @@ public PageResponse getCarsByCondition( return PageResponse.from(cars.map(CarResponse::from)); } - @GetMapping("/test") - @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험차량 관리] 차량 조회 필터", description = "조건에 맞는 시험 차량을 페이지네이션으로 조회합니다.") - public PageResponse getTestCarsByCondition( - @ParameterObject @ModelAttribute CarFilterCondition condition, - @ParameterObject Pageable pageable) { - final Page cars = carService.findAllWithStocksPageByCondition(condition, pageable); - return PageResponse.from(cars.map(TestCarResponse::from)); - } - @GetMapping("/{carId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[차량 관리] 사용자 상세 정보", description = "차량 상세 정보를 가져옵니다.") + @Operation(summary = "[차량 관리] 차량 상세 정보", description = "차량 상세 정보를 가져옵니다.") public CarResponse getCarById(@PathVariable Long carId) { final Car car = carService.findById(carId); return CarResponse.from(car); } - @PostMapping("/register") - @RoleAllowed(role = Role.ADMIN) - @Operation(summary = "[차량 관리] 차량 등록", description = "(관리자) 새로운 차량을 등록합니다.") - public CarResponse register(@Valid @RequestBody RegisterCarRequest request) { - final Car car = carService.register(request); - return CarResponse.from(car); - } - @PatchMapping("/{carId}") @RoleAllowed(role = Role.ADMIN) @Operation(summary = "[차량 관리] 차량 정보 수정", description = "(관리자) 차량 정보를 수정합니다.") @@ -85,4 +66,12 @@ public CarResponse withdraw(@PathVariable Long carId) { final Car car = carService.deleteById(carId); return CarResponse.from(car); } + + @PostMapping("/register") + @RoleAllowed(role = Role.ADMIN) + @Operation(summary = "[차량 등록] 차량 등록", description = "(관리자) 새로운 차량을 등록합니다.") + public CarResponse register(@Valid @RequestBody RegisterCarRequest request) { + final Car car = carService.register(request); + return CarResponse.from(car); + } } diff --git a/src/main/java/com/testcar/car/domains/car/TestCarController.java b/src/main/java/com/testcar/car/domains/car/TestCarController.java index 112163b..fdfcd3c 100644 --- a/src/main/java/com/testcar/car/domains/car/TestCarController.java +++ b/src/main/java/com/testcar/car/domains/car/TestCarController.java @@ -28,7 +28,7 @@ public class TestCarController { @GetMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험차량 관리] 차량 조회 필터", description = "조건에 맞는 시험 차량을 페이지네이션으로 조회합니다.") + @Operation(summary = "[대여] 차량 조회 필터", description = "조건에 맞는 시험 차량을 페이지네이션으로 조회합니다.") public PageResponse getTestCarsByCondition( @ParameterObject @ModelAttribute CarFilterCondition condition, @ParameterObject Pageable pageable) { @@ -38,7 +38,7 @@ public PageResponse getTestCarsByCondition( @GetMapping("/{carId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험차량 관리] 시험차량 상세 정보", description = "시험차량 상세 정보를 가져옵니다.") + @Operation(summary = "[대여] 시험차량 상세 정보", description = "대여할 시험 차량 상세 정보를 가져옵니다.") public TestCarResponse getCarById(@PathVariable Long carId) { final Car car = testCarService.findById(carId); return TestCarResponse.from(car); diff --git a/src/main/java/com/testcar/car/domains/car/model/RegisterCarRequest.java b/src/main/java/com/testcar/car/domains/car/model/RegisterCarRequest.java index 390f521..c5bc3a8 100644 --- a/src/main/java/com/testcar/car/domains/car/model/RegisterCarRequest.java +++ b/src/main/java/com/testcar/car/domains/car/model/RegisterCarRequest.java @@ -11,17 +11,17 @@ @Getter public class RegisterCarRequest { - @NotBlank + @NotBlank(message = "차량명을 입력해주세요.") @Length(max = 20) @Schema(description = "차량명", example = "아반떼") private String name; - @NotNull + @NotNull(message = "차종을 입력해주세요.") @Schema(description = "차종", example = "SEDAN", implementation = Type.class) private Type type; - @NotNull - @Positive + @NotNull(message = "배기량을 입력해주세요.") + @Positive(message = "배기량은 0보다 커야합니다.") @Schema(description = "배기량", example = "1.6") private Double displacement; } diff --git a/src/main/java/com/testcar/car/domains/carReservation/CarReservationController.java b/src/main/java/com/testcar/car/domains/carReservation/CarReservationController.java index 203f687..b809474 100644 --- a/src/main/java/com/testcar/car/domains/carReservation/CarReservationController.java +++ b/src/main/java/com/testcar/car/domains/carReservation/CarReservationController.java @@ -35,9 +35,18 @@ public class CarReservationController { private final CarReservationService carReservationService; + @PostMapping("/reserve") + @RoleAllowed(role = Role.USER) + @Operation(summary = "[대여] 시험 차량 대여", description = "시험 차량을 예약합니다.") + public CarReservationResponse postCarReservation( + @AuthMember Member member, @Valid @RequestBody CarReservationRequest request) { + final CarReservation carReservation = carReservationService.reserve(member, request); + return CarReservationResponse.from(carReservation); + } + @GetMapping("/reservations") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험차량 관리] 시험차량 대여 이력", description = "조건에 맞는 시험차량 대여 이력을 모두 조회합니다.") + @Operation(summary = "[대여 이력] 시험차량 대여 이력", description = "조건에 맞는 시험차량 대여 이력을 모두 조회합니다.") public PageResponse getCarReservationsByCondition( @ParameterObject @ModelAttribute CarReservationFilterCondition condition, @ParameterObject Pageable pageable) { @@ -46,18 +55,9 @@ public PageResponse getCarReservationsByCondition( return PageResponse.from(carReservations.map(CarReservationResponse::from)); } - @PostMapping("/reserve") - @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험차량 관리] 시험차량 대여", description = "시험 차량을 예약합니다.") - public CarReservationResponse postCarReservation( - @AuthMember Member member, @Valid @RequestBody CarReservationRequest request) { - final CarReservation carReservation = carReservationService.reserve(member, request); - return CarReservationResponse.from(carReservation); - } - @PatchMapping("/return") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험차량 관리] 시험차량 반납", description = "시험 차량을 반납합니다.") + @Operation(summary = "[대여 이력] 시험차량 반납", description = "시험 차량을 반납합니다.") public List postCarReservation( @AuthMember Member member, @Valid @RequestBody ReturnCarReservationRequest request) { final List carReservation = diff --git a/src/main/java/com/testcar/car/domains/carReservation/model/CarReservationRequest.java b/src/main/java/com/testcar/car/domains/carReservation/model/CarReservationRequest.java index 5388e79..06a6713 100644 --- a/src/main/java/com/testcar/car/domains/carReservation/model/CarReservationRequest.java +++ b/src/main/java/com/testcar/car/domains/carReservation/model/CarReservationRequest.java @@ -3,11 +3,13 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; import lombok.Getter; @Getter public class CarReservationRequest { - @NotNull + @NotNull(message = "차량재고 ID를 입력해주세요.") + @Positive(message = "차량재고 ID는 0보다 커야합니다.") @Schema(description = "차량재고 ID", example = "1") private Long carStockId; } diff --git a/src/main/java/com/testcar/car/domains/carReservation/model/ReturnCarReservationRequest.java b/src/main/java/com/testcar/car/domains/carReservation/model/ReturnCarReservationRequest.java index 0a660a0..491a494 100644 --- a/src/main/java/com/testcar/car/domains/carReservation/model/ReturnCarReservationRequest.java +++ b/src/main/java/com/testcar/car/domains/carReservation/model/ReturnCarReservationRequest.java @@ -2,13 +2,15 @@ import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import java.util.List; import lombok.Getter; @Getter public class ReturnCarReservationRequest { - @NotNull + @NotNull(message = "차량 예약 ID 리스트를 입력해주세요.") + @NotEmpty(message = "차량 예약 ID 리스트를 입력해주세요.") @Schema(description = "차량 예약 ID 리스트", example = "[1, 2, 3]") private List carReservationIds; } diff --git a/src/main/java/com/testcar/car/domains/carStock/CarStockController.java b/src/main/java/com/testcar/car/domains/carStock/CarStockController.java index 382064a..4838eab 100644 --- a/src/main/java/com/testcar/car/domains/carStock/CarStockController.java +++ b/src/main/java/com/testcar/car/domains/carStock/CarStockController.java @@ -11,6 +11,7 @@ import com.testcar.car.domains.carStock.model.vo.CarStockFilterCondition; import com.testcar.car.domains.member.Role; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; @@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "[차량 관리] ", description = "차량 재고 관리 API") @RestController @RequestMapping("/cars/stocks") @RequiredArgsConstructor diff --git a/src/main/java/com/testcar/car/domains/carStock/model/DeleteCarStockRequest.java b/src/main/java/com/testcar/car/domains/carStock/model/DeleteCarStockRequest.java index d510b4f..139070a 100644 --- a/src/main/java/com/testcar/car/domains/carStock/model/DeleteCarStockRequest.java +++ b/src/main/java/com/testcar/car/domains/carStock/model/DeleteCarStockRequest.java @@ -10,7 +10,8 @@ @Getter public class DeleteCarStockRequest { - @NotEmpty + @NotNull(message = "차량 재고 ID를 입력해주세요.") + @NotEmpty(message = "차량 재고 ID를 입력해주세요.") @Schema(description = "차량 재고 ID", example = "[1, 2, 3]") private List<@NotNull @Positive Long> ids; } diff --git a/src/main/java/com/testcar/car/domains/carStock/model/RegisterCarStockRequest.java b/src/main/java/com/testcar/car/domains/carStock/model/RegisterCarStockRequest.java index a0e4338..d5c80fe 100644 --- a/src/main/java/com/testcar/car/domains/carStock/model/RegisterCarStockRequest.java +++ b/src/main/java/com/testcar/car/domains/carStock/model/RegisterCarStockRequest.java @@ -6,20 +6,22 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Positive; import lombok.Getter; @Getter public class RegisterCarStockRequest { - @NotNull + @NotNull(message = "차량 ID를 입력해주세요.") + @Positive(message = "차량 ID는 0보다 커야합니다.") @Schema(description = "차량 ID", example = "아반떼") private Long carId; - @NotBlank - @Pattern(regexp = "^[0-9]{12}$") + @NotBlank(message = "차량 재고번호를 입력해주세요.") + @Pattern(regexp = "^[0-9]{12}$", message = "차량 재고번호는 12자리 숫자만 가능합니다.") @Schema(description = "차량 재고번호", example = "2023010300001") private String stockNumber; - @NotNull + @NotNull(message = "차량 재고 상태를 입력해주세요.") @Schema(description = "재고 상태", example = "AVAILABLE", implementation = StockStatus.class) private StockStatus status; } diff --git a/src/main/java/com/testcar/car/domains/carStock/model/UpdateCarStockRequest.java b/src/main/java/com/testcar/car/domains/carStock/model/UpdateCarStockRequest.java index 9654b20..13aef7c 100644 --- a/src/main/java/com/testcar/car/domains/carStock/model/UpdateCarStockRequest.java +++ b/src/main/java/com/testcar/car/domains/carStock/model/UpdateCarStockRequest.java @@ -10,12 +10,12 @@ @Getter public class UpdateCarStockRequest { - @NotBlank - @Pattern(regexp = "^[0-9]{12}$") + @NotBlank(message = "차량 재고번호를 입력해주세요.") + @Pattern(regexp = "^[0-9]{12}$", message = "차량 재고번호는 12자리 숫자만 가능합니다.") @Schema(description = "차량 재고번호", example = "2023010300001") private String stockNumber; - @NotNull + @NotNull(message = "차량 재고 상태를 입력해주세요.") @Schema(description = "재고 상태", example = "AVAILABLE", implementation = StockStatus.class) private StockStatus status; } diff --git a/src/main/java/com/testcar/car/domains/carTest/CarTestController.java b/src/main/java/com/testcar/car/domains/carTest/CarTestController.java index 687fcfe..8fbbefd 100644 --- a/src/main/java/com/testcar/car/domains/carTest/CarTestController.java +++ b/src/main/java/com/testcar/car/domains/carTest/CarTestController.java @@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -@Tag(name = "[시험장 관리] 시험 수행 이력", description = "차량 시험 수행 결과를 관리합니다.") +@Tag(name = "[시험차량 관리]", description = "차량 시험 수행 결과를 관리합니다.") @RestController @RequestMapping("/cars/tests") @RequiredArgsConstructor @@ -38,7 +38,7 @@ public class CarTestController { @GetMapping @RoleAllowed(role = Role.USER) @Operation( - summary = "[시험장 관리] 시험 수행 이력 조회 필터", + summary = "[시험 수행 이력] 시험 수행 이력 조회 필터", description = "조건에 맞는 모든 시험 수행 이력을 페이지네이션으로 조회합니다.") public PageResponse getCarTestsByCondition( @ParameterObject @ModelAttribute CarTestFilterCondition condition, @@ -50,7 +50,7 @@ public PageResponse getCarTestsByCondition( @GetMapping("/{carTestId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험 수행 이력 상세", description = "시험 수행 이력을 id로 조회합니다.") + @Operation(summary = "[시험 수행 이력] 시험 수행 이력 상세", description = "시험 수행 이력을 id로 조회합니다.") public CarTestResponse getCarTestsByCondition(@PathVariable Long carTestId) { final CarTestDto carTest = carTestService.findById(carTestId); return CarTestResponse.from(carTest); @@ -58,7 +58,7 @@ public CarTestResponse getCarTestsByCondition(@PathVariable Long carTestId) { @PostMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험 수행 이력 등록", description = "시험 수행 이력을 등록합니다.") + @Operation(summary = "[시험 수행 이력] 시험 수행 이력 등록", description = "시험 수행 이력을 등록합니다.") public CarTestResponse register( @AuthMember Member member, @Valid @RequestBody CarTestRequest request) { final CarTest carTest = carTestService.register(member, request); @@ -67,7 +67,7 @@ public CarTestResponse register( @PatchMapping("/{carTestId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험 수행 이력 수정", description = "시험 수행 이력을 수정합니다.") + @Operation(summary = "[시험 수행 이력] 시험 수행 이력 수정", description = "시험 수행 이력을 수정합니다.") public CarTestResponse update( @AuthMember Member member, @PathVariable Long carTestId, @@ -78,7 +78,7 @@ public CarTestResponse update( @DeleteMapping("/{carTestId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험 수행 이력 삭제", description = "시험 수행 이력을 삭제합니다.") + @Operation(summary = "[시험 수행 이력] 시험 수행 이력 삭제", description = "시험 수행 이력을 삭제합니다.") public Long delete(@AuthMember Member member, @PathVariable Long carTestId) { carTestService.delete(member, carTestId); return carTestId; diff --git a/src/main/java/com/testcar/car/domains/carTest/model/CarTestRequest.java b/src/main/java/com/testcar/car/domains/carTest/model/CarTestRequest.java index e3cd3e7..8437a8c 100644 --- a/src/main/java/com/testcar/car/domains/carTest/model/CarTestRequest.java +++ b/src/main/java/com/testcar/car/domains/carTest/model/CarTestRequest.java @@ -4,22 +4,26 @@ import com.testcar.car.common.annotation.DateFormat; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.LocalDate; import lombok.Getter; @Getter public class CarTestRequest { - @NotBlank + @NotBlank(message = "시험장 이름을 입력해주세요.") @Schema(description = "시험장 이름", example = "서산주행시험장") private String trackName; + @NotBlank(message = "차량 재고 번호를 입력해주세요.") @Schema(description = "차량 재고 번호", example = "123412343333") private String stockNumber; @DateFormat + @NotNull(message = "시험일자를 입력해주세요.") @Schema(description = "시험일자", example = "2021-01-01") private LocalDate performedAt; + @NotBlank(message = "주행 결과를 입력해주세요.") @Schema(description = "주행결과", example = "이상없음") private String result; diff --git a/src/main/java/com/testcar/car/domains/carTest/model/CarTestResponse.java b/src/main/java/com/testcar/car/domains/carTest/model/CarTestResponse.java index 4068aa1..fad0cb7 100644 --- a/src/main/java/com/testcar/car/domains/carTest/model/CarTestResponse.java +++ b/src/main/java/com/testcar/car/domains/carTest/model/CarTestResponse.java @@ -7,7 +7,7 @@ import com.testcar.car.domains.carStock.entity.CarStock; import com.testcar.car.domains.carTest.entity.CarTest; import com.testcar.car.domains.carTest.model.vo.CarTestDto; -import com.testcar.car.domains.department.Department; +import com.testcar.car.domains.department.entity.Department; import com.testcar.car.domains.member.Member; import com.testcar.car.domains.track.Track; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/com/testcar/car/domains/department/DepartmentController.java b/src/main/java/com/testcar/car/domains/department/DepartmentController.java index a78f8a1..1e48514 100644 --- a/src/main/java/com/testcar/car/domains/department/DepartmentController.java +++ b/src/main/java/com/testcar/car/domains/department/DepartmentController.java @@ -2,10 +2,12 @@ import com.testcar.car.common.annotation.RoleAllowed; +import com.testcar.car.domains.department.entity.Department; import com.testcar.car.domains.department.model.CreateDepartmentRequest; import com.testcar.car.domains.department.model.DepartmentResponse; import com.testcar.car.domains.member.Role; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; @@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "[부서 관리] ", description = "부서 관리 API") @RestController @RequestMapping("/departments") @RequiredArgsConstructor @@ -31,7 +34,7 @@ public List findAll() { @PostMapping @RoleAllowed(role = Role.ADMIN) - @Operation(summary = "[부서 관리] 부서 생성", description = "(관리자) 새로운 부서를 생성합니다.") + @Operation(summary = "[부서 등록] 부서 생성", description = "(관리자) 새로운 부서를 생성합니다.") public DepartmentResponse create(@Valid @RequestBody CreateDepartmentRequest request) { final Department department = departmentService.create(request); return DepartmentResponse.from(department); diff --git a/src/main/java/com/testcar/car/domains/department/DepartmentService.java b/src/main/java/com/testcar/car/domains/department/DepartmentService.java index 444898f..7e738c1 100644 --- a/src/main/java/com/testcar/car/domains/department/DepartmentService.java +++ b/src/main/java/com/testcar/car/domains/department/DepartmentService.java @@ -4,8 +4,10 @@ import com.testcar.car.common.exception.BadRequestException; import com.testcar.car.common.exception.NotFoundException; +import com.testcar.car.domains.department.entity.Department; import com.testcar.car.domains.department.exception.ErrorCode; import com.testcar.car.domains.department.model.CreateDepartmentRequest; +import com.testcar.car.domains.department.repository.DepartmentRepository; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/testcar/car/domains/department/Department.java b/src/main/java/com/testcar/car/domains/department/entity/Department.java similarity index 94% rename from src/main/java/com/testcar/car/domains/department/Department.java rename to src/main/java/com/testcar/car/domains/department/entity/Department.java index 1f900f6..efae32a 100644 --- a/src/main/java/com/testcar/car/domains/department/Department.java +++ b/src/main/java/com/testcar/car/domains/department/entity/Department.java @@ -1,4 +1,4 @@ -package com.testcar.car.domains.department; +package com.testcar.car.domains.department.entity; import com.testcar.car.common.entity.BaseEntity; diff --git a/src/main/java/com/testcar/car/domains/department/model/CreateDepartmentRequest.java b/src/main/java/com/testcar/car/domains/department/model/CreateDepartmentRequest.java index b590487..b1f9195 100644 --- a/src/main/java/com/testcar/car/domains/department/model/CreateDepartmentRequest.java +++ b/src/main/java/com/testcar/car/domains/department/model/CreateDepartmentRequest.java @@ -2,10 +2,12 @@ import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; import lombok.Getter; @Getter public class CreateDepartmentRequest { + @NotBlank(message = "부서명을 입력해주세요.") @Schema(description = "부서명", example = "시스템관리팀") private String name; } diff --git a/src/main/java/com/testcar/car/domains/department/model/DepartmentResponse.java b/src/main/java/com/testcar/car/domains/department/model/DepartmentResponse.java index 2830615..2a5ac08 100644 --- a/src/main/java/com/testcar/car/domains/department/model/DepartmentResponse.java +++ b/src/main/java/com/testcar/car/domains/department/model/DepartmentResponse.java @@ -1,7 +1,7 @@ package com.testcar.car.domains.department.model; -import com.testcar.car.domains.department.Department; +import com.testcar.car.domains.department.entity.Department; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/testcar/car/domains/department/model/vo/DepartmentVo.java b/src/main/java/com/testcar/car/domains/department/model/vo/DepartmentVo.java index 5b16ce6..e29b793 100644 --- a/src/main/java/com/testcar/car/domains/department/model/vo/DepartmentVo.java +++ b/src/main/java/com/testcar/car/domains/department/model/vo/DepartmentVo.java @@ -1,7 +1,7 @@ package com.testcar.car.domains.department.model.vo; -import com.testcar.car.domains.department.Department; +import com.testcar.car.domains.department.entity.Department; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/testcar/car/domains/department/DepartmentRepository.java b/src/main/java/com/testcar/car/domains/department/repository/DepartmentRepository.java similarity index 75% rename from src/main/java/com/testcar/car/domains/department/DepartmentRepository.java rename to src/main/java/com/testcar/car/domains/department/repository/DepartmentRepository.java index c9dacfa..f590e89 100644 --- a/src/main/java/com/testcar/car/domains/department/DepartmentRepository.java +++ b/src/main/java/com/testcar/car/domains/department/repository/DepartmentRepository.java @@ -1,6 +1,7 @@ -package com.testcar.car.domains.department; +package com.testcar.car.domains.department.repository; +import com.testcar.car.domains.department.entity.Department; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/com/testcar/car/domains/expense/ExpenseController.java b/src/main/java/com/testcar/car/domains/expense/ExpenseController.java index b5ac964..a03b416 100644 --- a/src/main/java/com/testcar/car/domains/expense/ExpenseController.java +++ b/src/main/java/com/testcar/car/domains/expense/ExpenseController.java @@ -37,7 +37,7 @@ public class ExpenseController { @GetMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[지출 관리] 지출 내역 조회", description = "지출 내역을 조건에 맞게 조회합니다.") + @Operation(summary = "[지출 내역 관리] 지출 내역 조회", description = "지출 내역을 조건에 맞게 조회합니다.") public PageResponse getExpensesByCondition( @ParameterObject @ModelAttribute ExpenseFilterCondition condition, @ParameterObject Pageable pageable) { @@ -47,7 +47,7 @@ public PageResponse getExpensesByCondition( @GetMapping("/{expenseId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[지출 관리]] 지출 이력 상세 조회", description = "지출 이력 상세 정보를 id로 조회합니다.") + @Operation(summary = "[지출 내역 관리] 지출 이력 조회", description = "지출 이력 상세 정보를 id로 조회합니다.") public ExpenseResponse getExpenseById(@PathVariable Long expenseId) { final ExpenseDto dto = expenseService.findById(expenseId); return ExpenseResponse.from(dto); @@ -55,7 +55,7 @@ public ExpenseResponse getExpenseById(@PathVariable Long expenseId) { @PostMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[지출 관리] 지출 이력 등록", description = "지출 이력을 등록합니다.") + @Operation(summary = "[지출 내역 관리] 지출 이력 등록", description = "지출 이력을 등록합니다.") public ExpenseResponse register( @AuthMember Member member, @Valid @RequestBody RegisterExpenseRequest request) { final Expense expense = expenseService.register(member, request); @@ -64,7 +64,7 @@ public ExpenseResponse register( @PatchMapping("/{expenseId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[지출 관리] 지출 이력 수정", description = "지출 이력을 수정합니다.") + @Operation(summary = "[지출 내역 관리] 지출 이력 수정", description = "지출 이력을 수정합니다.") public ExpenseResponse update( @AuthMember Member member, @PathVariable Long expenseId, @@ -75,7 +75,7 @@ public ExpenseResponse update( @DeleteMapping("/{expenseId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[지출 관리] 지출 이력 삭제", description = "지출 이력을 삭제합니다.") + @Operation(summary = "[지출 내역 관리] 지출 이력 삭제", description = "지출 이력을 삭제합니다.") public Long delete(@AuthMember Member member, @PathVariable Long expenseId) { expenseService.delete(member, expenseId); return expenseId; diff --git a/src/main/java/com/testcar/car/domains/expense/model/ExpenseResponse.java b/src/main/java/com/testcar/car/domains/expense/model/ExpenseResponse.java index f401e76..fa513fa 100644 --- a/src/main/java/com/testcar/car/domains/expense/model/ExpenseResponse.java +++ b/src/main/java/com/testcar/car/domains/expense/model/ExpenseResponse.java @@ -5,7 +5,7 @@ import com.testcar.car.common.annotation.DateTimeFormat; import com.testcar.car.domains.car.entity.Car; import com.testcar.car.domains.carStock.entity.CarStock; -import com.testcar.car.domains.department.Department; +import com.testcar.car.domains.department.entity.Department; import com.testcar.car.domains.expense.entity.Expense; import com.testcar.car.domains.expense.model.dto.ExpenseDto; import com.testcar.car.domains.member.Member; diff --git a/src/main/java/com/testcar/car/domains/expense/model/RegisterExpenseRequest.java b/src/main/java/com/testcar/car/domains/expense/model/RegisterExpenseRequest.java index 59f48f6..a323726 100644 --- a/src/main/java/com/testcar/car/domains/expense/model/RegisterExpenseRequest.java +++ b/src/main/java/com/testcar/car/domains/expense/model/RegisterExpenseRequest.java @@ -18,8 +18,8 @@ public class RegisterExpenseRequest { @Schema(description = "재고번호", example = "123412341234") private String stockNumber; - @NotNull(message = "지출일자를 입력해주세요.") @DateFormat + @NotNull(message = "지출일자를 입력해주세요.") @Schema(description = "지출일자", example = "2021-01-01") private LocalDate usedAt; diff --git a/src/main/java/com/testcar/car/domains/gasStation/model/DeleteGasStationRequest.java b/src/main/java/com/testcar/car/domains/gasStation/model/DeleteGasStationRequest.java index 116d79c..1ae9841 100644 --- a/src/main/java/com/testcar/car/domains/gasStation/model/DeleteGasStationRequest.java +++ b/src/main/java/com/testcar/car/domains/gasStation/model/DeleteGasStationRequest.java @@ -2,13 +2,17 @@ import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; import java.util.List; import lombok.Getter; @Getter public class DeleteGasStationRequest { - @NotEmpty + @NotNull(message = "주유소 ID 리스트를 입력해주세요.") + @NotEmpty(message = "주유소 ID 리스트를 입력해주세요.") @Schema(description = "주유소 ID", example = "[1, 2, 3]") - private List ids; + private List<@Valid @NotNull @Positive Long> ids; } diff --git a/src/main/java/com/testcar/car/domains/gasStation/model/RegisterGasStationRequest.java b/src/main/java/com/testcar/car/domains/gasStation/model/RegisterGasStationRequest.java index 7549ba2..689ad9f 100644 --- a/src/main/java/com/testcar/car/domains/gasStation/model/RegisterGasStationRequest.java +++ b/src/main/java/com/testcar/car/domains/gasStation/model/RegisterGasStationRequest.java @@ -7,7 +7,7 @@ @Getter public class RegisterGasStationRequest { - @NotBlank + @NotBlank(message = "주유소명을 입력해주세요.") @Schema(description = "주유소명", example = "서산주유소A") private String name; } diff --git a/src/main/java/com/testcar/car/domains/gasStation/model/UpdateGasStationRequest.java b/src/main/java/com/testcar/car/domains/gasStation/model/UpdateGasStationRequest.java index 0fb6e09..41668aa 100644 --- a/src/main/java/com/testcar/car/domains/gasStation/model/UpdateGasStationRequest.java +++ b/src/main/java/com/testcar/car/domains/gasStation/model/UpdateGasStationRequest.java @@ -7,7 +7,7 @@ @Getter public class UpdateGasStationRequest { - @NotBlank + @NotBlank(message = "주유소명을 입력해주세요.") @Schema(description = "주유소명", example = "서산주유소A") private String name; } diff --git a/src/main/java/com/testcar/car/domains/gasStationHistory/GasStationHistoryController.java b/src/main/java/com/testcar/car/domains/gasStationHistory/GasStationHistoryController.java index 4c972fa..5535a2f 100644 --- a/src/main/java/com/testcar/car/domains/gasStationHistory/GasStationHistoryController.java +++ b/src/main/java/com/testcar/car/domains/gasStationHistory/GasStationHistoryController.java @@ -37,7 +37,7 @@ public class GasStationHistoryController { @GetMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[주유소 관리] 주유 이력 조회", description = "주유 이력을 조건에 맞게 조회합니다.") + @Operation(summary = "[주유 이력 관리] 주유 이력 조회", description = "주유 이력을 조건에 맞게 조회합니다.") public PageResponse getGasStationHistoriesByCondition( @ParameterObject @ModelAttribute GasStationHistoryFilterCondition condition, @ParameterObject Pageable pageable) { @@ -48,7 +48,7 @@ public PageResponse getGasStationHistoriesByCondition @GetMapping("/{historyId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[주유소 관리] 주유 이력 상세 조회", description = "주유 이력 상세 정보를 id로 조회합니다.") + @Operation(summary = "[주유 이력 관리] 주유 이력 상세 조회", description = "주유 이력 상세 정보를 id로 조회합니다.") public GasStationHistoryResponse getGasStationHistoryById(@PathVariable Long historyId) { final GasStationHistoryDto dto = gasStationHistoryService.findById(historyId); return GasStationHistoryResponse.from(dto); @@ -56,7 +56,7 @@ public GasStationHistoryResponse getGasStationHistoryById(@PathVariable Long his @PostMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[주유소 관리] 주유 이력 등록", description = "주유 이력을 등록합니다.") + @Operation(summary = "[주유 이력 관리] 주유 이력 등록", description = "주유 이력을 등록합니다.") public GasStationHistoryResponse register( @AuthMember Member member, @Valid @RequestBody RegisterGasStationHistoryRequest request) { @@ -67,7 +67,7 @@ public GasStationHistoryResponse register( @PatchMapping("/{gasStationHistoryId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[주유소 관리] 주유 이력 수정", description = "주유 이력을 수정합니다.") + @Operation(summary = "[주유 이력 관리] 주유 이력 수정", description = "주유 이력을 수정합니다.") public GasStationHistoryResponse update( @AuthMember Member member, @PathVariable Long gasStationHistoryId, @@ -79,7 +79,7 @@ public GasStationHistoryResponse update( @DeleteMapping("/{gasStationHistoryId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[주유소 관리] 주유 이력 삭제", description = "주유 이력을 삭제합니다.") + @Operation(summary = "[주유 이력 관리] 주유 이력 삭제", description = "주유 이력을 삭제합니다.") public GasStationHistoryResponse delete( @AuthMember Member member, @PathVariable Long gasStationHistoryId) { final GasStationHistory gasStationHistory = diff --git a/src/main/java/com/testcar/car/domains/gasStationHistory/model/RegisterGasStationHistoryRequest.java b/src/main/java/com/testcar/car/domains/gasStationHistory/model/RegisterGasStationHistoryRequest.java index 5a6dfd9..1f81877 100644 --- a/src/main/java/com/testcar/car/domains/gasStationHistory/model/RegisterGasStationHistoryRequest.java +++ b/src/main/java/com/testcar/car/domains/gasStationHistory/model/RegisterGasStationHistoryRequest.java @@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Positive; import java.time.LocalDate; import lombok.Getter; @@ -21,11 +22,12 @@ public class RegisterGasStationHistoryRequest { private String stockNumber; @NotNull(message = "주유량을 입력해주세요.") + @Positive(message = "주유량은 0보다 커야합니다.") @Schema(description = "주유량", example = "100.33") private Double amount; - @NotNull(message = "주유일자를 입력해주세요.") @DateFormat + @NotNull(message = "주유일자를 입력해주세요.") @Schema(description = "주유일자", example = "2021-01-01") private LocalDate usedAt; } diff --git a/src/main/java/com/testcar/car/domains/health/HelloController.java b/src/main/java/com/testcar/car/domains/health/HelloController.java index a2e3996..74d3e92 100644 --- a/src/main/java/com/testcar/car/domains/health/HelloController.java +++ b/src/main/java/com/testcar/car/domains/health/HelloController.java @@ -1,10 +1,12 @@ package com.testcar.car.domains.health; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** server health check 를 수행하는 컨트롤러 */ +@Tag(name = "[Health Check]", description = "서버 상태 체크 API") @RestController public class HelloController { @GetMapping("/") diff --git a/src/main/java/com/testcar/car/domains/member/Member.java b/src/main/java/com/testcar/car/domains/member/Member.java index b94b16b..77d9c58 100644 --- a/src/main/java/com/testcar/car/domains/member/Member.java +++ b/src/main/java/com/testcar/car/domains/member/Member.java @@ -2,7 +2,7 @@ import com.testcar.car.common.entity.BaseEntity; -import com.testcar.car.domains.department.Department; +import com.testcar.car.domains.department.entity.Department; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; diff --git a/src/main/java/com/testcar/car/domains/member/MemberController.java b/src/main/java/com/testcar/car/domains/member/MemberController.java index 406cfbb..f9cd720 100644 --- a/src/main/java/com/testcar/car/domains/member/MemberController.java +++ b/src/main/java/com/testcar/car/domains/member/MemberController.java @@ -9,6 +9,7 @@ import com.testcar.car.domains.member.model.UpdateMemberRequest; import com.testcar.car.domains.member.model.vo.MemberFilterCondition; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springdoc.core.annotations.ParameterObject; @@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "[사용자 관리]", description = "사용자 관리 API") @RestController @RequestMapping("/members") @RequiredArgsConstructor @@ -32,14 +34,14 @@ public class MemberController { @GetMapping("/me") @RoleAllowed(role = Role.USER) - @Operation(summary = "[사용자 관리] 내 정보", description = "나의 정보를 가져옵니다.") + @Operation(summary = "[내 정보] 내 정보", description = "나의 정보를 가져옵니다.") public MemberResponse getMe(@AuthMember Member member) { return MemberResponse.from(member); } @GetMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[사용자 관리] 사용자 조회 필터", description = "조건에 맞는 모든 사용자를 페이지네이션으로 조회합니다.") + @Operation(summary = "[사용자 조회] 사용자 조회 필터", description = "조건에 맞는 모든 사용자를 페이지네이션으로 조회합니다.") public PageResponse getMembersByCondition( @ParameterObject @ModelAttribute MemberFilterCondition condition, @ParameterObject Pageable pageable) { @@ -49,7 +51,7 @@ public PageResponse getMembersByCondition( @GetMapping("/{memberId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[사용자 관리] 사용자 상세 정보", description = "사용자의 상세 정보를 가져옵니다.") + @Operation(summary = "[사용자 조회] 사용자 상세 정보", description = "사용자의 상세 정보를 가져옵니다.") public MemberResponse getMemberById(@PathVariable Long memberId) { final Member member = memberService.findById(memberId); return MemberResponse.from(member); @@ -57,7 +59,7 @@ public MemberResponse getMemberById(@PathVariable Long memberId) { @PostMapping("/register") @RoleAllowed(role = Role.ADMIN) - @Operation(summary = "[사용자 관리] 계정 생성", description = "(관리자) 새로운 사용자 계정을 생성합니다.") + @Operation(summary = "[계정 생성] 계정 생성", description = "(관리자) 새로운 사용자 계정을 생성합니다.") public MemberResponse register(@Valid @RequestBody RegisterMemberRequest request) { final Member member = memberService.register(request); return MemberResponse.from(member); @@ -65,7 +67,7 @@ public MemberResponse register(@Valid @RequestBody RegisterMemberRequest request @PatchMapping("/{memberId}") @RoleAllowed(role = Role.ADMIN) - @Operation(summary = "[사용자 관리] 사용자 정보 수정", description = "(관리자) 사용자 정보를 수정합니다.") + @Operation(summary = "[사용자 조회] 사용자 정보 수정", description = "(관리자) 사용자 정보를 수정합니다.") public MemberResponse update( @PathVariable Long memberId, @Valid @RequestBody UpdateMemberRequest request) { final Member member = memberService.updateById(memberId, request); @@ -74,7 +76,7 @@ public MemberResponse update( @DeleteMapping("/{memberId}") @RoleAllowed(role = Role.ADMIN) - @Operation(summary = "[사용자 관리] 사용자 삭제", description = "(관리자) 사용자를 삭제합니다.") + @Operation(summary = "[사용자 조회] 사용자 삭제", description = "(관리자) 사용자를 삭제합니다.") public MemberResponse withdraw(@AuthMember Member member, @PathVariable Long memberId) { final Member deleteMember = memberService.deleteById(member, memberId); return MemberResponse.from(deleteMember); diff --git a/src/main/java/com/testcar/car/domains/member/MemberService.java b/src/main/java/com/testcar/car/domains/member/MemberService.java index db9a460..e0ba3d3 100644 --- a/src/main/java/com/testcar/car/domains/member/MemberService.java +++ b/src/main/java/com/testcar/car/domains/member/MemberService.java @@ -4,8 +4,8 @@ import com.testcar.car.common.exception.BadRequestException; import com.testcar.car.common.exception.NotFoundException; import com.testcar.car.domains.auth.util.PasswordEncoder; -import com.testcar.car.domains.department.Department; import com.testcar.car.domains.department.DepartmentService; +import com.testcar.car.domains.department.entity.Department; import com.testcar.car.domains.member.exception.ErrorCode; import com.testcar.car.domains.member.model.RegisterMemberRequest; import com.testcar.car.domains.member.model.UpdateMemberRequest; diff --git a/src/main/java/com/testcar/car/domains/member/model/RegisterMemberRequest.java b/src/main/java/com/testcar/car/domains/member/model/RegisterMemberRequest.java index f4a6302..b935402 100644 --- a/src/main/java/com/testcar/car/domains/member/model/RegisterMemberRequest.java +++ b/src/main/java/com/testcar/car/domains/member/model/RegisterMemberRequest.java @@ -13,26 +13,27 @@ @Getter public class RegisterMemberRequest { - @NotNull - @Positive + @NotNull(message = "부서 ID를 입력해주세요.") + @Positive(message = "부서 ID는 0보다 커야합니다.") @Schema(description = "부서 ID", example = "1") private Long departmentId; - @Email - @NotBlank - @Length(max = 50) + @Length(max = 50, message = "이메일은 50자 이하로 입력해주세요.") + @Email(message = "이메일 형식이 올바르지 않습니다.") + @NotBlank(message = "이메일을 입력해주세요.") @Schema(description = "이메일", example = "kls1998@naver.com") private String email; @Password + @NotBlank(message = "비밀번호를 입력해주세요.") @Schema(description = "비밀번호", example = "1234abcd@") private String password; - @NotBlank + @NotBlank(message = "이름을 입력해주세요.") @Schema(description = "이름", example = "홍길동") private String name; - @NotNull + @NotNull(message = "권한을 입력해주세요.") @Schema(description = "권한", example = "USER", implementation = Role.class) private Role role; } diff --git a/src/main/java/com/testcar/car/domains/member/model/UpdateMemberRequest.java b/src/main/java/com/testcar/car/domains/member/model/UpdateMemberRequest.java index a067280..f351cb2 100644 --- a/src/main/java/com/testcar/car/domains/member/model/UpdateMemberRequest.java +++ b/src/main/java/com/testcar/car/domains/member/model/UpdateMemberRequest.java @@ -12,22 +12,22 @@ @Getter public class UpdateMemberRequest { - @NotNull - @Positive + @NotNull(message = "부서 ID를 입력해주세요.") + @Positive(message = "부서 ID는 0보다 커야합니다.") @Schema(description = "부서 ID", example = "1") private Long departmentId; - @Email - @NotBlank - @Length(max = 50) + @Email(message = "이메일 형식이 올바르지 않습니다.") + @NotBlank(message = "이메일을 입력해주세요.") + @Length(max = 50, message = "이메일은 50자 이하로 입력해주세요.") @Schema(description = "이메일", example = "kls1998@naver.com") private String email; - @NotBlank + @NotBlank(message = "이름을 입력해주세요.") @Schema(description = "이름", example = "홍길동") private String name; - @NotNull + @NotNull(message = "권한을 입력해주세요.") @Schema(description = "권한", example = "USER", implementation = Role.class) private Role role; } diff --git a/src/main/java/com/testcar/car/domains/member/repository/MemberCustomRepositoryImpl.java b/src/main/java/com/testcar/car/domains/member/repository/MemberCustomRepositoryImpl.java index 7dfc74e..79fb81c 100644 --- a/src/main/java/com/testcar/car/domains/member/repository/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/testcar/car/domains/member/repository/MemberCustomRepositoryImpl.java @@ -1,6 +1,6 @@ package com.testcar.car.domains.member.repository; -import static com.testcar.car.domains.department.QDepartment.department; +import static com.testcar.car.domains.department.entity.QDepartment.department; import static com.testcar.car.domains.member.QMember.member; import com.querydsl.core.types.dsl.BooleanExpression; diff --git a/src/main/java/com/testcar/car/domains/track/TrackController.java b/src/main/java/com/testcar/car/domains/track/TrackController.java index bb72c89..ec81424 100644 --- a/src/main/java/com/testcar/car/domains/track/TrackController.java +++ b/src/main/java/com/testcar/car/domains/track/TrackController.java @@ -8,6 +8,7 @@ import com.testcar.car.domains.track.model.TrackResponse; import com.testcar.car.domains.track.model.vo.TrackFilterCondition; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; @@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "[시험장 관리]", description = "시험장 관리 API") @RestController @RequestMapping("/tracks") @RequiredArgsConstructor @@ -29,7 +31,7 @@ public class TrackController { @GetMapping @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험장 조회", description = "시험장을 조건에 맞게 조회합니다.") + @Operation(summary = "[예약] 시험장 조회", description = "시험장을 조건에 맞게 조회합니다.") public List getTracksByCondition( @ParameterObject TrackFilterCondition condition) { final List tracks = trackService.findAllByCondition(condition); @@ -38,7 +40,7 @@ public List getTracksByCondition( @GetMapping("/{trackId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험장 상세 정보", description = "시험장 상세 정보를 가져옵니다.") + @Operation(summary = "[예약] 시험장 상세 정보", description = "시험장 상세 정보를 가져옵니다.") public TrackResponse getTrackById(@PathVariable Long trackId) { final Track track = trackService.findById(trackId); return TrackResponse.from(track); diff --git a/src/main/java/com/testcar/car/domains/track/model/DeleteTrackRequest.java b/src/main/java/com/testcar/car/domains/track/model/DeleteTrackRequest.java index cee3ef2..103b0ca 100644 --- a/src/main/java/com/testcar/car/domains/track/model/DeleteTrackRequest.java +++ b/src/main/java/com/testcar/car/domains/track/model/DeleteTrackRequest.java @@ -2,13 +2,17 @@ import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; import java.util.List; import lombok.Getter; @Getter public class DeleteTrackRequest { - @NotEmpty + @NotNull(message = "시험장 ID 리스트를 입력해주세요.") + @NotEmpty(message = "시험장 ID 리스트를 입력해주세요.") @Schema(description = "시험장 ID 리스트", example = "[1, 2, 3]") - private List ids; + private List<@Valid @NotNull @Positive Long> ids; } diff --git a/src/main/java/com/testcar/car/domains/track/model/RegisterTrackRequest.java b/src/main/java/com/testcar/car/domains/track/model/RegisterTrackRequest.java index 11f53b6..b00031a 100644 --- a/src/main/java/com/testcar/car/domains/track/model/RegisterTrackRequest.java +++ b/src/main/java/com/testcar/car/domains/track/model/RegisterTrackRequest.java @@ -10,21 +10,21 @@ @Getter public class RegisterTrackRequest { - @NotBlank - @Length(max = 20) + @NotBlank(message = "시험장명을 입력해주세요.") + @Length(max = 20, message = "시험장명은 20자 이하로 입력해주세요.") @Schema(description = "시험장명", example = "서산주행시험장") private String name; - @NotBlank + @NotBlank(message = "위치를 입력해주세요.") @Schema(description = "위치", example = "충청남도 서산시 부석면") private String location; - @NotBlank + @NotBlank(message = "시험장 특성을 입력해주세요.") @Schema(description = "시험장 특성", example = "평지") private String description; - @NotNull - @Positive + @NotNull(message = "시험장 길이를 입력해주세요.") + @Positive(message = "시험장 길이는 0보다 커야합니다.") @Schema(description = "길이", example = "100.32") private Double length; } diff --git a/src/main/java/com/testcar/car/domains/trackReservation/TrackReservationController.java b/src/main/java/com/testcar/car/domains/trackReservation/TrackReservationController.java index 78ad272..18cb694 100644 --- a/src/main/java/com/testcar/car/domains/trackReservation/TrackReservationController.java +++ b/src/main/java/com/testcar/car/domains/trackReservation/TrackReservationController.java @@ -38,7 +38,7 @@ public class TrackReservationController { @GetMapping("/reservations") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 내 시험장 예약 이력 조회", description = "나의 시험장 예약 이력을 조건에 맞게 조회합니다.") + @Operation(summary = "[예약 이력] 내 시험장 예약 이력 조회", description = "나의 시험장 예약 이력을 조건에 맞게 조회합니다.") public List getTrackReservationsByCondition( @AuthMember Member member, @ParameterObject TrackReservationFilterCondition condition) { final List trackReservations = @@ -48,7 +48,7 @@ public List getTrackReservationsByCondition( @GetMapping("/reservations/{trackReservationId}") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 내 시험장 예약 이력 상세 조회", description = "시험장 예약 이력 상세 정보를 조회합니다.") + @Operation(summary = "[예약 이력] 내 시험장 예약 이력 상세 조회", description = "시험장 예약 이력 상세 정보를 조회합니다.") public TrackReservationDetailResponse getTrackReservationDetailById( @AuthMember Member member, @PathVariable Long trackReservationId) { final TrackReservation trackReservation = @@ -58,7 +58,7 @@ public TrackReservationDetailResponse getTrackReservationDetailById( @GetMapping("/{trackId}/reservations") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험장 예약 내역 조회", description = "해당 시험장의 해당 일자에 예약된 내역을 조회합니다.") + @Operation(summary = "[예약 이력] 시험장 예약 내역 조회", description = "해당 시험장의 해당 일자에 예약된 내역을 조회합니다.") public TrackReservationSlotResponse getTrackReservationsByTrackId( @PathVariable Long trackId, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { final Set unavailableReservationSlots = @@ -68,7 +68,7 @@ public TrackReservationSlotResponse getTrackReservationsByTrackId( @PostMapping("/{trackId}/reserve") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험장 예약", description = "해당 시험장을 예약합니다.") + @Operation(summary = "[예약] 시험장 예약", description = "해당 시험장을 예약합니다.") public TrackReservationDetailResponse postTrackReservation( @AuthMember Member member, @PathVariable Long trackId, @@ -80,7 +80,7 @@ public TrackReservationDetailResponse postTrackReservation( @DeleteMapping("/reservations/{trackReservationId}/cancel") @RoleAllowed(role = Role.USER) - @Operation(summary = "[시험장 관리] 시험장 예약 취소", description = "해당 시험장을 예약을 취소합니다.") + @Operation(summary = "[예약 이력] 시험장 예약 취소", description = "해당 시험장을 예약을 취소합니다.") public TrackReservationDetailResponse postTrackReservation( @AuthMember Member member, @PathVariable Long trackReservationId) { final TrackReservation trackReservation = diff --git a/src/main/java/com/testcar/car/domains/trackReservation/model/TrackReservationRequest.java b/src/main/java/com/testcar/car/domains/trackReservation/model/TrackReservationRequest.java index d9aaa45..99c0ea2 100644 --- a/src/main/java/com/testcar/car/domains/trackReservation/model/TrackReservationRequest.java +++ b/src/main/java/com/testcar/car/domains/trackReservation/model/TrackReservationRequest.java @@ -4,6 +4,7 @@ import com.testcar.car.common.annotation.DateFormat; import com.testcar.car.domains.trackReservation.model.vo.ReservationSlotVo; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; @@ -12,13 +13,13 @@ @Getter public class TrackReservationRequest { - @NotNull @DateFormat + @NotNull(message = "예약일자를 입력해주세요.") @Schema(description = "예약일자", example = "2021-10-10") private LocalDate date; - @NotNull - @NotEmpty + @NotNull(message = "예약 시간 리스트를 입력해주세요.") + @NotEmpty(message = "예약 시간 리스트를 입력해주세요.") @Schema(description = "예약 시간") - private List reservationSlots; + private List<@Valid ReservationSlotVo> reservationSlots; } diff --git a/src/main/java/com/testcar/car/domains/trackReservation/model/vo/ReservationSlotVo.java b/src/main/java/com/testcar/car/domains/trackReservation/model/vo/ReservationSlotVo.java index be10c67..a4d3d25 100644 --- a/src/main/java/com/testcar/car/domains/trackReservation/model/vo/ReservationSlotVo.java +++ b/src/main/java/com/testcar/car/domains/trackReservation/model/vo/ReservationSlotVo.java @@ -4,6 +4,7 @@ import com.testcar.car.common.annotation.DateTimeFormat; import com.testcar.car.domains.trackReservation.entity.TrackReservationSlot; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; @@ -12,10 +13,12 @@ @Builder public class ReservationSlotVo { @DateTimeFormat + @NotNull(message = "예약 시간을 입력해주세요.") @Schema(description = "예약 시간", example = "2021-10-10 10:00:00") private LocalDateTime startedAt; @DateTimeFormat + @NotNull(message = "예약 시간을 입력해주세요.") @Schema(description = "예약 시간", example = "2021-10-10 11:00:00") private LocalDateTime expiredAt;