Skip to content

Commit

Permalink
[BYOB-217] API 버전 분리 (#66)
Browse files Browse the repository at this point in the history
* feat: API prefix 설정 변경 및 관련 Spring Security 설정 변경

* refactor: SecurityConfig 사용하지 않는 필드 제거

* refactor: API 버전 분리를 위한 패키지 구조 변경

* refactor: API prefix 변경 관련 잘못 수정된 부분 검토
  • Loading branch information
y-ngm-n authored Oct 14, 2024
1 parent b1d5756 commit bdf5855
Show file tree
Hide file tree
Showing 78 changed files with 233 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@OpenAPIDefinition(servers = {
@Server(url = "/api/v1", description = "Default Server URL")
@Server(url = "/api", description = "Default Server URL")
})
@EnableJpaAuditing
@SpringBootApplication
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
import team_alcoholic.jumo_server.domain.auth.service.OAuth2UserService;
import team_alcoholic.jumo_server.v1.auth.service.OAuth2UserService;
import team_alcoholic.jumo_server.global.config.oauth2.CustomOAuth2SuccessHandler;
import team_alcoholic.jumo_server.global.config.oauth2.GetRedirectUrlFilter;

Expand All @@ -24,9 +23,6 @@ public class SecurityConfig {
private final CustomAuthenticationEntryPoint customAuthenticationEntryPoint;
private final CustomOAuth2SuccessHandler customOAuth2SuccessHandler;

@Value("${service.url}")
private String serviceUrl;

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

Expand All @@ -36,13 +32,17 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.httpBasic(AbstractHttpConfigurer::disable)
.addFilterBefore(new GetRedirectUrlFilter(), ChannelProcessingFilter.class) // 필터 체인의 맨 앞에 필터 추가
.oauth2Login(oauth2 -> oauth2
.authorizationEndpoint(authorization -> authorization
.baseUri("/v1/oauth2/authorization"))
.redirectionEndpoint(redirection -> redirection
.baseUri("/v1/login/oauth2/code/*"))
.userInfoEndpoint(userInfoEndpoint -> userInfoEndpoint.userService(oAuth2UserService))
.successHandler(customOAuth2SuccessHandler))
.exceptionHandling(exceptionHandling -> exceptionHandling
.authenticationEntryPoint(customAuthenticationEntryPoint)
)
.logout(logout -> logout
.logoutUrl("/logout")
.logoutUrl("/v1/logout")
.invalidateHttpSession(true)
.deleteCookies("SESSION")
.logoutSuccessHandler((request, response, authentication) -> {
Expand All @@ -51,6 +51,4 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
);
return http.build();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import team_alcoholic.jumo_server.domain.auth.dto.CustomOAuth2User;
import team_alcoholic.jumo_server.v1.auth.dto.CustomOAuth2User;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package team_alcoholic.jumo_server.domain.auth.dto;
package team_alcoholic.jumo_server.v1.auth.dto;

import lombok.RequiredArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.core.user.OAuth2User;
import team_alcoholic.jumo_server.domain.user.dto.UserOAuth2DTO;
import team_alcoholic.jumo_server.v1.user.dto.UserOAuth2DTO;

import java.io.Serial;
import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.auth.dto;
package team_alcoholic.jumo_server.v1.auth.dto;

import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.auth.dto;
package team_alcoholic.jumo_server.v1.auth.dto;

/**
* OAuth2 인증을 통해 받은 사용자 정보를 담는 DTO 인터페이스
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.auth.service;
package team_alcoholic.jumo_server.v1.auth.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -7,11 +7,11 @@
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import team_alcoholic.jumo_server.domain.auth.dto.KakaoResponse;
import team_alcoholic.jumo_server.domain.auth.dto.OAuth2Response;
import team_alcoholic.jumo_server.domain.auth.dto.CustomOAuth2User;
import team_alcoholic.jumo_server.domain.user.dto.UserOAuth2DTO;
import team_alcoholic.jumo_server.domain.user.service.UserService;
import team_alcoholic.jumo_server.v1.auth.dto.KakaoResponse;
import team_alcoholic.jumo_server.v1.auth.dto.OAuth2Response;
import team_alcoholic.jumo_server.v1.auth.dto.CustomOAuth2User;
import team_alcoholic.jumo_server.v1.user.dto.UserOAuth2DTO;
import team_alcoholic.jumo_server.v1.user.service.UserService;

/**
* OAuth2 서버에서 사용자 정보를 가져와 이를 사용하여 사용자 정보를 조회하거나 생성하고 세션에 등록하는 서비스
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package team_alcoholic.jumo_server.domain.health;
package team_alcoholic.jumo_server.v1.health;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;

@RestController
@RestController()
@RequestMapping("v1/health")
public class HealthCheckController {

@GetMapping("/health")
@GetMapping
public ResponseEntity<String> healthCheck() {
return ResponseEntity.ok("OK");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.liquor.controller;
package team_alcoholic.jumo_server.v1.liquor.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -7,17 +7,17 @@
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.*;
import team_alcoholic.jumo_server.domain.liquor.dto.LiquorPostDto;
import team_alcoholic.jumo_server.domain.liquor.dto.LiquorResDto;
import team_alcoholic.jumo_server.domain.liquor.service.LiquorService;
import team_alcoholic.jumo_server.domain.user.domain.User;
import team_alcoholic.jumo_server.domain.user.service.UserService;
import team_alcoholic.jumo_server.v1.liquor.dto.LiquorPostDto;
import team_alcoholic.jumo_server.v1.liquor.dto.LiquorResDto;
import team_alcoholic.jumo_server.v1.liquor.service.LiquorService;
import team_alcoholic.jumo_server.v1.user.domain.User;
import team_alcoholic.jumo_server.v1.user.service.UserService;
import team_alcoholic.jumo_server.global.error.exception.UnauthorizedException;

import java.util.Objects;

@RestController
@RequestMapping("liquors")
@RequestMapping("v1/liquors")
@RequiredArgsConstructor
public class LiquorController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package team_alcoholic.jumo_server.domain.liquor.domain;
package team_alcoholic.jumo_server.v1.liquor.domain;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import team_alcoholic.jumo_server.domain.tastingnote.domain.AiTastingNote;
import team_alcoholic.jumo_server.domain.tastingnote.domain.TastingNote;
import team_alcoholic.jumo_server.domain.user.domain.User;
import team_alcoholic.jumo_server.v1.tastingnote.domain.AiTastingNote;
import team_alcoholic.jumo_server.v1.tastingnote.domain.TastingNote;
import team_alcoholic.jumo_server.v1.user.domain.User;
import team_alcoholic.jumo_server.global.common.domain.BaseEntity;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.liquor.dto;
package team_alcoholic.jumo_server.v1.liquor.dto;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package team_alcoholic.jumo_server.domain.liquor.dto;
package team_alcoholic.jumo_server.v1.liquor.dto;

import lombok.Builder;
import team_alcoholic.jumo_server.domain.liquor.domain.Liquor;
import team_alcoholic.jumo_server.domain.tastingnote.dto.AiNotesResDTO;
import team_alcoholic.jumo_server.domain.user.dto.UserRes;
import team_alcoholic.jumo_server.v1.liquor.domain.Liquor;
import team_alcoholic.jumo_server.v1.tastingnote.dto.AiNotesResDTO;
import team_alcoholic.jumo_server.v1.user.dto.UserRes;

public record LiquorResDto(
Long id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.liquor.exception;
package team_alcoholic.jumo_server.v1.liquor.exception;


import team_alcoholic.jumo_server.global.error.exception.NotFoundException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package team_alcoholic.jumo_server.domain.liquor.repository;
package team_alcoholic.jumo_server.v1.liquor.repository;

import org.springframework.data.jpa.repository.JpaRepository;

import team_alcoholic.jumo_server.domain.liquor.domain.Liquor;
import team_alcoholic.jumo_server.v1.liquor.domain.Liquor;

public interface LiquorRepository extends JpaRepository<Liquor, Long> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package team_alcoholic.jumo_server.domain.liquor.service;
package team_alcoholic.jumo_server.v1.liquor.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import team_alcoholic.jumo_server.domain.liquor.domain.Liquor;
import team_alcoholic.jumo_server.domain.liquor.dto.LiquorPostDto;
import team_alcoholic.jumo_server.domain.liquor.dto.LiquorResDto;
import team_alcoholic.jumo_server.domain.liquor.exception.LiquorNotFoundException;
import team_alcoholic.jumo_server.domain.liquor.repository.LiquorRepository;
import team_alcoholic.jumo_server.domain.user.domain.User;
import team_alcoholic.jumo_server.v1.liquor.domain.Liquor;
import team_alcoholic.jumo_server.v1.liquor.dto.LiquorPostDto;
import team_alcoholic.jumo_server.v1.liquor.dto.LiquorResDto;
import team_alcoholic.jumo_server.v1.liquor.exception.LiquorNotFoundException;
import team_alcoholic.jumo_server.v1.liquor.repository.LiquorRepository;
import team_alcoholic.jumo_server.v1.user.domain.User;

import java.util.List;
import java.util.Random;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package team_alcoholic.jumo_server.domain.liquorsearch.controller;
package team_alcoholic.jumo_server.v1.liquorsearch.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import team_alcoholic.jumo_server.domain.liquorsearch.domain.LiquorES;
import team_alcoholic.jumo_server.domain.liquorsearch.service.LiquorSearchService;
import team_alcoholic.jumo_server.v1.liquorsearch.domain.LiquorES;
import team_alcoholic.jumo_server.v1.liquorsearch.service.LiquorSearchService;

import java.util.List;

@RestController
@RequestMapping("liquorsearch")
@RequestMapping("v1/liquorsearch")
@RequiredArgsConstructor
public class LiquorSearchController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.liquorsearch.domain;
package team_alcoholic.jumo_server.v1.liquorsearch.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package team_alcoholic.jumo_server.domain.liquorsearch.service;
package team_alcoholic.jumo_server.v1.liquorsearch.service;

import lombok.extern.slf4j.Slf4j;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch._types.FieldValue;
import org.opensearch.client.opensearch.core.SearchRequest;
import org.opensearch.client.opensearch.core.SearchResponse;
import org.opensearch.client.opensearch.core.search.Hit;
import org.springframework.stereotype.Service;
import team_alcoholic.jumo_server.domain.liquorsearch.domain.LiquorES;
import team_alcoholic.jumo_server.v1.liquorsearch.domain.LiquorES;

import java.io.IOException;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package team_alcoholic.jumo_server.domain.meeting.controller;
package team_alcoholic.jumo_server.v1.meeting.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import team_alcoholic.jumo_server.domain.meeting.dto.MeetingResDto;
import team_alcoholic.jumo_server.domain.meeting.dto.MeetingListResDto;
import team_alcoholic.jumo_server.v1.meeting.dto.MeetingResDto;
import team_alcoholic.jumo_server.v1.meeting.dto.MeetingListResDto;

import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package team_alcoholic.jumo_server.domain.meeting.controller;
package team_alcoholic.jumo_server.v1.meeting.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import team_alcoholic.jumo_server.domain.meeting.dto.MeetingResDto;
import team_alcoholic.jumo_server.domain.meeting.dto.MeetingListResDto;
import team_alcoholic.jumo_server.domain.meeting.service.MeetingService;
import team_alcoholic.jumo_server.v1.meeting.dto.MeetingResDto;
import team_alcoholic.jumo_server.v1.meeting.dto.MeetingListResDto;
import team_alcoholic.jumo_server.v1.meeting.service.MeetingService;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("meetings")
@RequestMapping("v1/meetings")
@RequiredArgsConstructor
public class MeetingController implements MeetingApi {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package team_alcoholic.jumo_server.domain.meeting.domain;
package team_alcoholic.jumo_server.v1.meeting.domain;

import jakarta.persistence.*;
import lombok.Getter;
import team_alcoholic.jumo_server.domain.region.domain.Region;
import team_alcoholic.jumo_server.v1.region.domain.Region;
import team_alcoholic.jumo_server.global.common.domain.BaseTimeEntity;

import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team_alcoholic.jumo_server.domain.meeting.domain;
package team_alcoholic.jumo_server.v1.meeting.domain;

import jakarta.persistence.*;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package team_alcoholic.jumo_server.domain.meeting.dto;
package team_alcoholic.jumo_server.v1.meeting.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import team_alcoholic.jumo_server.domain.meeting.domain.Meeting;
import team_alcoholic.jumo_server.v1.meeting.domain.Meeting;

import java.time.LocalDateTime;

Expand Down
Loading

0 comments on commit bdf5855

Please sign in to comment.