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..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 @@ -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 @@ -112,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 a9e86b0..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().getImgUrl(), + b.getPlace().getPlaceIdx(), b.getPlace().getName(), - b.getPlace().getCreatedAt()); + b.getPlace().getImgUrl()); belongList.add(belongUser); } return belongList; @@ -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()); } + } 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()); + } }