Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] place, information 로직 수정 #120

Merged
merged 6 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,35 @@ public ResponseEntity<JsonResponse> getPlaceFriends(@PathVariable String code){

return ResponseEntity.ok(new JsonResponse(true, 200, "getPlaceFriends", userList));
}

// 장소 수정
// @PutMapping("/update/{code}")
// public ResponseEntity<JsonResponse> 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<JsonResponse> deletePlace(@PathVariable String code){
//
// }



}
13 changes: 12 additions & 1 deletion src/main/java/com/umc/commonplant/domain/place/dto/PlaceDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public List<PlaceDto.getPlaceBelongUser> getPlaceBelongUser(User user) {
List<PlaceDto.getPlaceBelongUser> 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;
Expand All @@ -162,6 +162,15 @@ public List<PlaceDto.getPlaceFriends> 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 외 메서드 -----

// 장소에 속한 유저인지 확인하는 메서드
Expand All @@ -181,4 +190,5 @@ public List<Place> getPlaceListByUser(User user){
return belongRepository.getPlaceListByUser(user.getUuid());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ public ResponseEntity<JsonResponse> searchInfo(@RequestParam("name") String name
return ResponseEntity.ok(new JsonResponse(true, 200, "searchInfo", infoList));
}

@GetMapping("/searchInfoPlus")
public ResponseEntity<JsonResponse> searchPlusInfo(@RequestParam("name") String name) {

List<InfoDto.SearchInfoWithWaterResponse> infoList = infoService.searchPlusInfo(name);

return ResponseEntity.ok(new JsonResponse(true, 200, "searchInfo", infoList));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ public ResponseEntity<JsonResponse> createInfo(
@Operation(summary = "식물도감 검색", description = "식물 이름(또는 학술명)의 일부로 식물을 찾습니다.")
@Parameter(name = "name", description = "식물 이름(또는 학술명)의 일부", example = "mons", required = true)
public ResponseEntity<JsonResponse> searchInfo(@RequestParam("name") String name);

@Operation(summary = "식물도감 검색 w 물주기 정보", description = "식물 이름(또는 학술명)의 일부로 식물을 찾습니다. SearchInfo에 식물 물주기 정보가 포함된 형태입니다.")
@Parameter(name = "name", description = "식물 이름(또는 학술명)의 일부", example = "mons", required = true)
public ResponseEntity<JsonResponse> searchPlusInfo(@RequestParam("name") String name);
}
19 changes: 19 additions & 0 deletions src/main/java/com/umc/commonplant/domain2/info/dto/InfoDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,17 @@ public List<Info> getOneInfo(String name) {
List<Info> infoList = infoRepository.findByName(name);
return infoList;
}

public List<InfoDto.SearchInfoWithWaterResponse> searchPlusInfo(String name) {
List<Info> 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());
}
}
Loading