From 814a67a49e4357b6425fbb0d89b2643bdca5cb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=A9=EC=A7=80=EB=AF=BC?= Date: Sun, 26 May 2024 08:42:29 +0900 Subject: [PATCH 1/3] [Feat] create new API SearchInfo with waterday --- .../info/controller/InfoController.java | 7 +++++++ .../domain2/info/controller/InfoSwagger.java | 4 ++++ .../commonplant/domain2/info/dto/InfoDto.java | 19 +++++++++++++++++++ .../domain2/info/service/InfoService.java | 13 +++++++++++++ 4 files changed, 43 insertions(+) diff --git a/src/main/java/com/umc/commonplant/domain2/info/controller/InfoController.java b/src/main/java/com/umc/commonplant/domain2/info/controller/InfoController.java index 8c2ed20..3152df8 100644 --- a/src/main/java/com/umc/commonplant/domain2/info/controller/InfoController.java +++ b/src/main/java/com/umc/commonplant/domain2/info/controller/InfoController.java @@ -57,4 +57,11 @@ public ResponseEntity searchInfo(@RequestParam("name") String name return ResponseEntity.ok(new JsonResponse(true, 200, "searchInfo", infoList)); } + @GetMapping("/searchInfoPlus") + public ResponseEntity searchPlusInfo(@RequestParam("name") String name) { + + List infoList = infoService.searchPlusInfo(name); + + return ResponseEntity.ok(new JsonResponse(true, 200, "searchInfo", infoList)); + } } diff --git a/src/main/java/com/umc/commonplant/domain2/info/controller/InfoSwagger.java b/src/main/java/com/umc/commonplant/domain2/info/controller/InfoSwagger.java index 275e313..4fab783 100644 --- a/src/main/java/com/umc/commonplant/domain2/info/controller/InfoSwagger.java +++ b/src/main/java/com/umc/commonplant/domain2/info/controller/InfoSwagger.java @@ -48,4 +48,8 @@ public ResponseEntity createInfo( @Operation(summary = "식물도감 검색", description = "식물 이름(또는 학술명)의 일부로 식물을 찾습니다.") @Parameter(name = "name", description = "식물 이름(또는 학술명)의 일부", example = "mons", required = true) public ResponseEntity searchInfo(@RequestParam("name") String name); + + @Operation(summary = "식물도감 검색 w 물주기 정보", description = "식물 이름(또는 학술명)의 일부로 식물을 찾습니다. SearchInfo에 식물 물주기 정보가 포함된 형태입니다.") + @Parameter(name = "name", description = "식물 이름(또는 학술명)의 일부", example = "mons", required = true) + public ResponseEntity searchPlusInfo(@RequestParam("name") String name); } diff --git a/src/main/java/com/umc/commonplant/domain2/info/dto/InfoDto.java b/src/main/java/com/umc/commonplant/domain2/info/dto/InfoDto.java index f7e380f..3f50102 100644 --- a/src/main/java/com/umc/commonplant/domain2/info/dto/InfoDto.java +++ b/src/main/java/com/umc/commonplant/domain2/info/dto/InfoDto.java @@ -138,4 +138,23 @@ public SearchInfoResponse(String name, String scientific_name, String imgUrl) { } } + + @NoArgsConstructor + @Data + public static class SearchInfoWithWaterResponse { + private String name; + private String scientific_name; + private String imgUrl; + + private Long water_day; + + @Builder + public SearchInfoWithWaterResponse(String name, String scientific_name, String imgUrl, Long water_day) { + this.name = name; + this.scientific_name = scientific_name; + this.imgUrl = imgUrl; + this.water_day = water_day; + } + + } } diff --git a/src/main/java/com/umc/commonplant/domain2/info/service/InfoService.java b/src/main/java/com/umc/commonplant/domain2/info/service/InfoService.java index 9c7002b..7be0f99 100644 --- a/src/main/java/com/umc/commonplant/domain2/info/service/InfoService.java +++ b/src/main/java/com/umc/commonplant/domain2/info/service/InfoService.java @@ -139,4 +139,17 @@ public List getOneInfo(String name) { List infoList = infoRepository.findByName(name); return infoList; } + + public List searchPlusInfo(String name) { + List infoList = infoRepository.findByNameOrScientificNameContainingAndVerified(name); + + return infoList.stream() + .map(info -> InfoDto.SearchInfoWithWaterResponse.builder() + .name(info.getName()) + .scientific_name(info.getScientificName()) + .imgUrl(info.getImgUrl()) + .water_day(info.getWater_day()) + .build()) + .collect(Collectors.toList()); + } } From 1e1ec544391bb0e5959b29ae78c39cfcd84f06a7 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 27 May 2024 21:05:53 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Chore]=20getPlaceBelongUser=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../place/controller/PlaceContoller.java | 31 +++++++++++++++++++ .../domain/place/dto/PlaceDto.java | 11 +++++++ .../domain/place/service/PlaceService.java | 12 ++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/umc/commonplant/domain/place/controller/PlaceContoller.java b/src/main/java/com/umc/commonplant/domain/place/controller/PlaceContoller.java index ea678ef..5c6b6f8 100644 --- a/src/main/java/com/umc/commonplant/domain/place/controller/PlaceContoller.java +++ b/src/main/java/com/umc/commonplant/domain/place/controller/PlaceContoller.java @@ -129,4 +129,35 @@ public ResponseEntity getPlaceFriends(@PathVariable String code){ return ResponseEntity.ok(new JsonResponse(true, 200, "getPlaceFriends", userList)); } + + // 장소 수정 +// @PutMapping("/update/{code}") +// public ResponseEntity updatePlace(@PathVariable String code, +// @RequestPart(value = "place") PlaceDto.updatePlaceReq req, +// @RequestPart(value = "image") MultipartFile image){ +// String uuid = jwtService.resolveToken(); +// User user = userService.getUser(uuid); +// +// String placeCode = placeService.update(user, code, req, image); +// return ResponseEntity.ok(new JsonResponse(true, 200, "createPlace", placeCode)); +// +// } + + // 장소 삭제 + // - 장소 탈퇴시 + // - 팀원이 탈퇴시 + // - 사용자가 등록한 메모, 캘린더 일정 + // → 사용자 null 로 설정 후 장소에서 팀원 삭제 + // → 사용자 id 를 어떻게 보여줄지 벤치마킹 + // - 팀짱이 탈퇴시 + // - 팀원이 등록된 순서대로 팀짱 넘겨주기!! + // - 장소 수정에서 팀장을 넘겨줄 수 있게!! (일단 디자인 반영!!) + // → 모든 사용자가 장소 탈퇴시 장소는 삭제 +// @DeleteMapping("/delete/{code}") +// public ResponseEntity deletePlace(@PathVariable String code){ +// +// } + + + } diff --git a/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java b/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java index 5fcbfc0..5c86e82 100644 --- a/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java +++ b/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java @@ -24,6 +24,17 @@ public static class createPlaceReq{ private String address; } + @AllArgsConstructor + @NoArgsConstructor + @Data + @Schema(description = "장소 생성 관련 Request") + public static class updatePlaceReq{ + @Schema(description = "장소 이름" , example = "우리집 거실") + private String name; + @Schema(description = "장소 주소" , example = "서울특별시 노원구 광운로 20") + private String address; + } + @AllArgsConstructor @NoArgsConstructor @Data diff --git a/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java b/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java index a9e86b0..64beb1d 100644 --- a/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java +++ b/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java @@ -140,8 +140,8 @@ public List getPlaceBelongUser(User user) { List belongList = new ArrayList<>(); for(Belong b : belongs){ PlaceDto.getPlaceBelongUser belongUser = new PlaceDto.getPlaceBelongUser( - b.getPlace().getImgUrl(), b.getPlace().getName(), + b.getPlace().getImgUrl(), b.getPlace().getCreatedAt()); belongList.add(belongUser); } @@ -162,6 +162,15 @@ public List getPlaceFriends(String code) { return friends; } +// public String update(User user, String code, PlaceDto.updatePlaceReq req, MultipartFile image) { +// userOnPlace(user, code); +// Place oldPlace = placeRepository.getPlaceByCode(code).orElseThrow(() -> new BadRequestException(NOT_FOUND_PLACE_CODE)); +// +// +// } + + + // ----- API 외 메서드 ----- // 장소에 속한 유저인지 확인하는 메서드 @@ -181,4 +190,5 @@ public List getPlaceListByUser(User user){ return belongRepository.getPlaceListByUser(user.getUuid()); } + } From 9288fb6b2019828f2e3df588fc03146033fddbfe Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 27 May 2024 23:49:18 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Chore]=20getPlaceBelongUser=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/umc/commonplant/domain/place/dto/PlaceDto.java | 2 +- .../umc/commonplant/domain/place/service/PlaceService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java b/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java index 5c86e82..2ab436e 100644 --- a/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java +++ b/src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java @@ -123,9 +123,9 @@ public static class getMainPage{ @AllArgsConstructor @Data public static class getPlaceBelongUser { + private Long placeId; private String name; private String imgUrl; - private LocalDateTime createdAt; } diff --git a/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java b/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java index 64beb1d..acdf520 100644 --- a/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java +++ b/src/main/java/com/umc/commonplant/domain/place/service/PlaceService.java @@ -140,9 +140,9 @@ public List getPlaceBelongUser(User user) { List belongList = new ArrayList<>(); for(Belong b : belongs){ PlaceDto.getPlaceBelongUser belongUser = new PlaceDto.getPlaceBelongUser( + b.getPlace().getPlaceIdx(), b.getPlace().getName(), - b.getPlace().getImgUrl(), - b.getPlace().getCreatedAt()); + b.getPlace().getImgUrl()); belongList.add(belongUser); } return belongList;