Skip to content

Commit 6d33cc9

Browse files
authored
Merge pull request #65 from swyp-app-team-4/feat#64-add-image-url-field-in-official-place-response
[Feat] 공식 장소 Response에 `imageUrl` 추가 및 누락된 Swagger 어노테이션 추가
2 parents 93290f7 + b5e187f commit 6d33cc9

7 files changed

Lines changed: 101 additions & 14 deletions

File tree

src/main/java/boombimapi/domain/congestion/api/MemberCongestionController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import boombimapi.domain.congestion.dto.request.CreateMemberCongestionRequest;
77
import boombimapi.domain.congestion.dto.response.CreateMemberCongestionResponse;
88
import boombimapi.global.response.BaseResponse;
9+
import io.swagger.v3.oas.annotations.Operation;
10+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
11+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
12+
import io.swagger.v3.oas.annotations.tags.Tag;
913
import lombok.RequiredArgsConstructor;
1014
import org.springframework.http.HttpStatus;
1115
import org.springframework.http.ResponseEntity;
@@ -18,10 +22,15 @@
1822
@RestController
1923
@RequiredArgsConstructor
2024
@RequestMapping("/member-congestion")
25+
@Tag(name = "Member Congestion", description = "사용자 혼잡도 관련 API")
2126
public class MemberCongestionController {
2227

2328
private final MemberCongestionService memberCongestionService;
2429

30+
@Operation(summary = "사용자 혼잡도 생성", description = "사용자 장소에 새로운 사용자 혼잡도를 추가합니다.")
31+
@ApiResponses(value = {
32+
@ApiResponse(responseCode = "200", description = "사용자 혼잡도 생성 성공")
33+
})
2534
@PostMapping("/create")
2635
public ResponseEntity<BaseResponse<CreateMemberCongestionResponse>> createMemberCongestion(
2736
@AuthenticationPrincipal String memberId,
@@ -37,5 +46,4 @@ public ResponseEntity<BaseResponse<CreateMemberCongestionResponse>> createMember
3746
}
3847

3948

40-
4149
}

