Skip to content

Commit

Permalink
[merge] 스웨거 문서 작성 1차
Browse files Browse the repository at this point in the history
스웨거 문서 작성 1차
  • Loading branch information
jinkonu authored Oct 21, 2024
2 parents 9e453d0 + 7d8229e commit 9fe794c
Show file tree
Hide file tree
Showing 51 changed files with 1,687 additions and 331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import org.recordy.server.auth.security.filter.TokenAuthenticationFilter;
import org.recordy.server.auth.security.handler.CustomAuthenticationEntryPoint;
import org.recordy.server.auth.security.handler.UndefinedAccessHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -29,6 +30,7 @@ public class SecurityConfig {

private final TokenAuthenticationFilter tokenAuthenticationFilter;
private final UndefinedAccessHandler undefinedAccessHandler;
private final CustomAuthenticationEntryPoint authenticationEntryPoint;

@Bean
@Profile("local")
Expand Down Expand Up @@ -60,7 +62,11 @@ private void setHttp(HttpSecurity http) throws Exception {
.formLogin(FormLoginConfigurer::disable)
.httpBasic(HttpBasicConfigurer::disable)
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
.exceptionHandling(exception -> exception.accessDeniedHandler(undefinedAccessHandler))
.exceptionHandling(exception ->
exception
.accessDeniedHandler(undefinedAccessHandler)
.authenticationEntryPoint(authenticationEntryPoint)
)
.authorizeHttpRequests(requests ->
requests
.requestMatchers(authFreeApis).permitAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public enum ErrorMessage {
EXPIRED_TOKEN(HttpStatus.UNAUTHORIZED, "액세스 토큰이 만료되었습니다. 재발급 받아주세요."),
INVALID_TOKEN(HttpStatus.UNAUTHORIZED, "액세스 토큰의 형식이 올바르지 않습니다. Bearer 타입을 확인해 주세요."),
INVALID_TOKEN_VALUE(HttpStatus.UNAUTHORIZED, "액세스 토큰의 값이 올바르지 않습니다."),
NOT_MATCH_REFRESH_TOKEN(HttpStatus.UNAUTHORIZED, "일치하지 않는 리프레시 토큰입니다."),

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

/**
* SEARCH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.recordy.server.exhibition.domain.usecase.ExhibitionCreate;
import org.recordy.server.exhibition.repository.ExhibitionRepository;
import org.recordy.server.place.controller.dto.request.PlaceCreateRequest;
import org.recordy.server.place.controller.dto.response.PlatformPlaceSearchResponse;
import org.recordy.server.place.domain.Place;
import org.recordy.server.place.exception.PlaceException;
import org.recordy.server.place.repository.PlaceRepository;
Expand All @@ -33,7 +34,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;

@Slf4j
@Profile({"dev", "local"})
@Profile({"dev"})
@Component
public class ExhibitionDataInitializer {

Expand Down Expand Up @@ -88,8 +89,15 @@ private void saveExhibition(PerforList performance) {
place = placeRepository.findByName(performance.place());
} catch (PlaceException e) {
try {
String platformId = platformPlaceService.searchId(performance.place());
place = placeService.create(new PlaceCreateRequest(platformId));
PlatformPlaceSearchResponse response = platformPlaceService.search(performance.place()).get(0);

place = placeService.create(new PlaceCreateRequest(
response.platformPlaceId(),
response.name(),
response.longitude(),
response.latitude(),
response.address()
));
} catch (PlaceException ee) {
place = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void create(ExhibitionCreateRequest request) {
Place place = placeRepository.findById(request.placeId());
Exhibition exhibition = exhibitionRepository.save(Exhibition.create(ExhibitionCreate.of(request, place)));

searchRepository.save(Search.from(exhibition, place.getLocation().getAddress()));
searchRepository.save(Search.from(exhibition, place));
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public record LocationGetResponse(
Long id,
Point point,
String address
Point point
) {
}
11 changes: 2 additions & 9 deletions src/main/java/org/recordy/server/location/domain/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.locationtech.jts.geom.Point;
import org.recordy.server.place.domain.usecase.PlatformPlace;

import java.time.LocalDateTime;

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

private Long id;
private Point geometry;
private String address;
private String platformPlaceId;

private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public static Location of(PlatformPlace platformPlace) {
public static Location of(Point point) {
return new Location(
null,
platformPlace.geometry(),
platformPlace.address(),
platformPlace.placeId(),
point,
null,
null
);
Expand All @@ -34,8 +29,6 @@ public static Location from(LocationEntity entity) {
return new Location(
entity.getId(),
entity.getGeometry(),
entity.getAddress(),
entity.getPlatformPlaceId(),
entity.getCreatedAt(),
entity.getUpdatedAt()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Point;
import org.recordy.server.common.domain.JpaMetaInfoEntity;
import org.recordy.server.place.domain.PlaceEntity;

import java.time.LocalDateTime;

Expand All @@ -20,24 +19,15 @@ public class LocationEntity extends JpaMetaInfoEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Point geometry;
private String address;
private String platformPlaceId;

@OneToOne(mappedBy = "location")
private PlaceEntity place;

private LocationEntity(
Long id,
Point geometry,
String address,
String platformPlaceId,
LocalDateTime createdAt,
LocalDateTime updatedAt
) {
this.id = id;
this.geometry = geometry;
this.address = address;
this.platformPlaceId = platformPlaceId;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
}
Expand All @@ -46,8 +36,6 @@ public static LocationEntity from(Location location) {
return new LocationEntity(
location.getId(),
location.getGeometry(),
location.getAddress(),
location.getPlatformPlaceId(),
location.getCreatedAt(),
location.getUpdatedAt()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.recordy.server.place.controller.dto.request;

public record PlaceCreateRequest(
String platformId
String id,
String name,
double longitude,
double latitude,
String address
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class PlaceGetResponse {

Long id;
String name;
String address;
String platformId;
LocationGetResponse location;
@Setter
long exhibitionSize;
Expand All @@ -18,10 +20,14 @@ public class PlaceGetResponse {
public PlaceGetResponse(
Long id,
String name,
String address,
String platformId,
LocationGetResponse location
) {
this.id = id;
this.name = name;
this.address = address;
this.platformId = platformId;
this.location = location;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
package org.recordy.server.place.controller.dto.response;

import org.recordy.server.place.service.dto.google.GooglePlaceSearch;
import org.recordy.server.place.service.dto.kakao.KakaoPlaceSearch;

public record PlatformPlaceSearchResponse(
String platformPlaceId,
String address
String address,
double longitude,
double latitude,
String name
) {

public static PlatformPlaceSearchResponse from(GooglePlaceSearch google) {
return new PlatformPlaceSearchResponse(
google.place_id(),
google.formatted_address()
google.formatted_address(),
google.geometry().location().lng(),
google.geometry().location().lat(),
google.name()
);
}

public static PlatformPlaceSearchResponse from(KakaoPlaceSearch kakao) {
return new PlatformPlaceSearchResponse(
kakao.id(),
kakao.address_name(),
Double.parseDouble(kakao.x()),
Double.parseDouble(kakao.y()),
kakao.place_name()
);
}
}
6 changes: 6 additions & 0 deletions src/main/java/org/recordy/server/place/domain/Place.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Place {

private Long id;
private String name;
private String platformId;
private String address;
private List<Exhibition> exhibitions;
private Location location;

Expand All @@ -31,6 +33,8 @@ public static Place from(PlaceEntity entity) {
return new Place(
entity.getId(),
entity.getName(),
entity.getPlatformId(),
entity.getAddress(),
entity.getExhibitions().stream()
.map(Exhibition::from)
.toList(),
Expand All @@ -48,6 +52,8 @@ public static Place create(PlaceCreate create) {
return new Place(
null,
create.name(),
create.platformId(),
create.address(),
List.of(),
create.location(),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class PlaceEntity extends JpaMetaInfoEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String platformId;
private String address;

@OneToMany(mappedBy = "place", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ExhibitionEntity> exhibitions = new ArrayList<>();
Expand All @@ -33,13 +35,17 @@ public class PlaceEntity extends JpaMetaInfoEntity {
private PlaceEntity(
Long id,
String name,
String platformId,
String address,
List<ExhibitionEntity> exhibitions,
LocationEntity location,
LocalDateTime createdAt,
LocalDateTime updatedAt
) {
this.id = id;
this.name = name;
this.platformId = platformId;
this.address = address;
this.exhibitions = exhibitions;
this.location = location;
this.createdAt = createdAt;
Expand All @@ -54,6 +60,8 @@ public static PlaceEntity create(Place place) {
return new PlaceEntity(
place.getId(),
place.getName(),
place.getPlatformId(),
place.getAddress(),
place.getExhibitions().stream()
.map(ExhibitionEntity::from)
.toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.recordy.server.place.service.dto.Review;
import org.recordy.server.place.service.dto.google.Review;

import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
package org.recordy.server.place.domain.usecase;

import org.recordy.server.location.domain.Location;
import org.recordy.server.place.controller.dto.request.PlaceCreateRequest;

public record PlaceCreate(
String name,
String address,
String platformId,
Location location
) {

public static PlaceCreate from(PlaceCreateRequest request, Location location) {
return new PlaceCreate(
request.name(),
request.address(),
request.id(),
location
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ public interface PlaceRepository {
Place findByName(String name);
PlaceGetResponse findDetailById(Long id);
Slice<PlaceGetResponse> findAllOrderByExhibitionStartDateDesc(Pageable pageable);
Slice<PlaceGetResponse> findAllByNameOrderByExhibitionStartDateDesc(Pageable pageable, String query);
Slice<PlaceGetResponse> findAllByLocationOrderByExhibitionStartDateDesc(Pageable pageable, Point currentLocation, double distance);
}
Loading

0 comments on commit 9fe794c

Please sign in to comment.