diff --git a/src/main/java/com/comma/soomteum/domain/place/entity/Place.java b/src/main/java/com/comma/soomteum/domain/place/entity/Place.java index dd6d222..06deebf 100644 --- a/src/main/java/com/comma/soomteum/domain/place/entity/Place.java +++ b/src/main/java/com/comma/soomteum/domain/place/entity/Place.java @@ -23,6 +23,9 @@ public class Place extends BaseEntity { @Column(length = 255, nullable = false) private String contentId; + @Column(length = 255) + private String name; + @Column(length = 100, nullable = false) @Builder.Default private BigDecimal cnctrLevel = BigDecimal.ZERO; diff --git a/src/main/java/com/comma/soomteum/domain/place/service/PlaceService.java b/src/main/java/com/comma/soomteum/domain/place/service/PlaceService.java index 701f6a6..3b0f4cd 100644 --- a/src/main/java/com/comma/soomteum/domain/place/service/PlaceService.java +++ b/src/main/java/com/comma/soomteum/domain/place/service/PlaceService.java @@ -88,12 +88,12 @@ public PlaceDetailWithParkingDto getPlaceDetailWithNearestParking(String content } @Transactional(propagation = Propagation.REQUIRES_NEW) - public Place findOrCreatePlace(String contentId, String regionName, String themeName, BigDecimal cnctrLevel) { + public Place findOrCreatePlace(String contentId, String regionName, String themeName, String placeName, BigDecimal cnctrLevel) { return placeRepository.findByContentId(contentId) - .orElseGet(() -> createPlace(contentId, regionName, themeName, cnctrLevel)); + .orElseGet(() -> createPlace(contentId, regionName, themeName, placeName, cnctrLevel)); } - private Place createPlace(String contentId, String regionName, String themeName, BigDecimal cnctrLevel) { + private Place createPlace(String contentId, String regionName, String themeName, String placeName, BigDecimal cnctrLevel) { // Region 찾기 - 없으면 기본값 사용 var region = regionRepository.findByName(regionName) .orElse(regionRepository.findByName("강릉시") @@ -108,6 +108,7 @@ private Place createPlace(String contentId, String regionName, String themeName, var place = Place.builder() .contentId(contentId) + .name(placeName) .cnctrLevel(cnctrLevel) .likeCount(0L) .region(region) diff --git a/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceLikeController.java b/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceLikeController.java index cde2079..0762ac8 100644 --- a/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceLikeController.java +++ b/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceLikeController.java @@ -42,11 +42,12 @@ public ResponseEntity> likePlace( @Valid @RequestBody PlaceActionRequestDto request) { UserPlaceResponseDto responseDto = userPlaceService.setActionByContentId( user.getUserId(), - request.getContentId(), - request.getRegionName(), - request.getThemeName(), + request.getContentId(), + request.getRegionName(), + request.getThemeName(), + request.getPlaceName(), request.getCnctrLevel(), - UserActionType.LIKE, + UserActionType.LIKE, true); return ResponseEntity.ok(ApiResponse.ok(responseDto)); } diff --git a/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceSaveController.java b/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceSaveController.java index cf0d880..bc480d9 100644 --- a/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceSaveController.java +++ b/src/main/java/com/comma/soomteum/domain/userPlace/controller/PlaceSaveController.java @@ -47,11 +47,12 @@ public ResponseEntity> save( var dto = userPlaceService.setActionByContentId( user.getUserId(), - request.getContentId(), - request.getRegionName(), - request.getThemeName(), + request.getContentId(), + request.getRegionName(), + request.getThemeName(), + request.getPlaceName(), request.getCnctrLevel(), - UserActionType.SAVE, + UserActionType.SAVE, true); return ResponseEntity.ok(ApiResponse.ok(dto)); } diff --git a/src/main/java/com/comma/soomteum/domain/userPlace/dto/PlaceActionRequestDto.java b/src/main/java/com/comma/soomteum/domain/userPlace/dto/PlaceActionRequestDto.java index 1d2e18a..ff050c0 100644 --- a/src/main/java/com/comma/soomteum/domain/userPlace/dto/PlaceActionRequestDto.java +++ b/src/main/java/com/comma/soomteum/domain/userPlace/dto/PlaceActionRequestDto.java @@ -27,6 +27,9 @@ public class PlaceActionRequestDto { @Schema(description = "테마명", example = "자연관광지") private String themeName; + @Schema(description = "여행지 이름", example = "경복궁") + private String placeName; + @NotNull @Schema(description = "혼잡도 레벨", example = "3.5") private BigDecimal cnctrLevel; diff --git a/src/main/java/com/comma/soomteum/domain/userPlace/dto/UserPlaceItemDto.java b/src/main/java/com/comma/soomteum/domain/userPlace/dto/UserPlaceItemDto.java index 45559c9..f538e41 100644 --- a/src/main/java/com/comma/soomteum/domain/userPlace/dto/UserPlaceItemDto.java +++ b/src/main/java/com/comma/soomteum/domain/userPlace/dto/UserPlaceItemDto.java @@ -22,6 +22,9 @@ public class UserPlaceItemDto { @Schema(description = "Place 콘텐츠 ID", example = "content123") private String contentId; + @Schema(description = "여행지 이름", example = "경복궁") + private String placeName; + @Schema(description = "Place 좋아요 수", example = "42") private Long likeCount; diff --git a/src/main/java/com/comma/soomteum/domain/userPlace/service/UserPlaceService.java b/src/main/java/com/comma/soomteum/domain/userPlace/service/UserPlaceService.java index aef2fcc..7b8aae4 100644 --- a/src/main/java/com/comma/soomteum/domain/userPlace/service/UserPlaceService.java +++ b/src/main/java/com/comma/soomteum/domain/userPlace/service/UserPlaceService.java @@ -173,6 +173,7 @@ public UserPlacePageResponseDto getMyPlaces(Long userId, UserActionType type, in return UserPlaceItemDto.builder() .cnctrLevel(place.getCnctrLevel()) .contentId(place.getContentId()) + .placeName(place.getName()) .likeCount(place.getLikeCount()) .themeName(place.getTheme() != null ? place.getTheme().getName() : null) .savedAt(up.getCreatedAt()) @@ -203,7 +204,7 @@ public UserPlacePageResponseDto getMyPlaces(Long userId, UserActionType type, in } @Transactional - public UserPlaceResponseDto setActionByContentId(Long userId, String contentId, String regionName, String themeName, BigDecimal cnctrLevel, UserActionType type, boolean enable) { + public UserPlaceResponseDto setActionByContentId(Long userId, String contentId, String regionName, String themeName, String placeName, BigDecimal cnctrLevel, UserActionType type, boolean enable) { if (userId == null) { throw new CustomException(ErrorCode.USER_NOT_FOUND); } @@ -211,7 +212,7 @@ public UserPlaceResponseDto setActionByContentId(Long userId, String contentId, var user = userRepository.findById(userId) .orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND)); - var place = placeService.findOrCreatePlace(contentId, regionName, themeName, cnctrLevel); + var place = placeService.findOrCreatePlace(contentId, regionName, themeName, placeName, cnctrLevel); boolean changed = false;