src/main/java/boombimapi/domain/favorite/api/FavoriteController.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
import boombimapi.domain.favorite.dto.response.AddFavoriteResponse;
88
import boombimapi.domain.favorite.dto.response.GetFavoriteResponse;
99
import boombimapi.global.response.BaseResponse;
10+
import io.swagger.v3.oas.annotations.Operation;
11+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
12+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
13+
import io.swagger.v3.oas.annotations.tags.Tag;
1014
import java.util.List;
1115
import lombok.RequiredArgsConstructor;
1216
import org.springframework.http.HttpStatus;
@@ -23,10 +27,15 @@
2327
@RestController
2428
@RequiredArgsConstructor
2529
@RequestMapping("/favorite")
30+
@Tag(name = "Favorite", description = "사용자 즐겨찾기 관련 API")
2631
public class FavoriteController {
2732

2833
private final FavoriteService favoriteService;
2934

35+
@Operation(summary = "즐겨찾기 추가", description = "해당 장소를 즐겨찾기에 추가합니다.")
36+
@ApiResponses(value = {
37+
@ApiResponse(responseCode = "200", description = "즐겨찾기 추가 성공")
38+
})
3039
@PostMapping
3140
public ResponseEntity<BaseResponse<AddFavoriteResponse>> addFavorite(
3241
@AuthenticationPrincipal String memberId,
@@ -41,6 +50,10 @@ public ResponseEntity<BaseResponse<AddFavoriteResponse>> addFavorite(
4150
);
4251
}
4352

53+
@Operation(summary = "즐겨찾기 삭제", description = "해당 장소를 즐겨찾기에서 삭제합니다.")
54+
@ApiResponses(value = {
55+
@ApiResponse(responseCode = "200", description = "즐겨찾기 삭제 성공")
56+
})
4457
@DeleteMapping
4558
public ResponseEntity<BaseResponse<Void>> deleteFavorite(
4659
@AuthenticationPrincipal String memberId,
@@ -57,6 +70,10 @@ public ResponseEntity<BaseResponse<Void>> deleteFavorite(
5770
);
5871
}
5972

73+
@Operation(summary = "즐겨찾기 조회", description = "사용자가 즐겨찾기한 장소들의 최신 혼잡도를 조회합니다.")
74+
@ApiResponses(value = {
75+
@ApiResponse(responseCode = "200", description = "사용자 즐겨찾기 최신 혼잡도 조회 성공")
76+
})
6077
@GetMapping
6178
public ResponseEntity<BaseResponse<List<GetFavoriteResponse>>> getFavorites(
6279
@AuthenticationPrincipal String memberId

src/main/java/boombimapi/domain/place/application/OfficialPlaceService.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,19 @@ public List<ViewportResponse> getOfficialPlacesInViewport(
8888
centroidLongitude
8989
);
9090

91-
result.add(new ViewportResponse(
92-
officialPlace.getId(),
93-
officialPlace.getName(),
94-
new Coordinate(centroidLatitude, centroidLongitude),
95-
distanceMeters,
96-
congestionLevel.getName(),
97-
congestionLevel.getMessage()));
91+
Coordinate coordinate = Coordinate.of(centroidLatitude, centroidLongitude);
92+
93+
result.add(
94+
ViewportResponse.of(
95+
officialPlace.getId(),
96+
officialPlace.getName(),
97+
officialPlace.getImageUrl(),
98+
coordinate,
99+
distanceMeters,
100+
congestionLevel.getName(),
101+
congestionLevel.getMessage()
102+
)
103+
);
98104
}
99105

100106
// TODO: 정렬을 DB 단에서 해줄지, 아니면 지금처럼 소스 코드 단에서 해줄지 고민
@@ -130,10 +136,11 @@ public OfficialPlaceOverviewResponse getOverview(
130136
.map(OfficialPlaceForecast::from)
131137
.toList();
132138

133-
return new OfficialPlaceOverviewResponse(
139+
return OfficialPlaceOverviewResponse.of(
134140
officialPlace.getId(),
135141
officialPlace.getName(),
136142
officialPlace.getPoiCode(),
143+
officialPlace.getImageUrl(),
137144
latestOfficialCongestion.getObservedAt(),
138145
officialPlace.getCentroidLatitude(),
139146
officialPlace.getCentroidLongitude(),

src/main/java/boombimapi/domain/place/dto/response/ViewportResponse.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,33 @@
33
import boombimapi.global.dto.Coordinate;
44

55
public record ViewportResponse(
6-
Long id,
7-
String name,
6+
Long officialPlaceId,
7+
String officialPlaceName,
8+
String imageUrl,
89
Coordinate coordinate,
910
double distance,
1011
String congestionLevelName,
1112
String congestionMessage
1213
) {
1314

15+
public static ViewportResponse of(
16+
Long officialPlaceId,
17+
String officialPlaceName,
18+
String imageUrl,
19+
Coordinate coordinate,
20+
double distance,
21+
String congestionLevelName,
22+
String congestionMessage
23+
) {
24+
return new ViewportResponse(
25+
officialPlaceId,
26+
officialPlaceName,
27+
imageUrl,
28+
coordinate,
29+
distance,
30+
congestionLevelName,
31+
congestionMessage
32+
);
33+
}
34+
1435
}

src/main/java/boombimapi/domain/place/dto/response/official/OfficialPlaceOverviewResponse.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import java.util.List;
55

66
public record OfficialPlaceOverviewResponse(
7-
Long id,
8-
String name,
7+
Long officialPlaceId,
8+
String officialPlaceName,
99
String poiCode,
10+
String imageUrl,
1011
LocalDateTime observedAt,
1112
Double centroidLatitude,
1213
Double centroidLongitude,
@@ -15,4 +16,30 @@ public record OfficialPlaceOverviewResponse(
1516
List<OfficialPlaceForecast> forecasts
1617
) {
1718

19+
public static OfficialPlaceOverviewResponse of(
20+
Long officialPlaceId,
21+
String officialPlaceName,
22+
String poiCode,
23+
String imageUrl,
24+
LocalDateTime observedAt,
25+
Double centroidLatitude,
26+
Double centroidLongitude,
27+
String polygonCoordinates,
28+
List<OfficialPlaceDemographics> demographics,
29+
List<OfficialPlaceForecast> forecasts
30+
) {
31+
return new OfficialPlaceOverviewResponse(
32+
officialPlaceId,
33+
officialPlaceName,
34+
poiCode,
35+
imageUrl,
36+
observedAt,
37+
centroidLatitude,
38+
centroidLongitude,
39+
polygonCoordinates,
40+
demographics,
41+
forecasts
42+
);
43+
}
44+
1845
}

src/main/java/boombimapi/global/dto/Coordinate.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ public record Coordinate(
55
double longitude
66
) {
77

8+
public static Coordinate of(
9+
double latitude,
10+
double longitude
11+
) {
12+
return new Coordinate(latitude, longitude);
13+
}
14+
815
}

src/main/resources/application-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spring:
1212
password: ${DB_PASSWORD}
1313
jpa:
1414
hibernate:
15-
ddl-auto: none
15+
ddl-auto: create
1616
properties:
1717
hibernate:
1818
default_schema: root # 기본 스키마

0 commit comments

Comments
 (0)