Skip to content

Commit 86dd1b1

Browse files
committed
필드 이름 에러 해결
2 parents 3300814 + f12d46b commit 86dd1b1

11 files changed

Lines changed: 54 additions & 170 deletions

src/main/java/com/matzip/place/api/controller/CategoryController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.matzip.place.api.controller;
22

33
import com.matzip.common.response.ApiResponse;
4-
import com.matzip.place.api.response.CategoryPlaceResponseDto;
4+
import com.matzip.place.api.response.PlaceCommonResponseDto;
55
import com.matzip.place.application.service.PlaceReadService;
66
import com.matzip.place.domain.Campus;
77
import lombok.RequiredArgsConstructor;
@@ -23,11 +23,11 @@ public class CategoryController {
2323
private final CategoryService categoryService;
2424

2525
@GetMapping("/{categoryId}/places")
26-
public ApiResponse<List<CategoryPlaceResponseDto>> getPlacesByCategory(
26+
public ApiResponse<List<PlaceCommonResponseDto>> getPlacesByCategory(
2727
@PathVariable Long categoryId,
2828
@RequestParam Campus campus) {
2929

30-
List<CategoryPlaceResponseDto> places = placeReadService.getPlacesByCategory(categoryId, campus);
30+
List<PlaceCommonResponseDto> places = placeReadService.getPlacesByCategory(categoryId, campus);
3131
return ApiResponse.success(places);
3232
}
3333

src/main/java/com/matzip/place/api/controller/PlaceLikeController.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import com.matzip.common.response.ApiResponse;
44
import com.matzip.common.security.UserPrincipal;
5-
import com.matzip.place.api.response.LikedPlaceResponseDto;
65
import com.matzip.place.api.response.PlaceLikeResponseDto;
6+
import com.matzip.place.api.response.PlaceCommonResponseDto;
77
import com.matzip.place.application.service.PlaceLikeService;
88
import lombok.RequiredArgsConstructor;
99
import org.springframework.web.bind.annotation.RestController;
10-
import org.springframework.http.ResponseEntity;
1110
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1211
import org.springframework.web.bind.annotation.*;
1312

@@ -22,28 +21,28 @@ public class PlaceLikeController {
2221

2322

2423
@PostMapping("/{placeId}/like")
25-
public ResponseEntity<ApiResponse<PlaceLikeResponseDto>> addLike(
24+
public ApiResponse<PlaceLikeResponseDto> addLike(
2625
@PathVariable Long placeId,
2726
@AuthenticationPrincipal UserPrincipal userPrincipal) {
2827

2928
PlaceLikeResponseDto response = placeLikeService.addLike(userPrincipal.getUserId(), placeId);
30-
return ResponseEntity.ok(ApiResponse.success(response));
29+
return ApiResponse.success(response);
3130
}
3231

3332
@DeleteMapping("/{placeId}/like")
34-
public ResponseEntity<ApiResponse<PlaceLikeResponseDto>> removeLike(
33+
public ApiResponse<PlaceLikeResponseDto> removeLike(
3534
@PathVariable Long placeId,
3635
@AuthenticationPrincipal UserPrincipal userPrincipal) {
3736

3837
PlaceLikeResponseDto response = placeLikeService.removeLike(userPrincipal.getUserId(), placeId);
39-
return ResponseEntity.ok(ApiResponse.success(response));
38+
return ApiResponse.success(response);
4039
}
4140

4241
@GetMapping("/like")
43-
public ResponseEntity<ApiResponse<List<LikedPlaceResponseDto>>> getMyLikedPlaces(
42+
public ApiResponse<List<PlaceCommonResponseDto>> getMyLikedPlaces(
4443
@AuthenticationPrincipal UserPrincipal userPrincipal) {
4544

46-
List<LikedPlaceResponseDto> likedPlaces = placeLikeService.getLikedPlaces(userPrincipal.getUserId());
47-
return ResponseEntity.ok(ApiResponse.success(likedPlaces));
45+
List<PlaceCommonResponseDto> likedPlaces = placeLikeService.getLikedPlaces(userPrincipal.getUserId());
46+
return ApiResponse.success(likedPlaces);
4847
}
4948
}

src/main/java/com/matzip/place/api/controller/PlaceReadController.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import com.matzip.common.response.ApiResponse;
44
import com.matzip.common.security.UserPrincipal;
55
import com.matzip.place.api.request.MapSearchRequestDto;
6+
import com.matzip.place.api.response.PlaceCommonResponseDto;
67
import jakarta.validation.Valid;
7-
import com.matzip.place.api.response.CategoryPlaceResponseDto;
88
import com.matzip.place.api.response.MapSearchResponseDto;
99
import com.matzip.place.api.response.PlaceDetailResponseDto;
10-
import com.matzip.place.api.response.PlaceRankingResponseDto;
1110
import com.matzip.place.application.service.PlaceReadService;
1211
import com.matzip.place.domain.Campus;
1312
import lombok.RequiredArgsConstructor;
14-
import org.springframework.http.ResponseEntity;
1513
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1614
import org.springframework.web.bind.annotation.*;
1715

@@ -25,30 +23,30 @@ public class PlaceReadController {
2523
private final PlaceReadService placeReadService;
2624

2725
@GetMapping("/{placeId}")
28-
public ResponseEntity<ApiResponse<PlaceDetailResponseDto>> getPlaceDetail(
26+
public ApiResponse<PlaceDetailResponseDto> getPlaceDetail(
2927
@PathVariable Long placeId,
3028
@AuthenticationPrincipal UserPrincipal userPrincipal) {
3129

3230
Long userId = userPrincipal != null ? userPrincipal.getUserId() : null;
3331
PlaceDetailResponseDto placeDetail = placeReadService.getPlaceDetail(placeId, userId);
3432

35-
return ResponseEntity.ok(ApiResponse.success(placeDetail));
33+
return ApiResponse.success(placeDetail);
3634
}
3735

3836
@GetMapping
39-
public ResponseEntity<ApiResponse<List<MapSearchResponseDto>>> getPlacesInMap(
37+
public ApiResponse<List<MapSearchResponseDto>> getPlacesInMap(
4038
@Valid @ModelAttribute MapSearchRequestDto requestDto) {
4139

4240
List<MapSearchResponseDto> places = placeReadService.findPlacesInMapBounds(requestDto);
43-
return ResponseEntity.ok(ApiResponse.success(places));
41+
return ApiResponse.success(places);
4442
}
4543

4644
@GetMapping("/ranking")
47-
public ResponseEntity<ApiResponse<List<PlaceRankingResponseDto>>> getRanking(
45+
public ApiResponse<List<PlaceCommonResponseDto>> getRanking(
4846
@RequestParam String sort,
4947
@RequestParam Campus campus) {
5048

51-
List<PlaceRankingResponseDto> ranking = placeReadService.getRanking(campus, sort);
52-
return ResponseEntity.ok(ApiResponse.success(ranking));
49+
List<PlaceCommonResponseDto> ranking = placeReadService.getRanking(campus, sort);
50+
return ApiResponse.success(ranking);
5351
}
5452
}

src/main/java/com/matzip/place/api/response/CategoryPlaceResponseDto.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/com/matzip/place/api/response/LikedPlaceResponseDto.java renamed to src/main/java/com/matzip/place/api/response/PlaceCommonResponseDto.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313

1414
@Getter
1515
@Builder
16-
public class LikedPlaceResponseDto {
16+
public class PlaceCommonResponseDto {
1717
private final Long placeId;
1818
private final String placeName;
1919
private final String address;
2020
private final List<CategoryDto> categories;
2121
private final List<TagDto> tags;
2222

23-
public static LikedPlaceResponseDto from(Place place, List<Category> categoryEntities, List<Tag> tagEntities) {
24-
23+
public static PlaceCommonResponseDto from(Place place, List<Category> categoryEntities, List<Tag> tagEntities) {
2524
List<CategoryDto> categoryDtos = categoryEntities.stream()
2625
.map(CategoryDto::from)
2726
.collect(Collectors.toList());
@@ -30,7 +29,7 @@ public static LikedPlaceResponseDto from(Place place, List<Category> categoryEnt
3029
.map(TagDto::from)
3130
.collect(Collectors.toList());
3231

33-
return LikedPlaceResponseDto.builder()
32+
return PlaceCommonResponseDto.builder()
3433
.placeId(place.getId())
3534
.placeName(place.getName())
3635
.address(place.getAddress())
@@ -39,4 +38,15 @@ public static LikedPlaceResponseDto from(Place place, List<Category> categoryEnt
3938
.build();
4039
}
4140

41+
public static PlaceCommonResponseDto of(Long placeId, String placeName, String address,
42+
List<CategoryDto> categories, List<TagDto> tags) {
43+
return PlaceCommonResponseDto.builder()
44+
.placeId(placeId)
45+
.placeName(placeName)
46+
.address(address)
47+
.categories(categories)
48+
.tags(tags)
49+
.build();
50+
}
4251
}
52+

src/main/java/com/matzip/place/api/response/PlaceDetailResponseDto.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.matzip.place.api.response;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.matzip.place.api.RecommendedMenuDto;
45
import com.matzip.place.domain.entity.*;
56
import com.matzip.place.dto.CategoryDto;
@@ -21,12 +22,14 @@ public class PlaceDetailResponseDto {
2122
private String address;
2223
private LocationDto location;
2324
private List<PhotoDto> photos;
24-
private boolean isLiked;
2525
private String description;
2626
private List<RecommendedMenuDto> menus;
2727
private List<TagDto> tags;
2828
private List<CategoryDto> categories;
2929

30+
@Getter(onMethod_ = @JsonProperty("isLiked"))
31+
private boolean isLiked;
32+
3033
// 서비스 계층에서 모든 정보를 조합하여 DTO로 변환하는 정적 팩토리 메서드
3134
public static PlaceDetailResponseDto from(
3235
Place place,

src/main/java/com/matzip/place/api/response/PlaceRankingResponseDto.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/java/com/matzip/place/application/port/PlaceTempStore.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,16 @@
33
import java.util.List;
44

55
/**
6-
* 임시 스냅샷 저장소 Port(추상화)
7-
* 애플리케이션 계층은 구현체(메모리/Redis 등)에 의존하지 않고 이 인터페이스에만 의존
6+
* 임시 스냅샷 저장소 Port
87
*/
98
public interface PlaceTempStore {
109

1110
void put(PlaceSnapshot snapshot);
1211

13-
/**
14-
* 등록 시점에 사용할 스냅샷을 조회한다.
15-
* 존재하지 않거나 만료되었으면 null을 반환한다.
16-
*/
1712
PlaceSnapshot findById(String kakaoPlaceId);
1813

1914
void remove(String kakaoPlaceId);
2015

21-
/**
22-
* 프리뷰 단계에서 확보한 값을 등록 시까지 보존하기 위한 스냅샷 모델
23-
* 서버가 신뢰하는 값(이름/주소/좌표)을 보존하여, 등록 시 클라이언트 입력을 신뢰하지 않기 위함
24-
* 사진/메뉴는 정책상 URL/원본 메뉴 기준으로 보존한다(추천 여부는 등록 요청에서 사용자 선택 반영)
25-
*/
2616
final class PlaceSnapshot {
2717

2818
private final String kakaoPlaceId;
@@ -71,10 +61,7 @@ public PlaceSnapshot(
7161
public List<SMenu> getMenus() { return menus; }
7262
public List<SPhoto> getPhotos() { return photos; }
7363

74-
/**
75-
* 프리뷰 시점의 메뉴 스냅샷(추천 여부는 포함하지 않음)
76-
* 등록 단계에서 요청의 isRecommended를 이름 매칭으로 반영하기 위함
77-
*/
64+
7865
public static final class SMenu {
7966
private final String name;
8067
private final int price;
@@ -99,10 +86,7 @@ public int getPrice() {
9986
}
10087
}
10188

102-
/**
103-
* 프리뷰 시점의 사진 스냅샷
104-
* 정책상 서버는 파일을 저장하지 않고 외부 URL만 보관한다.
105-
*/
89+
10690
public static final class SPhoto {
10791
private final Long photoId; // 외부에서 식별용으로 제공되면 사용(없으면 null)
10892
private final String photoUrl; // 필수

src/main/java/com/matzip/place/application/service/PlaceLikeService.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.matzip.common.exception.BusinessException;
44
import com.matzip.common.exception.code.ErrorCode;
5-
import com.matzip.place.api.response.LikedPlaceResponseDto;
65
import com.matzip.place.api.response.PlaceLikeResponseDto;
6+
import com.matzip.place.api.response.PlaceCommonResponseDto;
77
import com.matzip.place.domain.entity.*;
88
import com.matzip.place.infra.repository.PlaceCategoryRepository;
99
import com.matzip.place.infra.repository.PlaceLikeRepository;
@@ -18,7 +18,6 @@
1818
import java.util.Collections;
1919
import java.util.List;
2020
import java.util.Map;
21-
import java.util.Optional;
2221
import java.util.stream.Collectors;
2322

2423
@Service
@@ -60,7 +59,7 @@ public PlaceLikeResponseDto removeLike(Long userId, Long placeId) {
6059
}
6160

6261
@Transactional(readOnly = true)
63-
public List<LikedPlaceResponseDto> getLikedPlaces(Long userId) {
62+
public List<PlaceCommonResponseDto> getLikedPlaces(Long userId) {
6463
User user = findUserById(userId);
6564

6665
List<PlaceLike> likes = placeLikeRepository.findAllByUserWithPlace(user);
@@ -86,7 +85,7 @@ public List<LikedPlaceResponseDto> getLikedPlaces(Long userId) {
8685
.map(place -> {
8786
List<Category> categories = placeIdToCategories.getOrDefault(place.getId(), Collections.emptyList());
8887
List<Tag> tags = placeIdToTags.getOrDefault(place.getId(), Collections.emptyList());
89-
return LikedPlaceResponseDto.from(place, categories, tags);
88+
return PlaceCommonResponseDto.from(place, categories, tags);
9089
})
9190
.collect(Collectors.toList());
9291
}

0 commit comments

Comments
 (0)