diff --git a/build.gradle b/build.gradle index da5439a5..caa14d82 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,12 @@ dependencies { // mysql connector runtimeOnly 'com.mysql:mysql-connector-j' + // queryDSL 설정 + implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta" + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + // redis implementation 'org.springframework.boot:spring-boot-starter-data-redis' @@ -56,3 +62,25 @@ jar { tasks.named('test') { useJUnitPlatform() } + + +// Querydsl 설정부 +// 아래 것들이 없어도 기본적인 querydsl 동작은 하나 인테리제이에서 빌드 시 발생할 문제를 예방 +def generated = 'src/main/generated' + +// querydsl QClass 파일 생성 위치를 지정 +// 원래 build 디렉토리 안에 있어서 눈에 안보였지만 꺼네서 내가 지정한 디렉토리에 꺼내옴 +// 인텔리제이 IDE와의 문제인데, 빌드 gradle 할때 스캔 영역이 달라서 중복 스캔이 발생할 수 있다. +tasks.withType(JavaCompile) { + options.getGeneratedSourceOutputDirectory().set(file(generated)) +} + +// java source set 에 querydsl QClass 위치 추가 +sourceSets { + main.java.srcDirs += [ generated ] +} + +// gradle clean 시에 QClass 디렉토리 삭제 +clean { + delete file(generated) +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/controller/PlaceController.java b/src/main/java/com/haejwo/tripcometrue/domain/place/controller/PlaceController.java new file mode 100644 index 00000000..1f963443 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/controller/PlaceController.java @@ -0,0 +1,96 @@ +package com.haejwo.tripcometrue.domain.place.controller; + +import com.haejwo.tripcometrue.domain.place.dto.request.PlaceRequestDTO; +import com.haejwo.tripcometrue.domain.place.dto.response.PlaceResponseDTO; +import com.haejwo.tripcometrue.domain.place.service.PlaceService; +import com.haejwo.tripcometrue.global.util.ResponseDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/v1/places") +@RequiredArgsConstructor +public class PlaceController { + + private final PlaceService placeService; + + @PostMapping + public ResponseEntity> placeAdd( + @RequestBody PlaceRequestDTO requestDto + ) { + + PlaceResponseDTO responseDto = placeService.addPlace(requestDto); + ResponseDTO responseBody = ResponseDTO.okWithData(responseDto); + + return ResponseEntity + .status(responseBody.getCode()) + .body(responseBody); + } + + @GetMapping("/{placeId}") + public ResponseEntity> placeDetails( + @PathVariable Long placeId + ) { + + PlaceResponseDTO responseDto = placeService.findPlace(placeId); + ResponseDTO responseBody = ResponseDTO.okWithData(responseDto); + + return ResponseEntity + .status(responseBody.getCode()) + .body(responseBody); + } + + @GetMapping + public ResponseEntity>> placeList( + Pageable pageable, + @RequestParam Integer storedCount + ) { + + Page placePage = placeService.findPlaces(pageable, storedCount); + + ResponseDTO responseBody = ResponseDTO.okWithData(placePage); + + return ResponseEntity + .status(responseBody.getCode()) + .body(responseBody); + } + + @PutMapping("/{placeId}") + public ResponseEntity> placeModify( + @PathVariable Long placeId, + @RequestBody PlaceRequestDTO requestDto + ) { + + PlaceResponseDTO responseDto = placeService.modifyPlace(placeId, requestDto); + ResponseDTO responseBody = ResponseDTO.okWithData(responseDto); + + return ResponseEntity + .status(responseBody.getCode()) + .body(responseBody); + } + + @DeleteMapping("/{placeId}") + public ResponseEntity placeRemove( + @PathVariable Long placeId + ) { + + placeService.removePlace(placeId); + ResponseDTO responseBody = ResponseDTO.ok(); + + return ResponseEntity + .status(responseBody.getCode()) + .body(responseBody); + } + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/controller/PlaceControllerAdvice.java b/src/main/java/com/haejwo/tripcometrue/domain/place/controller/PlaceControllerAdvice.java new file mode 100644 index 00000000..9f51a461 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/controller/PlaceControllerAdvice.java @@ -0,0 +1,29 @@ +package com.haejwo.tripcometrue.domain.place.controller; + +import com.haejwo.tripcometrue.domain.place.exception.PlaceNotFoundException; +import com.haejwo.tripcometrue.global.util.ResponseDTO; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class PlaceControllerAdvice { + + @ExceptionHandler(PlaceNotFoundException.class) + public ResponseEntity> placeNotFoundExceptionHandler( + PlaceNotFoundException e + ) { + HttpStatus status = e.getErrorCode().getHttpStatus(); + + return ResponseEntity + .status(status) + .body(ResponseDTO.errorWithMessage(status, e.getMessage())); + + + } + + + + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/dto/PlaceDto.java b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/PlaceDto.java new file mode 100644 index 00000000..237e2f49 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/PlaceDto.java @@ -0,0 +1,38 @@ +package com.haejwo.tripcometrue.domain.place.dto; + +import java.time.LocalTime; +import lombok.Builder; + +public record PlaceDto( + Long id, + String name, + String address, + String description, + LocalTime weekdayOpenTime, + LocalTime weekdayCloseTime, + LocalTime weekendOpenTime, + LocalTime weekendCloseTime, + Integer storedCount) { + + @Builder + public PlaceDto( + Long id, + String name, + String address, + String description, + LocalTime weekdayOpenTime, + LocalTime weekdayCloseTime, + LocalTime weekendOpenTime, + LocalTime weekendCloseTime, + Integer storedCount) { + this.id = id; + this.name = name; + this.address = address; + this.description = description; + this.weekdayOpenTime = weekdayOpenTime; + this.weekdayCloseTime = weekdayCloseTime; + this.weekendOpenTime = weekendOpenTime; + this.weekendCloseTime = weekendCloseTime; + this.storedCount = storedCount; + } +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/dto/request/PlaceFilterRequestDTO.java b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/request/PlaceFilterRequestDTO.java new file mode 100644 index 00000000..d8bd5f1c --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/request/PlaceFilterRequestDTO.java @@ -0,0 +1,13 @@ +package com.haejwo.tripcometrue.domain.place.dto.request; + +public record PlaceFilterRequestDTO( + Integer stored_count, + Integer storedCount +) { + + // record는 Compact Constructor라는 기능있어, 생성자 내부의 변수에 대한 로직이 마지막으로 동작하여 변수 초기화를 한다. + public PlaceFilterRequestDTO { + storedCount = stored_count; + } + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/dto/request/PlaceRequestDTO.java b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/request/PlaceRequestDTO.java new file mode 100644 index 00000000..38b7b89b --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/request/PlaceRequestDTO.java @@ -0,0 +1,57 @@ +package com.haejwo.tripcometrue.domain.place.dto.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.haejwo.tripcometrue.domain.place.entity.Place; +import java.time.LocalTime; +import lombok.Builder; + +public record PlaceRequestDTO( + String name, + String address, + String description, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekdayOpenTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekdayCloseTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekendOpenTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekendCloseTime, + Integer storedCount, + Long cityId +) { + + @Builder + public PlaceRequestDTO( + String name, + String address, + String description, + LocalTime weekdayOpenTime, + LocalTime weekdayCloseTime, + LocalTime weekendOpenTime, + LocalTime weekendCloseTime, + Integer storedCount, + Long cityId + ) { + this.name = name; + this.address = address; + this.description = description; + this.weekdayOpenTime = weekdayOpenTime; + this.weekdayCloseTime = weekdayCloseTime; + this.weekendOpenTime = weekendOpenTime; + this.weekendCloseTime = weekendCloseTime; + this.storedCount = storedCount; + this.cityId = cityId; + } + + public Place toEntity() { + return Place.builder() + .name(this.name) + .address(this.address) + .description(this.description) + .weekdayOpenTime(this.weekdayOpenTime) + .weekdayCloseTime(this.weekdayCloseTime) + .weekendOpenTime(this.weekendOpenTime) + .weekendCloseTime(this.weekendCloseTime) + .storedCount(this.storedCount) + .cityId(this.cityId) + .build(); + } + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/dto/response/PlaceResponseDTO.java b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/response/PlaceResponseDTO.java new file mode 100644 index 00000000..c631e866 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/dto/response/PlaceResponseDTO.java @@ -0,0 +1,60 @@ +package com.haejwo.tripcometrue.domain.place.dto.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.haejwo.tripcometrue.domain.place.entity.Place; +import java.time.LocalTime; +import lombok.Builder; +public record PlaceResponseDTO( + Long id, + String name, + String address, + String description, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekdayOpenTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekdayCloseTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekendOpenTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") LocalTime weekendCloseTime, + Integer storedCount, + Long cityId +) { + + @Builder + public PlaceResponseDTO( + Long id, + String name, + String address, + String description, + LocalTime weekdayOpenTime, + LocalTime weekdayCloseTime, + LocalTime weekendOpenTime, + LocalTime weekendCloseTime, + Integer storedCount, + Long cityId + ) { + this.id = id; + this.name = name; + this.address = address; + this.description = description; + this.weekdayOpenTime = weekdayOpenTime; + this.weekdayCloseTime = weekdayCloseTime; + this.weekendOpenTime = weekendOpenTime; + this.weekendCloseTime = weekendCloseTime; + this.storedCount = storedCount; + this.cityId = cityId; + } + + public static PlaceResponseDTO fromEntity(Place entity) { + return PlaceResponseDTO.builder() + .id(entity.getId()) + .name(entity.getName()) + .address(entity.getAddress()) + .description(entity.getDescription()) + .weekdayOpenTime(entity.getWeekdayOpenTime()) + .weekdayCloseTime(entity.getWeekdayCloseTime()) + .weekendOpenTime(entity.getWeekendOpenTime()) + .weekendCloseTime(entity.getWeekendCloseTime()) + .storedCount(entity.getStoredCount()) + .cityId(entity.getCityId()) + .build(); + } + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/entity/Place.java b/src/main/java/com/haejwo/tripcometrue/domain/place/entity/Place.java new file mode 100644 index 00000000..20deb3dc --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/entity/Place.java @@ -0,0 +1,74 @@ +package com.haejwo.tripcometrue.domain.place.entity; + +import com.haejwo.tripcometrue.domain.place.dto.request.PlaceRequestDTO; +import com.haejwo.tripcometrue.global.entity.BaseTimeEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.PrePersist; +import java.time.LocalTime; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Place extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "place_id") + private Long id; + + @Column(nullable = false) + private String name; + @Column(nullable = false) + private String address; + private String description; + private LocalTime weekdayOpenTime; + private LocalTime weekdayCloseTime; + private LocalTime weekendOpenTime; + private LocalTime weekendCloseTime; + private Integer storedCount; + + // 임시 City 테이블 데이터 + private Long cityId; + + @PrePersist + public void prePersist() { + this.storedCount = this.storedCount == null ? 0 : storedCount; + } + + @Builder + public Place( + Long id, String name, String address, String description, + LocalTime weekdayOpenTime, LocalTime weekdayCloseTime, + LocalTime weekendOpenTime, LocalTime weekendCloseTime, + Integer storedCount, Long cityId) { + this.id = id; + this.name = name; + this.address = address; + this.description = description; + this.weekdayOpenTime = weekdayOpenTime; + this.weekdayCloseTime = weekdayCloseTime; + this.weekendOpenTime = weekendOpenTime; + this.weekendCloseTime = weekendCloseTime; + this.storedCount = storedCount; + this.cityId = cityId; + } + + public void update(PlaceRequestDTO requestDto) { + this.name = requestDto.name(); + this.address = requestDto.address(); + this.description = requestDto.description(); + this.weekdayOpenTime = requestDto.weekdayOpenTime(); + this.weekdayCloseTime = requestDto.weekdayCloseTime(); + this.weekendOpenTime = requestDto.weekendOpenTime(); + this.weekendCloseTime = requestDto.weekendCloseTime(); + this.storedCount = requestDto.storedCount(); + this.cityId = requestDto.cityId(); + } +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/exception/PlaceNotFoundException.java b/src/main/java/com/haejwo/tripcometrue/domain/place/exception/PlaceNotFoundException.java new file mode 100644 index 00000000..bfd1a699 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/exception/PlaceNotFoundException.java @@ -0,0 +1,13 @@ +package com.haejwo.tripcometrue.domain.place.exception; + +import com.haejwo.tripcometrue.global.exception.ApplicationException; +import com.haejwo.tripcometrue.global.exception.ErrorCode; + +public class PlaceNotFoundException extends ApplicationException { + private static final ErrorCode ERROR_CODE = ErrorCode.PLCAE_NOT_FOUND; + + public PlaceNotFoundException() { + super(ERROR_CODE); + } + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceCustomRepository.java b/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceCustomRepository.java new file mode 100644 index 00000000..79021e46 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceCustomRepository.java @@ -0,0 +1,12 @@ +package com.haejwo.tripcometrue.domain.place.repositroy; + +import com.haejwo.tripcometrue.domain.place.entity.Place; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface PlaceCustomRepository { + + Page findPlaceWithFilter(Pageable pageable, + Integer storedCount); + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceCustomRepositoryImpl.java b/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceCustomRepositoryImpl.java new file mode 100644 index 00000000..039e4a43 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceCustomRepositoryImpl.java @@ -0,0 +1,40 @@ +package com.haejwo.tripcometrue.domain.place.repositroy; + +import com.haejwo.tripcometrue.domain.place.entity.Place; +import com.haejwo.tripcometrue.domain.place.entity.QPlace; +import com.querydsl.core.BooleanBuilder; +import java.util.List; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport; + +public class PlaceCustomRepositoryImpl extends QuerydslRepositorySupport implements PlaceCustomRepository { + + public PlaceCustomRepositoryImpl() { + super(Place.class); + } + + @Override + public Page findPlaceWithFilter(Pageable pageable, Integer storedCount) { + + QPlace place = QPlace.place; + BooleanBuilder booleanBuilder = new BooleanBuilder(); + + if(storedCount != null && storedCount >= 0) { + booleanBuilder.and(place.storedCount.goe(storedCount)); + } + + List result = from(place) + .where(booleanBuilder) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + // 프론트의 Page 정보 필요 유무에 따라 응답 객체 List, Page 나뉨 + long total = from(place).where(booleanBuilder).fetchCount(); + + return new PageImpl<>(result, pageable, total); + + } +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceRepository.java b/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceRepository.java new file mode 100644 index 00000000..dda60097 --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/repositroy/PlaceRepository.java @@ -0,0 +1,11 @@ +package com.haejwo.tripcometrue.domain.place.repositroy; + +import com.haejwo.tripcometrue.domain.place.entity.Place; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PlaceRepository extends + JpaRepository, + PlaceCustomRepository +{ + +} diff --git a/src/main/java/com/haejwo/tripcometrue/domain/place/service/PlaceService.java b/src/main/java/com/haejwo/tripcometrue/domain/place/service/PlaceService.java new file mode 100644 index 00000000..528ee1cd --- /dev/null +++ b/src/main/java/com/haejwo/tripcometrue/domain/place/service/PlaceService.java @@ -0,0 +1,84 @@ +package com.haejwo.tripcometrue.domain.place.service; + +import com.haejwo.tripcometrue.domain.place.dto.request.PlaceRequestDTO; +import com.haejwo.tripcometrue.domain.place.dto.response.PlaceResponseDTO; +import com.haejwo.tripcometrue.domain.place.entity.Place; +import com.haejwo.tripcometrue.domain.place.exception.PlaceNotFoundException; +import com.haejwo.tripcometrue.domain.place.repositroy.PlaceRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Slf4j +public class PlaceService { + + private final PlaceRepository placeRepository; + + @Transactional + public PlaceResponseDTO addPlace(PlaceRequestDTO requestDto) { + + System.out.println(requestDto.storedCount()); + Place requestPlace = requestDto.toEntity(); + Place savedPlace = placeRepository.save(requestPlace); + System.out.println(savedPlace.getStoredCount()); + PlaceResponseDTO responseDto = PlaceResponseDTO.fromEntity(savedPlace); + + return responseDto; + + } + + @Transactional(readOnly = true) + public PlaceResponseDTO findPlace(Long placeId) { + + Place findPlace = findPlaceById(placeId); + + PlaceResponseDTO responseDto = PlaceResponseDTO.fromEntity(findPlace); + + return responseDto; + } + + @Transactional(readOnly = true) + public Page findPlaces(Pageable pageable, Integer storedCount) { + + Page findPlaces = placeRepository.findPlaceWithFilter(pageable, storedCount); + + Page result = findPlaces.map(PlaceResponseDTO::fromEntity); + + return result; + + } + + @Transactional + public PlaceResponseDTO modifyPlace(Long placeId, PlaceRequestDTO requestDto) { + + Place place = findPlaceById(placeId); + place.update(requestDto); + PlaceResponseDTO responseDto = PlaceResponseDTO.fromEntity(place); + + return responseDto; + } + + @Transactional + public void removePlace(Long placeId) { + Place findPlace = findPlaceById(placeId); + placeRepository.delete(findPlace); + } + + + + private Place findPlaceById(Long placeId) { + + Place findPlace = placeRepository.findById(placeId) + .orElseThrow(PlaceNotFoundException::new); + + return findPlace; + } + + + +} diff --git a/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java b/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java index 5525bd2b..4cde1bbe 100644 --- a/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java +++ b/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -23,6 +24,9 @@ public ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper(); // RestController에서 json 응답 시 null 값의 필드는 아예 보여주지 않도록 설정하는 부분 objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + // LocalTime, LocalDateTime 과 같은 시간관련 클래스의 직렬화, 역직렬화 포함한 클래스 설정을 추가 + objectMapper.registerModule(new JavaTimeModule()); + return objectMapper; } } diff --git a/src/main/java/com/haejwo/tripcometrue/global/exception/ErrorCode.java b/src/main/java/com/haejwo/tripcometrue/global/exception/ErrorCode.java index f348e923..55582bdf 100644 --- a/src/main/java/com/haejwo/tripcometrue/global/exception/ErrorCode.java +++ b/src/main/java/com/haejwo/tripcometrue/global/exception/ErrorCode.java @@ -23,6 +23,9 @@ public enum ErrorCode { // AUTH INVALID_PASSWORD(HttpStatus.BAD_REQUEST, "비밀번호가 틀렸습니다."), + // PLACE + PLCAE_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 여행지입니다."), + // 5xx INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버 내부 에러"); diff --git a/src/main/java/com/haejwo/tripcometrue/global/springsecurity/SpringSecurityConfig.java b/src/main/java/com/haejwo/tripcometrue/global/springsecurity/SpringSecurityConfig.java index 5de3fc4a..c9e992d5 100644 --- a/src/main/java/com/haejwo/tripcometrue/global/springsecurity/SpringSecurityConfig.java +++ b/src/main/java/com/haejwo/tripcometrue/global/springsecurity/SpringSecurityConfig.java @@ -56,6 +56,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http, .requestMatchers(HttpMethod.OPTIONS, "/basket/**").permitAll() // OPTIONS 메서드에 대한 권한 허용 */ .requestMatchers(new AntPathRequestMatcher("/login/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/v1/member/signup/**")).permitAll() + .requestMatchers(new AntPathRequestMatcher("/v1/places/**")).permitAll() .anyRequest().authenticated()); http.exceptionHandling(exceptionHandling -> {