diff --git a/src/main/java/umc/IRECIPE_Server/controller/IngredientController.java b/src/main/java/umc/IRECIPE_Server/controller/IngredientController.java index 51dbb31..97f5a25 100644 --- a/src/main/java/umc/IRECIPE_Server/controller/IngredientController.java +++ b/src/main/java/umc/IRECIPE_Server/controller/IngredientController.java @@ -1,5 +1,11 @@ package umc.IRECIPE_Server.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -36,6 +42,13 @@ public class IngredientController { //재료추가 @PostMapping(value = "/", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) + @Operation(summary = "냉장고 재료 추가 API",description = "냉장고에 재료를 추가하는 API입니다.") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) public ApiResponse addIngredient(@RequestPart("request") IngredientRequest.addDTO request) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); @@ -47,6 +60,16 @@ public ApiResponse addIngredient(@RequestPart(" //재료 상세정보 조회 @GetMapping("/{ingredientId}") + @Operation(summary = "재료 정보 상세 조회 API",description = "재료 클릭시 상세 정보를 조회하는 API") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) + @Parameters({ + @Parameter(name = "ingredientId", description = "재료의 아이디, path variable 입니다!") + }) public ApiResponse findOne(@PathVariable(name = "ingredientId") Long ingredientId) { Ingredient ingredient = ingredientQueryService.findOne(ingredientId); return ApiResponse.onSuccess(IngredientConverter.toFindOneResultDTO(ingredient)); @@ -54,6 +77,16 @@ public ApiResponse findOne(@PathVariable(na //재료 삭제 @DeleteMapping("/{ingredientId}") + @Operation(summary = "재료 삭제 API",description = "재료를 삭제하는 API") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) + @Parameters({ + @Parameter(name = "ingredientId", description = "재료의 아이디, path variable 입니다!") + }) public ApiResponse deleteIngredient(@PathVariable(name = "ingredientId") Long ingredientId) { ingredientQueryService.delete(ingredientId); return ApiResponse.onSuccess(IngredientConverter.toDeleteResultDTO()); @@ -61,6 +94,16 @@ public ApiResponse deleteIngredient(@PathVar //재료 수정 @PatchMapping("/{ingredientId}") + @Operation(summary = "재료 정보 수정 조회 API",description = "재료 정보를 수정하는 API") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) + @Parameters({ + @Parameter(name = "ingredientId", description = "재료의 아이디, path variable 입니다!") + }) public ApiResponse updateIngredient( @RequestBody @Valid IngredientRequest.updateDTO request, @PathVariable(name = "ingredientId") Long ingredientId) { @@ -71,6 +114,13 @@ public ApiResponse updateIngredient( //재료 전체 조회 @GetMapping("/") + @Operation(summary = "재료 전체 조회 API",description = "냉장고 메인 화면 전체 재료 조회하는 API, query String 으로 page 번호를 주세요") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) public ApiResponse findAll(@RequestParam(name = "page") Integer page) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String userId = authentication.getName(); @@ -81,6 +131,13 @@ public ApiResponse findAll(@RequestPara //보관 방법별 재료 리스트 조회 @GetMapping("/types") + @Operation(summary = "보관 방법별 재료 리스트 조회 API",description = "보관 방법별로 재료를 조회하는 API, query String 으로 page 번호, 보관 방법을 주세요") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) public ApiResponse findRefrigeratedList(@RequestParam(name = "page") Integer page, @RequestParam(name = "type") Type type ) { @@ -93,6 +150,13 @@ public ApiResponse findRefrigeratedList //재료 이름 검색 @GetMapping("/search") + @Operation(summary = "재료 이름 검색 API",description = "이름으로 냉장고 내 재료를 검색하는 API, query String 으로 page 번호, 검색어를 주세요") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) public ApiResponse searchIngredient(@RequestParam(name = "name") String name, @RequestParam(name = "page") Integer page) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); @@ -103,6 +167,13 @@ public ApiResponse searchIngredient(@Re } @GetMapping("/expire") + @Operation(summary = "유통기한 만료일 순 재료 조회 API",description = "유통기한이 얼마 안남은 순으로 재료 리스트 조회하는 API, query String 으로 page 번호를 주세요") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "acess 토큰 만료",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "acess 토큰 모양이 이상함",content = @Content(schema = @Schema(implementation = ApiResponse.class))), + }) public ApiResponse findNearingExpirationIngredient(@RequestParam(name = "page") Integer page) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String userId = authentication.getName(); diff --git a/src/main/java/umc/IRECIPE_Server/converter/IngredientConverter.java b/src/main/java/umc/IRECIPE_Server/converter/IngredientConverter.java index f4a2ec8..ad68d09 100644 --- a/src/main/java/umc/IRECIPE_Server/converter/IngredientConverter.java +++ b/src/main/java/umc/IRECIPE_Server/converter/IngredientConverter.java @@ -38,6 +38,7 @@ public static Ingredient toIngredient(Member member, IngredientRequest.addDTO re public static IngredientResponse.findOneResultDTO toFindOneResultDTO(Ingredient ingredient) { return IngredientResponse.findOneResultDTO.builder() + .ingredientId(ingredient.getIngredientId()) .name(ingredient.getName()) .memo(ingredient.getMemo()) .category(ingredient.getCategory()) @@ -66,6 +67,7 @@ public static IngredientResponse.findAllResultListDTO toFindAllResultListDTO(Pag private static IngredientResponse.findIngredientResultDTO toFindIngredientResultDTO(Ingredient ingredient) { return IngredientResponse.findIngredientResultDTO.builder() + .ingredientId(ingredient.getIngredientId()) .name(ingredient.getName()) .memo(ingredient.getMemo()) .category(ingredient.getCategory()) diff --git a/src/main/java/umc/IRECIPE_Server/dto/IngredientRequest.java b/src/main/java/umc/IRECIPE_Server/dto/IngredientRequest.java index b3512ef..ed48c5f 100644 --- a/src/main/java/umc/IRECIPE_Server/dto/IngredientRequest.java +++ b/src/main/java/umc/IRECIPE_Server/dto/IngredientRequest.java @@ -1,5 +1,6 @@ package umc.IRECIPE_Server.dto; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -13,27 +14,39 @@ public class IngredientRequest { + @Schema(description = "냉장고 재료 추가 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class addDTO{ + @Schema(description = "재료 이름", defaultValue = "소고기") String name; + @Schema(description = "재료 카테고리", defaultValue = "MEAT") IngredientCategory category; + @Schema(description = "재료 메모", defaultValue = "빨리 먹어야 함") String memo; + @Schema(description = "재료 보관방법", defaultValue = "FROZEN") Type type; + @Schema(description = "재료 유통기한", defaultValue = "2025-02-09") LocalDate expiryDate; } + @Schema(description = "냉장고 재료 수정 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class updateDTO{ + @Schema(description = "재료 이름", defaultValue = "소고기") String name; + @Schema(description = "재료 카테고리", defaultValue = "MEAT") IngredientCategory category; + @Schema(description = "재료 메모", defaultValue = "빨리 먹어야 함") String memo; + @Schema(description = "재료 보관방법", defaultValue = "FROZEN") Type type; + @Schema(description = "재료 유통기한", defaultValue = "2025-02-09") LocalDate expiryDate; } diff --git a/src/main/java/umc/IRECIPE_Server/dto/IngredientResponse.java b/src/main/java/umc/IRECIPE_Server/dto/IngredientResponse.java index 5af9701..136a30e 100644 --- a/src/main/java/umc/IRECIPE_Server/dto/IngredientResponse.java +++ b/src/main/java/umc/IRECIPE_Server/dto/IngredientResponse.java @@ -1,11 +1,13 @@ package umc.IRECIPE_Server.dto; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import umc.IRECIPE_Server.common.enums.IngredientCategory; import umc.IRECIPE_Server.common.enums.Type; +import umc.IRECIPE_Server.dto.response.PostResponseDTO; import java.time.LocalDate; import java.time.LocalDateTime; @@ -14,67 +16,100 @@ public class IngredientResponse { + @Schema(description = "냉장고 재료 추가 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class addResultDTO{ + @Schema(description = "재료 아이디", defaultValue = "1") Long ingredientId; + @Schema(description = "재료 생성일시") LocalDateTime createdAt; } + @Schema(description = "재료 상세 정보 조회 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class findOneResultDTO{ + @Schema(description = "재료 아이디", defaultValue = "1") + Long ingredientId; + @Schema(description = "재료 이름", defaultValue = "소고기") String name; + @Schema(description = "재료 카테고리", defaultValue = "MEAT") IngredientCategory category; + @Schema(description = "재료 메모", defaultValue = "빨리 먹어야 함") String memo; + @Schema(description = "재료 보관방법", defaultValue = "FROZEN") Type type; + @Schema(description = "재료 유통기한", defaultValue = "2025-02-09") LocalDate expiryDate; + @Schema(description = "유통기한까지 남은 일 수", defaultValue = "10") Integer remainingDays; } + @Schema(description = "재료 정보 수정 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class updateResultDTO{ + @Schema(description = "재료 아이디", defaultValue = "1") Long ingredientId; + @Schema(description = "수정 일시") LocalDateTime updatedAt; } + @Schema(description = "냉장고 재료 삭제 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class deleteResultDTO{ + @Schema(description = "완료 메세지", defaultValue = "삭제 완료") String message; } + @Schema(description = "냉장고 재료 조회 DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class findIngredientResultDTO{ + @Schema(description = "재료 아이디", defaultValue = "1") + Long ingredientId; + @Schema(description = "재료 이름", defaultValue = "소고기") String name; + @Schema(description = "재료 카테고리", defaultValue = "MEAT") IngredientCategory category; + @Schema(description = "재료 메모", defaultValue = "빨리 먹어야 함") String memo; + @Schema(description = "재료 보관방법", defaultValue = "FROZEN") Type type; + @Schema(description = "재료 유통기한", defaultValue = "2025-02-09") LocalDate expiryDate; + @Schema(description = "유통기한까지 남은 일 수", defaultValue = "10") Integer remainingDays; } + @Schema(description = "조회 리스트 정보DTO") @Builder @Getter @NoArgsConstructor @AllArgsConstructor public static class findAllResultListDTO{ - List ingredientList; + @Schema(description = "게시글 리스트") + List postList; + @Schema(description = "리스트 사이즈", defaultValue = "1") Integer listSize; + @Schema(description = "전체 페이지 갯수", defaultValue = "1") Integer totalPage; + @Schema(description = "전체 데이터 갯수", defaultValue = "10") Long totalElements; + @Schema(description = "첫 페이지면 true", defaultValue = "true") Boolean isFirst; + @Schema(description = " 마지막 페이지면 true", defaultValue = "true") Boolean isLast; } diff --git a/src/main/java/umc/IRECIPE_Server/dto/response/PostResponseDTO.java b/src/main/java/umc/IRECIPE_Server/dto/response/PostResponseDTO.java index d0c75d3..8226b05 100644 --- a/src/main/java/umc/IRECIPE_Server/dto/response/PostResponseDTO.java +++ b/src/main/java/umc/IRECIPE_Server/dto/response/PostResponseDTO.java @@ -206,6 +206,7 @@ public static class getRankedPostDTO { @Schema(description = "게시글 한달 평균 별점", defaultValue = "4.3") private Float scoresInOneMonth; + } @Schema(description = "이달의 랭킹 게시글 리스트 DTO") @@ -214,11 +215,17 @@ public static class getRankedPostDTO { @NoArgsConstructor @AllArgsConstructor public static class findAllResultListDTO{ + @Schema(description = "게시글 리스트") List postList; + @Schema(description = "리스트 사이즈", defaultValue = "1") Integer listSize; + @Schema(description = "전체 페이지 갯수", defaultValue = "1") Integer totalPage; + @Schema(description = "전체 데이터 갯수", defaultValue = "10") Long totalElements; + @Schema(description = "첫 페이지면 true", defaultValue = "true") Boolean isFirst; + @Schema(description = " 마지막 페이지면 true", defaultValue = "true") Boolean isLast; } }