Skip to content
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 @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("강릉시")
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ public ResponseEntity<ApiResponse<UserPlaceResponseDto>> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public ResponseEntity<ApiResponse<UserPlaceResponseDto>> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -203,15 +204,15 @@ 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);
}

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;

Expand Down