Skip to content

Commit

Permalink
refactor: savePlace API 응답에 placeId 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yooooonshine committed Jan 15, 2025
1 parent be4a270 commit 2e6b198
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import middle_point_search.backend.domains.place.dto.request.SavePlaceRequest;
import middle_point_search.backend.domains.place.dto.request.UpdatePlaceRequest;
import middle_point_search.backend.domains.place.dto.response.FindPlacesResponse;
import middle_point_search.backend.domains.place.dto.response.SavePlaceResponse;
import middle_point_search.backend.domains.place.service.PlaceService;

@Tag(name = "PLACE API", description = "회원 장소에 대한 API입니다.")
Expand Down Expand Up @@ -69,15 +70,15 @@ public class PlaceController {
)
}
)
public ResponseEntity<DataResponse<Void>> placeSave(
public ResponseEntity<DataResponse<SavePlaceResponse>> placeSave(
@PathVariable("roomId") String roomId,
@RequestBody @Valid SavePlaceRequest request
) {
Member member = memberLoader.getMember();

placeService.savePlace(roomId, member, request);
SavePlaceResponse response = placeService.savePlace(roomId, member, request);

return ResponseEntity.ok(DataResponse.ok());
return ResponseEntity.ok(DataResponse.from(response));
}

@PatchMapping("/rooms/{roomId}")
Expand Down Expand Up @@ -171,7 +172,6 @@ public ResponseEntity<DataResponse<FindPlacesResponse>> placesFind(
return ResponseEntity.ok(DataResponse.from(response));
}


@DeleteMapping("/{placeId}")
@Operation(
summary = "장소 삭제하기",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package middle_point_search.backend.domains.place.dto.response;

public record SavePlaceResponse(Long placeId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import middle_point_search.backend.domains.place.dto.request.SavePlaceRequest;
import middle_point_search.backend.domains.place.dto.request.UpdatePlaceRequest;
import middle_point_search.backend.domains.place.dto.response.FindPlacesResponse;
import middle_point_search.backend.domains.place.dto.response.SavePlaceResponse;
import middle_point_search.backend.domains.place.repository.PlaceRepository;
import middle_point_search.backend.domains.room.domain.Room;
import middle_point_search.backend.domains.room.service.RoomService;
Expand Down Expand Up @@ -58,7 +59,7 @@ public FindPlacesResponse findPlaces(Long memberId, String roomId) {

//장소 저장
@Transactional(rollbackFor = {CustomException.class})
public void savePlace(String roomId, Member member, SavePlaceRequest request) {
public SavePlaceResponse savePlace(String roomId, Member member, SavePlaceRequest request) {
// 회원이 방에 속해있는지 확인
memberRoomValidateService.validateAuthorizedMember(member.getId(), roomId);

Expand All @@ -68,7 +69,9 @@ public void savePlace(String roomId, Member member, SavePlaceRequest request) {
// 구글 placeId 조회
String googlePlaceId = googleService.findGooglePlaceId(request.getAddressLat(), request.getAddressLong());

placeRepository.save(Place.from(request, room, member, googlePlaceId));
Place place = placeRepository.save(Place.from(request, room, member, googlePlaceId));

return new SavePlaceResponse(place.getId());
}

//장소 업데이트
Expand Down

0 comments on commit 2e6b198

Please sign in to comment.