Skip to content

Commit 9fe794c

Browse files
authored
[merge] 스웨거 문서 작성 1차
스웨거 문서 작성 1차
2 parents 9e453d0 + 7d8229e commit 9fe794c

File tree

51 files changed

+1687
-331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1687
-331
lines changed

src/main/java/org/recordy/server/common/config/SecurityConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.RequiredArgsConstructor;
44
import org.recordy.server.auth.security.filter.TokenAuthenticationFilter;
5+
import org.recordy.server.auth.security.handler.CustomAuthenticationEntryPoint;
56
import org.recordy.server.auth.security.handler.UndefinedAccessHandler;
67
import org.springframework.beans.factory.annotation.Value;
78
import org.springframework.context.annotation.Bean;
@@ -29,6 +30,7 @@ public class SecurityConfig {
2930

3031
private final TokenAuthenticationFilter tokenAuthenticationFilter;
3132
private final UndefinedAccessHandler undefinedAccessHandler;
33+
private final CustomAuthenticationEntryPoint authenticationEntryPoint;
3234

3335
@Bean
3436
@Profile("local")
@@ -60,7 +62,11 @@ private void setHttp(HttpSecurity http) throws Exception {
6062
.formLogin(FormLoginConfigurer::disable)
6163
.httpBasic(HttpBasicConfigurer::disable)
6264
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
63-
.exceptionHandling(exception -> exception.accessDeniedHandler(undefinedAccessHandler))
65+
.exceptionHandling(exception ->
66+
exception
67+
.accessDeniedHandler(undefinedAccessHandler)
68+
.authenticationEntryPoint(authenticationEntryPoint)
69+
)
6470
.authorizeHttpRequests(requests ->
6571
requests
6672
.requestMatchers(authFreeApis).permitAll()

src/main/java/org/recordy/server/common/message/ErrorMessage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public enum ErrorMessage {
3333
EXPIRED_TOKEN(HttpStatus.UNAUTHORIZED, "액세스 토큰이 만료되었습니다. 재발급 받아주세요."),
3434
INVALID_TOKEN(HttpStatus.UNAUTHORIZED, "액세스 토큰의 형식이 올바르지 않습니다. Bearer 타입을 확인해 주세요."),
3535
INVALID_TOKEN_VALUE(HttpStatus.UNAUTHORIZED, "액세스 토큰의 값이 올바르지 않습니다."),
36-
NOT_MATCH_REFRESH_TOKEN(HttpStatus.UNAUTHORIZED, "일치하지 않는 리프레시 토큰입니다."),
3736

3837
// APPLE
3938
APPLE_EXPIRED_IDENTITY_TOKEN(HttpStatus.UNAUTHORIZED, "Apple OAuth Identity Token 토큰의 유효 기간이 만료되었습니다."),
@@ -73,7 +72,7 @@ public enum ErrorMessage {
7372
* PLACE
7473
*/
7574
PLACE_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 장소입니다."),
76-
PLACE_GOOGLE_NO_RESULT(HttpStatus.NOT_FOUND, "구글 지도 검색 결과가 없습니다."),
75+
PLATFORM_PLACE_NO_SEARCH_RESULT(HttpStatus.NOT_FOUND, "지도 검색 결과가 없습니다."),
7776

7877
/**
7978
* SEARCH

src/main/java/org/recordy/server/common/util/data/ExhibitionDataInitializer.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.recordy.server.exhibition.domain.usecase.ExhibitionCreate;
1111
import org.recordy.server.exhibition.repository.ExhibitionRepository;
1212
import org.recordy.server.place.controller.dto.request.PlaceCreateRequest;
13+
import org.recordy.server.place.controller.dto.response.PlatformPlaceSearchResponse;
1314
import org.recordy.server.place.domain.Place;
1415
import org.recordy.server.place.exception.PlaceException;
1516
import org.recordy.server.place.repository.PlaceRepository;
@@ -33,7 +34,7 @@
3334
import static java.nio.charset.StandardCharsets.UTF_8;
3435

3536
@Slf4j
36-
@Profile({"dev", "local"})
37+
@Profile({"dev"})
3738
@Component
3839
public class ExhibitionDataInitializer {
3940

@@ -88,8 +89,15 @@ private void saveExhibition(PerforList performance) {
8889
place = placeRepository.findByName(performance.place());
8990
} catch (PlaceException e) {
9091
try {
91-
String platformId = platformPlaceService.searchId(performance.place());
92-
place = placeService.create(new PlaceCreateRequest(platformId));
92+
PlatformPlaceSearchResponse response = platformPlaceService.search(performance.place()).get(0);
93+
94+
place = placeService.create(new PlaceCreateRequest(
95+
response.platformPlaceId(),
96+
response.name(),
97+
response.longitude(),
98+
response.latitude(),
99+
response.address()
100+
));
93101
} catch (PlaceException ee) {
94102
place = null;
95103
}

src/main/java/org/recordy/server/exhibition/service/impl/ExhibitionServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void create(ExhibitionCreateRequest request) {
3535
Place place = placeRepository.findById(request.placeId());
3636
Exhibition exhibition = exhibitionRepository.save(Exhibition.create(ExhibitionCreate.of(request, place)));
3737

38-
searchRepository.save(Search.from(exhibition, place.getLocation().getAddress()));
38+
searchRepository.save(Search.from(exhibition, place));
3939
}
4040

4141
@Transactional

src/main/java/org/recordy/server/location/controller/dto/response/LocationGetResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
public record LocationGetResponse(
66
Long id,
7-
Point point,
8-
String address
7+
Point point
98
) {
109
}

src/main/java/org/recordy/server/location/domain/Location.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import lombok.AllArgsConstructor;
44
import lombok.Getter;
55
import org.locationtech.jts.geom.Point;
6-
import org.recordy.server.place.domain.usecase.PlatformPlace;
76

87
import java.time.LocalDateTime;
98

@@ -13,18 +12,14 @@ public class Location {
1312

1413
private Long id;
1514
private Point geometry;
16-
private String address;
17-
private String platformPlaceId;
1815

1916
private LocalDateTime createdAt;
2017
private LocalDateTime updatedAt;
2118

22-
public static Location of(PlatformPlace platformPlace) {
19+
public static Location of(Point point) {
2320
return new Location(
2421
null,
25-
platformPlace.geometry(),
26-
platformPlace.address(),
27-
platformPlace.placeId(),
22+
point,
2823
null,
2924
null
3025
);
@@ -34,8 +29,6 @@ public static Location from(LocationEntity entity) {
3429
return new Location(
3530
entity.getId(),
3631
entity.getGeometry(),
37-
entity.getAddress(),
38-
entity.getPlatformPlaceId(),
3932
entity.getCreatedAt(),
4033
entity.getUpdatedAt()
4134
);

src/main/java/org/recordy/server/location/domain/LocationEntity.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import lombok.NoArgsConstructor;
77
import org.locationtech.jts.geom.Point;
88
import org.recordy.server.common.domain.JpaMetaInfoEntity;
9-
import org.recordy.server.place.domain.PlaceEntity;
109

1110
import java.time.LocalDateTime;
1211

@@ -20,24 +19,15 @@ public class LocationEntity extends JpaMetaInfoEntity {
2019
@GeneratedValue(strategy = GenerationType.IDENTITY)
2120
private Long id;
2221
private Point geometry;
23-
private String address;
24-
private String platformPlaceId;
25-
26-
@OneToOne(mappedBy = "location")
27-
private PlaceEntity place;
2822

2923
private LocationEntity(
3024
Long id,
3125
Point geometry,
32-
String address,
33-
String platformPlaceId,
3426
LocalDateTime createdAt,
3527
LocalDateTime updatedAt
3628
) {
3729
this.id = id;
3830
this.geometry = geometry;
39-
this.address = address;
40-
this.platformPlaceId = platformPlaceId;
4131
this.createdAt = createdAt;
4232
this.updatedAt = updatedAt;
4333
}
@@ -46,8 +36,6 @@ public static LocationEntity from(Location location) {
4636
return new LocationEntity(
4737
location.getId(),
4838
location.getGeometry(),
49-
location.getAddress(),
50-
location.getPlatformPlaceId(),
5139
location.getCreatedAt(),
5240
location.getUpdatedAt()
5341
);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package org.recordy.server.place.controller.dto.request;
22

33
public record PlaceCreateRequest(
4-
String platformId
4+
String id,
5+
String name,
6+
double longitude,
7+
double latitude,
8+
String address
59
) {
610
}

src/main/java/org/recordy/server/place/controller/dto/response/PlaceGetResponse.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class PlaceGetResponse {
99

1010
Long id;
1111
String name;
12+
String address;
13+
String platformId;
1214
LocationGetResponse location;
1315
@Setter
1416
long exhibitionSize;
@@ -18,10 +20,14 @@ public class PlaceGetResponse {
1820
public PlaceGetResponse(
1921
Long id,
2022
String name,
23+
String address,
24+
String platformId,
2125
LocationGetResponse location
2226
) {
2327
this.id = id;
2428
this.name = name;
29+
this.address = address;
30+
this.platformId = platformId;
2531
this.location = location;
2632
}
2733
}
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
package org.recordy.server.place.controller.dto.response;
22

33
import org.recordy.server.place.service.dto.google.GooglePlaceSearch;
4+
import org.recordy.server.place.service.dto.kakao.KakaoPlaceSearch;
45

56
public record PlatformPlaceSearchResponse(
67
String platformPlaceId,
7-
String address
8+
String address,
9+
double longitude,
10+
double latitude,
11+
String name
812
) {
913

1014
public static PlatformPlaceSearchResponse from(GooglePlaceSearch google) {
1115
return new PlatformPlaceSearchResponse(
1216
google.place_id(),
13-
google.formatted_address()
17+
google.formatted_address(),
18+
google.geometry().location().lng(),
19+
google.geometry().location().lat(),
20+
google.name()
21+
);
22+
}
23+
24+
public static PlatformPlaceSearchResponse from(KakaoPlaceSearch kakao) {
25+
return new PlatformPlaceSearchResponse(
26+
kakao.id(),
27+
kakao.address_name(),
28+
Double.parseDouble(kakao.x()),
29+
Double.parseDouble(kakao.y()),
30+
kakao.place_name()
1431
);
1532
}
1633
}

src/main/java/org/recordy/server/place/domain/Place.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class Place {
1717

1818
private Long id;
1919
private String name;
20+
private String platformId;
21+
private String address;
2022
private List<Exhibition> exhibitions;
2123
private Location location;
2224

@@ -31,6 +33,8 @@ public static Place from(PlaceEntity entity) {
3133
return new Place(
3234
entity.getId(),
3335
entity.getName(),
36+
entity.getPlatformId(),
37+
entity.getAddress(),
3438
entity.getExhibitions().stream()
3539
.map(Exhibition::from)
3640
.toList(),
@@ -48,6 +52,8 @@ public static Place create(PlaceCreate create) {
4852
return new Place(
4953
null,
5054
create.name(),
55+
create.platformId(),
56+
create.address(),
5157
List.of(),
5258
create.location(),
5359
null,

src/main/java/org/recordy/server/place/domain/PlaceEntity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class PlaceEntity extends JpaMetaInfoEntity {
2424
@GeneratedValue(strategy = GenerationType.IDENTITY)
2525
private Long id;
2626
private String name;
27+
private String platformId;
28+
private String address;
2729

2830
@OneToMany(mappedBy = "place", cascade = CascadeType.ALL, orphanRemoval = true)
2931
private List<ExhibitionEntity> exhibitions = new ArrayList<>();
@@ -33,13 +35,17 @@ public class PlaceEntity extends JpaMetaInfoEntity {
3335
private PlaceEntity(
3436
Long id,
3537
String name,
38+
String platformId,
39+
String address,
3640
List<ExhibitionEntity> exhibitions,
3741
LocationEntity location,
3842
LocalDateTime createdAt,
3943
LocalDateTime updatedAt
4044
) {
4145
this.id = id;
4246
this.name = name;
47+
this.platformId = platformId;
48+
this.address = address;
4349
this.exhibitions = exhibitions;
4450
this.location = location;
4551
this.createdAt = createdAt;
@@ -54,6 +60,8 @@ public static PlaceEntity create(Place place) {
5460
return new PlaceEntity(
5561
place.getId(),
5662
place.getName(),
63+
place.getPlatformId(),
64+
place.getAddress(),
5765
place.getExhibitions().stream()
5866
.map(ExhibitionEntity::from)
5967
.toList(),

src/main/java/org/recordy/server/place/domain/PlaceReview.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import lombok.AllArgsConstructor;
55
import lombok.Getter;
66
import lombok.NoArgsConstructor;
7-
import org.recordy.server.place.service.dto.Review;
7+
import org.recordy.server.place.service.dto.google.Review;
88

99
import java.time.LocalDateTime;
1010

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
package org.recordy.server.place.domain.usecase;
22

33
import org.recordy.server.location.domain.Location;
4+
import org.recordy.server.place.controller.dto.request.PlaceCreateRequest;
45

56
public record PlaceCreate(
67
String name,
8+
String address,
9+
String platformId,
710
Location location
811
) {
12+
13+
public static PlaceCreate from(PlaceCreateRequest request, Location location) {
14+
return new PlaceCreate(
15+
request.name(),
16+
request.address(),
17+
request.id(),
18+
location
19+
);
20+
}
921
}

src/main/java/org/recordy/server/place/domain/usecase/PlatformPlace.java

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

src/main/java/org/recordy/server/place/repository/PlaceRepository.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ public interface PlaceRepository {
1616
Place findByName(String name);
1717
PlaceGetResponse findDetailById(Long id);
1818
Slice<PlaceGetResponse> findAllOrderByExhibitionStartDateDesc(Pageable pageable);
19-
Slice<PlaceGetResponse> findAllByNameOrderByExhibitionStartDateDesc(Pageable pageable, String query);
2019
Slice<PlaceGetResponse> findAllByLocationOrderByExhibitionStartDateDesc(Pageable pageable, Point currentLocation, double distance);
2120
}

0 commit comments

Comments
 (0)