Skip to content

Commit

Permalink
builld: 운영 서버 배포 (#162)
Browse files Browse the repository at this point in the history
* chore: 이슈 템플릿 수정 (#7)

* chore: PR 템플릿 추가 (#7)

* chore: CI 설정 파일 작성 (#14)

* chore: CI 설정 파일 작성

* fix: ci-gradle.yml 내 JDK 11->17로 수정

* fix: actions workflow 토큰 변수 수정

* fix: ci-gradle.yml에 write 권한 허용

* chore: pull-request, issues, checks에 write 권한 부여

* feat: 프로젝트 기반 코드 작성 및 ERD 반영 (#12)

* feat: 결제 기능 구현 (#13)

* feat: Spring Security 인증 구현 (#16)

* feat: setup project for shopping

* Step 1, 2, 3 상품 조회, 로그인, 장바구니 기능 구현 (#10)

* docs: README 1단계 기능 명세 추가

* feat: 상품 entity, repository 추가

* test: TestFixture / createProductEntity 메서드 추가

* feat: ProductService / 상품 목록 조회 기능 작성

* test: 통합 테스트 작성

* refactor: 필드명 변경

* feat: data.sql 작성

* feat: ProductController 추가

* docs: README 2단계 기능 명세 추가

* fix: ProductIntegrationTest 수정

* test: User 통합 테스트 코드 추가

* feat: UserEntity 추가

* feat: data.sql 데이터 추가

* feat: UserRepository 추가

* feat: UserService 추가

* fix: UserEntity table 이름 수정

* feat: JwtProvider 추가

* feat: UserController 추가

* feat: 로그인 페이지 연동

* docs: README 3단계 기능 명세 추가

* feat: CartItemEntity 추가

* fix: token subject 변경

* refactor: 생성자 기본값 변경

* feat: CartItemRepository 추가

* feat: CartItemAddRequest 추가

* feat: 장바구니 아이템 추가 기능 구현

* feat: JwtProvider 검증, 파싱 메서드 추가

* feat: 인증 인터셉터, argument resolver 추가

* fix: Jwt parsing 메서드 변경

* fix: 정적파일 Interceptor 제외 항목에 추가

* feat: CartController 추가

* test: CartIntegrationTest 추가

* feat: CartItemRepository 추가

* feat: 장바구니 조회 기능 구현

* test: Fixture 메서드 추가

* feat: 장바구니 조회 기능 구현

* feat: 뷰 연결

* feat: 장바구니 상품 수정 기능 구현

* fix: 정적파일 예외 케이스 추가

* test: TestFixture 메서드 추가

* feat: CartController 업데이트 추가

* feat: 뷰 연결

* feat: 장바구니 상품 삭제 기능 추가

* feat: CartController 삭제 기능 작성

* feat: 뷰 연결

* feat: 커스텀 예외 작성

* refactor: GlobalControllerAdvice Response 형식 통일

* test: AuthInterceptor 테스트 추가

* test: CartIntegrationTest 테스트 추가

* docs: README 예외 사항 추가

* chore: 용어 변경(아이템 -> 상품)

* refactor: CartService 메서드 분리 및 예외 클래스 수정

* refactor: 로그 삭제

* refactor: 정적 팩토리 메서드 이름 변경

* refactor: 오타 수정

* refactor: 메서드 분리

* refactor: 상수 추출

* refactor: static 키워드 삭제

* refactor: 메서드 분리

* refactor: 메서드 인자 변경

* test: 테스트 수정

* fix: 장바구니 상품 수량이 0인 경우 상품 제거

* refactor: 패키지 분리

* refactor: 엔티티 클래스명 변경

* refactor: 컨트롤러 분리

* fix: 응답 코드 변경

* fix: 생성자, 상수 접근 제어자 변경

* refactor: 클래스, 메서드명 변경

* refactor: DTO 클래스에 final 키워드 설정

* refactor: 변수명 변경

* refactor: 메서드 통합

* refactor: 메서드명 변경

* refactor: 상수 접근 제어자 변경

* refactor: BeforeEach 로직 이동

* test: 통과하지 않는 테스트 수정

* test: 테스트 수정
- 응답이나 결과값을 더 자세히 확인하도록 함

* feat: Password 작성

* feat: Email 작성

* feat: Email 메서드 추가 및 패턴 변경

* fix: Password 패턴 변경

* refactor: Email, Password 도메인 객체를 사용하도록 변경

* test: 테스트 추가

* feat: Quantity 클래스 작성

* refactor: Quantity 객체를 사용하도록 변경, vo 패키지 생성

* test: 테스트 전후 설정 변경

* fix: 매직 넘버 상수화

* test: 서비스 계층 테스트 변경

* test: 통합 테스트 변경

* feat: 필수 항목 누락 검증 추가

* test: 널값 검증 테스트 추가

* refactor: 필드명 변경

* refactor: 필드명 변경

* docs: API 목록 추가

* docs: API 목록 추가

* docs: 주문 관련 요구사항 추가

* feat: OrderItem 엔티티 작성

* feat: Money 클래스 작성

* feat: Order 클래스 작성

* feat: OrderRepository 작성

* feat: OrderItemRepository 작성

* feat: 엔티티 상수, 메서드 추가

* feat: 주문 기능 구현

* fix: 오류 데이터 삭제

* refactor: 메서드명 변경

* refactor: 미사용 생성자 삭제

* fix: 로직 추가

* feat: 메서드 추가

* feat: 주문 상세 조회 구현

* feat: 주문 상세 페이지 연동

* feat: 주문 목록 조회 기능 구현

* refactor: DTO 이름 변경

* test: 테스트 변경

* refactor: URI 변경

* docs: 리드미 API 추가

* docs: 리드미 요구사항 작성

* feat: MoneyType 작성

* feat: ForeignCurrency 작성

* feat: ExchangeRate 작성

* feat: ExchangeRateProvider 작성

* feat: DefaultExchangeRateProvider 작성

* feat: OrderHistoryResponse 작성

* feat: 달러 변환 구현

* fix: 검증 조건 추가

* refactor: 의존성을 주입받도록 변경

* chore: 설정 추가

* refactor: mock 사용하지 않도록 변경

* fix: 검증 로직 추가

* test: 테스트 추가

* fix: 주문 시점의 환율 정보를 저장하도록 변경

* test: 테스트 추가

* test: 테스트 추가

* refactor: DollarMoney 필드 타입 변경

* refactor: 뷰 변경

* refactor: DTO 클래스명 변경

* refactor: PK 생성 전략 변경

* refactor: RestTemplate 설정 분리

* refactor: Money -> WonMoney 클래스명 변경

* refactor: 주문 생성 로직 변경

* refactor: 검증 로직 변경

* refactor: 패키지 구조 변경

* refactor: OrderItem / order 필드 제거

* refactor: user 간접 참조로 변경

* feat: OrderItem / product 간접 참조 생성

* refactor: 패키지 분리

* feat: BaseTimeEntity 작성

* feat: ERD 반영

* refactor: Member / 클래스명 변경

* refactor: lombok 사용하도록 변경

* refactor: 환율 기능 삭제

* refactor: DisplayName 변경

* refactor: RestTemplate timeout 변경

* refactor: 상수명 변경

* refactor: static import 변경

* refactor: 형식 통일

* refactor: final 키워드 추가

* style: 필드 간 줄바꿈 추가

* refactor: 어노테이션 클래스 단위로 변경

* test: 필드 접근 제어자 변경

* style: 코드 컨벤션 반영

* chore: validation 의존성 추가

* refactor: validator 삭제 및 validation 사용

* chore: h2 console 설정 추가

* refactor: not null 제약조건 추가

* test: DisplayName 변경

* test: 가독성을 위한 코드 리팩토링

* chore: spring security 의존성 변경

* feat: Jwt 인증 필터 등록

* fix: security filter 가 필요한 경로에만 동작하도록 설정 수정

* fix: springBoot 에 의해 필터가 두 번 등록되지 않도록 FilterRegistrationBean 등록

* feat: Jwt 인증 필터 구현

* fix: SecurityContext 설정 방식 변경

* refactor: jwt 토큰 검증 로직 추가

* test: JwtAuthenticationProvider 단위 테스트 작성

* test: jwt 인증 기능 통합 테스트 작성

* style: 구글 코드 컨벤션 적용

* refactor: 변수에 final 추가

* refactor: 시큐리티 필터 설정에 로그인 api 요청 허용하도록 추가

* refactor: principal 타입 변경

* style: 줄 간격 변경

* fix: mvc api 경로에 AntPathRequestMatcher 사용

* fix: 반환 값 변환 에러 수정

* feat: 인증 실패 시 ErrorResponse 반환하도록 설정

* refactor: Security Context 어노테이션 사용

* refactor: 상품 목록 인증 예외처리, 테스트 케이스 수정

* style: 컨벤션에 맞게 줄바꿈

* style: 컨벤션에 맞게 줄바꿈

* refactor: interceptor 제거하고 @AuthenticationPrincipal 적용

* fix: JwtProvider 를 JwtConfig 에서 빈으로 등록하도록 수정

* fix: RestAssured defaultParser 설정

* refactor: jwt 관련 기능을 common 으로 이동

* refactor: auth 패키지 구조화

* fix: JwtAuthentication equals, hashCode, toString 구현

* test: 결제 api 검증 시 헤더에 access token 추가

* fix: api 경로에 대해서만 인증 검사하도록 설정 수정

* feat: 존재하지 않는 memberId 로 요청 전송 시 예외 처리

---------

Co-authored-by: JoJo <buyongjo@gmail.com>
Co-authored-by: 건 <gunner6603@snu.ac.kr>

* feat: 데이터베이스 스키마 스크립트 추가 (#21)

* feat: Pay 엔티티에 시간 정보 추가

* test: jwt 인증 테스트에 memberRepository 모킹 추가

* refactor: Pay 금액에 WonMoney 값 객체 적용

* refactor: Order 엔티티에서 totalPrice 컬럼 제거

* refactor: OrderItem 테이블 이름 변경

* refactor: OrderItem.productName 을 name 으로 변경

* refactor: 테이블 이름 복수형으로 통일

* refactor: 빌더에서 값 객체 변환하도록 수정

* refactor: attribute override 로 속성값 변경

* feat: schema.sql 스크립트 생성

* refactor: memberId fk 제약조건 추가

* refactor: fk 제약조건 추가

* fix: description 타입을 longtext 로 변경 및 테이블 생성 순서 변경

* test: 결제 데이터 검증 로직 보강

* fix: description 타입을 clob 으로 변경

* test: order api 로부터 생성된 order id 를 사용하도록 수정

* feat: application properties 암호화 (#22)

* chore: application.properties 속성 값을 환경변수로부터 주입받도록 설정

* chore: github actions 수행 시 application.properties 속성 값 설정하도록 변경

* test: git action 으로부터 secret key 주입 여부 테스트

* refactor: github 시크릿 변수 읽어오도록 수정

* refactor: 테스트를 위해 ci 설정 임시 변경

* fix: uses 키워드 제거

* fix: environment 환경변수 사용을 위해 environment 설정 추가

* fix: environment 설정을 build 태그 하위로 위치 변경

* test: environment 태그에서 에러가 발생하는지 테스트

* test: 공백 제거해보기

* fix: gradle 상대 경로로 변경

* test: yml 설정 파일 수정

* chore: secret 출력 형식 변경

* chore: key 맵핑 형식 변경

* chore: jq 키 파싱 함수 수정

* chore: jq 키 파싱 함수 escape 처리

* chore: application.properties 설정 스크립트 수정

* chore: secrets 값 디코딩

* chore: "" 추가

* chore: ci-gradle.yml run 수정

* chore: ci-gradle.yml run 수정

* chore: ci-gradle.yml 에서 테스트 브랜치 제거

* test: 불필요한 테스트 제거

* feat: 회원가입 기능 구현 (#27)

* feat: 재고 기능 구현하기 (#23)

* test: StockTest '재고를 생성한다' 테스트

* feat: StockTest '재고를 생성한다' 구현

* test: StockTest '부적절한 값으로 재고를 생성할 때 예외가 발생한다' 테스트

* feat: StockTest '부적절한 값으로 재고를 생성할 때 예외가 발생한다' 구현

* feat: Product에 Stock 값 객체 추가

* test: JwtAuthenticationProviderTest 'JwtAuthenticationToken 인증에 성공한다' 테스트

* feat: 프론트에서 물품의 재고가 0일 때 장바구니 추가 버튼이 disabled 되는 기능 구현

* test: CartIntegrationTest '품절된 상품이면 장바구니 상품 추가를 요청했을 때 400 상태코드를 응답한다' 테스트

* test: StockTest '재고가 0일 시 품절 여부를 true, false로 반환한다' 테스트

* feat: StockTest '재고가 0일 시 품절 여부를 true, false로 반환한다' 구현

* feat: CartIntegrationTest '품절된 상품이면 장바구니 상품 추가를 요청했을 때 400 상태코드를 응답한다' 구현

* test: OrderIntegrationTest '품절된 상품을 포함해 주문을 요청했을 때 400 상태코드를 응답한다' 테스트

* refactor: Product에 validateStock 메서드 추가

* test: ProductTest '물품이 품절인지 검사한다' 테스트

* test: ProductTest '물품이 품절인지 검사할 때 품절이면 예외를 반환한다' 테스트

* test: CartItemTest '장바구니 아이템이 품절인지 검사한다' 테스트

* feat: CartItemTest '장바구니 아이템이 품절인지 검사한다' 구현

* feat: OrderIntegrationTest '품절된 상품을 포함해 주문을 요청했을 때 400 상태코드를 응답한다' 구현

* test: 테스트 보강

* fix: 빌드 에러 해결 및 gitignore에 application.properties 추가

* refactor: 사용하지 않는 ErrorCode 삭제

* feat: 주문 시 주문 수량과 물품 재고를 비교하는 검증 로직 추가

* test: StockTest '요청 수량과 재고 비교' 테스트

* test: ProductTest '주문 수량과 재고 비교' 테스트

* test: OrderIntegrationTest '주문을 요청했을 때 재고가 부족하면 400 상태코드를 응답한다' 테스트

* refactor: Stock의 수량 비교하는 메서드 이름 변경

* refactor: Product의 재고 확인 로직 이름 변경

* refactor: CartItem의 validateStock 메서드 이름 변경

* test: CartItemTest validateMemberHasId 메서드 테스트 추가

* fix: 테스트 환경 분리

* fix: JwtAuthenticationEntryPoint에서 response에 MediaType 추가

* refactor: OrderService의 검증 로직을 OrderItem으로 이동

* test: OrderItem 내 유효성 검증 로직 추가에 따른 OrderItemTest 테스트 추가

* fix: 테스트 데이터베이스 환경 분리

* refactor: Stock의 value를 wrapper type으로 변경

* refactor: 테스트 이름 변경ㅌ

* refactor: 필요없는 sql문 삭제

* feat: 상품 페이징 및 기본 정렬 (#33)

* test: 상품 목록 페이징 인수 테스트 작성

* test: 페이징 인수 테스트 수정

* feat: 상품 목록 페이징 구현

* test: 상품 기본 정렬 인수 테스트

* refactor: final 추가

* feat: 기본 정렬 설정

* test: 통합 테스트 검증 로직 수정

* refactor: 총 몇 개의 페이지가 있는지 응답하도록 수정

* test: 테스트 데이터 파싱 방법 수정

* refactor: 상품 조회 기능과 상품 페이지 조회 컨트롤러를 분리

* fix: SecurityConfig 에 상품 조회 경로 추가

* feat: 수정된 api 와 화면 연동

* test: 화면 테스트 제거

* test: 테스트 인증 수정

* refactor: 페이징 결과 dto 수정

* test: 페이징 dto 변화에 따라 테스트 수정

* refactor: 상품 조회 화면 수정

* config: 테스트 환경변수 분리 (#37)

* test: 테스트 환경 분리

* chore: application.properties 추가

* chore: properties 를 yml 로 변경, 실행 환경 별로 분리

* chore: maria db dialect 설정

* fix: clob 데이터 저장 타입 수정

* fix: clob 을 text 로 변경

* chore: application.properties 생성하지 않도록 빌드 스크립트 수정

* refactor: final 추가

* test: 테스트 구체화

* feat: 결제 기능 회원, 주문 기능과 연동 (#31)

* feat: 결제 기능 일부 구현

* feat: API 뷰 연동

* refactor: 패키지명 변경

* refactor: 가독성을 위한 리팩토링

* fix: Pay 생성 로직 변경

* fix: 에러 코드 변경

* refactor: 주문 이름 생성 로직 변경

* fix: 재고 감소 로직 수정

* test: 단위 테스트 작성

* test: 통합 테스트 작성

* fix: url 경로 변경

* test: 응답 로그를 출력하도록 변경

* fix: 오타 제거

* comment: 주석 제거

* refactor: 리포지토리 메서드 변경

* refactor: 매직 넘버 상수화

* remove: WebMvcConfig 삭제

* refactor: RequestMapping 추가

* refactor: 패키지 추가

* fix: null 확인 로직 추가

* refactor: 리포지토리 메서드명 변경

* style: 줄바꿈 추가

* refactor: 메서드명 변경

* refactor: final 키워드 추가

* refactor: 리포지토리 메서드 생성 및 로직 변경

* comment: 주석 삭제

* fix: conflict 해결

* refactor: WonMoney 를 Money 로 변경 (#47)

* refactor: WonMoney 를 Money 로 수정 및 validation 추가

* test: 테스트 메서드 이름 수정

* test: Money 생성 성공 테스트 추가

* refactor: println 제거

* test: ErrorCode 검증 추가

* refactor: MoneyTest '금액은 0보다 작을 수 없다' 테스트 코드 수정

---------

Co-authored-by: sen <seeunchoi99@gmail.com>

* feat:프론트의 로그인 회원가입 인증 수정 (#49)

* fix: 장바구니 메뉴 들어갈 때 로그아웃 되는 현상 수정

* feat: 로그인 시 로그아웃 버튼, 로그아웃 상태시 로그인 및 회원가입 버튼이 보임

* fix: 로그인 시 에러 메시지 정상 처리 (#50)

* feat: 상품 조회 페이징 프론트에 반영 (#51)

* feat: 상품 조회 페이징 프론트에 반영

* fix: EOL 설정

* fix: 마지막 페이지 볼 수 있도록 조건 수정

* refactor: 존재하지 않는 것에 대한 상태코드 404로 수정 (#52)

* test: 테스트 내 반복적인 회원가입 단순한 메소드로 변경 (#53)

* refactor: 중복된 signUp 과 login 호출을 메서드로 분리

* refactor: 불필요한 email, password 변수 선언을 제거하고 파라미터로 바로 전달

* refactor: api 관련 테스트 메서드를 ApiUtils 로 분리

* refactor: 테스트 domain 생성 메서드를 DomainUtils 로 분리

* refactor: signUp 과 login 메서드를 ApiUtils 로 이동

* refactor: util 메서드 적용

* feat: 상품 검색 및 정렬 기능 구현 (#54)

* test: ProductIntegrationTest '검색어로 검색한 결과를 최신순으로 정렬하여 반환한다' 테스트

* chore: application.yml 설정 분리

dev, prod, test로 분리

* feat: ProductIntegrationTest '검색어로 검색한 결과를 최신순으로 정렬하여 반환한다' 구현

* test: ProductIntegrationTest '검색어로 검색한 결과를 가격이 비싼순으로 정렬하여 반환한다' 테스트

* feat: ProductIntegrationTest '검색어로 검색한 결과를 가격이 비싼순으로 정렬하여 반환한다' 구현

* feat: ProductIntegrationTest '검색어로 검색한 결과를 가격이 비싸지 않은 순으로 정렬하여 반환한다' 구현

* refactor: 존재하지 않는 것에 대한 상태코드 404로 수정 (#52)

* test: 테스트 내 반복적인 회원가입 단순한 메소드로 변경 (#53)

* refactor: 중복된 signUp 과 login 호출을 메서드로 분리

* refactor: 불필요한 email, password 변수 선언을 제거하고 파라미터로 바로 전달

* refactor: api 관련 테스트 메서드를 ApiUtils 로 분리

* refactor: 테스트 domain 생성 메서드를 DomainUtils 로 분리

* refactor: signUp 과 login 메서드를 ApiUtils 로 이동

* refactor: util 메서드 적용

* test: ProductIntegrationTest '검색어로 검색한 결과를 최신순으로 정렬하여 반환한다' 테스트

* chore: application.yml 설정 분리

dev, prod, test로 분리

* feat: ProductIntegrationTest '검색어로 검색한 결과를 최신순으로 정렬하여 반환한다' 구현

* test: ProductIntegrationTest '검색어로 검색한 결과를 가격이 비싼순으로 정렬하여 반환한다' 테스트

* feat: ProductIntegrationTest '검색어로 검색한 결과를 가격이 비싼순으로 정렬하여 반환한다' 구현

* feat: ProductIntegrationTest '검색어로 검색한 결과를 가격이 비싸지 않은 순으로 정렬하여 반환한다' 구현

* refactor: 기존 코드에 맞게 ProductIntegrationTest의 테스트 코드 수정

* style: static 삭제

* style: 컨벤션에 맞게 인덴트 수정

* test: ProductIntegrationTest '빈 문자열의 키워드로 검색하면 에러를 반환한다' 테스트

* feat: ProductIntegrationTest '빈 문자열의 키워드로 검색하면 에러를 반환한다' 구현

* test: ProductIntegrationTest '키워드 없이 검색하면 에러를 반환한다' 테스트

* feat: ProductIntegrationTest '키워드 없이 검색하면 에러를 반환한다' 구현

* style: GlobalControllerAdvice 변수 이름 수정

* fix: ProductIntegrationTest '검색어로 검색한 결과를 최신순으로 정렬하여 반환한다'에서 결과를 최신순인지 검증하도록 변경

---------

Co-authored-by: dongjoo <46925347+dongjoo0-0@users.noreply.github.com>
Co-authored-by: rimrim990 <62409503+rimrim990@users.noreply.github.com>

* refactor: OrderName 생성 로직 가독성 개선 (#56)

* refactor: OrderName 생성 로직 가독성 개선

* refactor: 상수 private 화 및 size 내부 체크

* refactor: 도메인 내 VO 외부에서 생성 후 주입 (#57)

* refactor: Member Email VO 외부에서 주입

* refactor: Member Nickname VO 외부에서 주입

* refactor: CartItem Quantity VO 외부에서 주입

* refactor: Product Quantity, Money VO 외부에서 주입

* refactor: CartItem, Member 생성자 생략

* refactor: Pay Money VO 외부에서 주입

* fix: confict 해결

* style: final 추가 및 가독성 개선

* fix: conflict 수정 및 새로운 테스트 픽스쳐에 vo 주입 로직 적용

* refactor: 결제 실패시 주문 페이지로 이동하도록 변경 (#59)

* test: 통합테스트 코드 작성

* feat: 결제 실패시 orderId 디코딩 기능 구현

* feat: 결제 실패 페이지 연동

* style: 400 상태코드 오타 500으로 수정

* fix: 회원가입 페이지 오타 수정

* feat: 로깅 추가 (#64)

* feat: getMessage 오버라이드

* feat: stacktrace 기반으로 에러 로깅하도록 변경

* feat: 외부 API 호출 시 로깅하도록 변경

* refactor: 로깅 줄바꿈 삭제

* feat: 로깅 설정 추가

* fix: 로깅 조건 변경

* refactor: 메서드명 변경

* feat: HTTP 요청, 응답 로깅 추가

* fix: 장바구니에 담긴 물품이 없을 때 /null 로 이동하는 현상 해결  (#66)

* fix: 장바구니 주문 시 에러 처리 추가

* refactor: 프론트에서 response.ok 활용하도록 변경

* test: data.sql 삭제 및 테스트 격리 (#63)

* refactor: 중복된 signUp 과 login 호출을 메서드로 분리

* refactor: 불필요한 email, password 변수 선언을 제거하고 파라미터로 바로 전달

* refactor: api 관련 테스트 메서드를 ApiUtils 로 분리

* refactor: 테스트 domain 생성 메서드를 DomainUtils 로 분리

* refactor: signUp 과 login 메서드를 ApiUtils 로 이동

* refactor: util 메서드 적용

* delete: data.sql 제거

* fix: repository 사용하여 product 정보 생성하도록 수정

* fix: 새로 추가된 테스트 케이스에 product repository 사용하도록 적용

* refactor: 여러 개의 상품 생성하는 메서드 분리

* refactor: 테스트 메서드 종료 하면 데이터 초기화를 위해 clean.sql 실행

* refactor: 미사용 메서드 제거

* refactor: final 추가

* refactor: 중복된 Product 생성을 DomainUtils 로 이동

* refactor: final 추가

* refactor: testEventListener 에서 truncate 쿼리를 실행하여 데이터 초기화하도록 수정

* fix: encodedOrderId 64자 이내로 제한 (#68)

* chore: 기본 이미지 추가 (#70)

* chore: 기본 이미지 추가

* chore: 기본 이미지 변경

---------

Co-authored-by: dahyen0o <seeunchoi99@gmail.com>

* feat: 상품 검색 및 정렬 페이지 구현 (#67)

* feat: 메인 페이지의 검색창 구현

* feat: 검색 결과 페이지 구현

* feat: 검색 결과 페이지의 정렬 기능 구현

* fix: 기본 데이터베이스 설정 추가

* feat: 검색 결과 페이지의 페이지네이션 구현

* fix: 오타 삭제

* build: Jacoco로 테스트 커버리지 측정 (#72)

* build: jacoco 테스트 커버리지 측정 추가

* build: PR에 코멘트로 등록하도록 설정

* fix: jacoco 코멘트 설정 변경

* feat: 장바구니 물품이 품절이면 페이지에 품절 표시 (#71)

* feat: 상품 상세 조회 페이지 구현 (#73)

* refactor: 중복된 signUp 과 login 호출을 메서드로 분리

* refactor: 불필요한 email, password 변수 선언을 제거하고 파라미터로 바로 전달

* refactor: api 관련 테스트 메서드를 ApiUtils 로 분리

* refactor: 테스트 domain 생성 메서드를 DomainUtils 로 분리

* refactor: signUp 과 login 메서드를 ApiUtils 로 이동

* refactor: util 메서드 적용

* delete: data.sql 제거

* fix: repository 사용하여 product 정보 생성하도록 수정

* fix: 새로 추가된 테스트 케이스에 product repository 사용하도록 적용

* refactor: 여러 개의 상품 생성하는 메서드 분리

* refactor: 테스트 메서드 종료 하면 데이터 초기화를 위해 clean.sql 실행

* refactor: 미사용 메서드 제거

* refactor: final 추가

* refactor: 중복된 Product 생성을 DomainUtils 로 이동

* test: 상품 상세 조회 API 인수 테스트

* feat: 상품 상세 조회 API 구현

* feat: 상품 상세 조회 시 상품이 존재하지 않을 때 예외 처리

* feat: 상품 상세 페이지 연동

* refactor: 페이지 UI 수정

* refactor: final 추가

* delete: clean.sql 과 sql 어노테이션 제거

* refactor: 사용되지 않는 pay 기능 제거

* feat: Dockerfile 작성 (#78)

* feat: CD 자동화 (#79)

* feat: workflow 파일 작성

* Update cd.yml

* fix: step 변경

* feat: 별점 기능 구현 (#81)

* feat: rate 스키마 생성

* refactor: OrderItemResponse 에 id 와 productId 추가

* test: 별점 생성 기능 인수 테스트

* test: 별점 생성 시의 입력 검증 인수 테스트 보강

* feat: 별점 생성 검증 기능 구현

* feat: 별점 범위 검증 구현

* fix: Transactional 추가

* test: 결제되지 않은 주문에 별점 생성 여부 검증 테스트

* refactor: 유효한 별점 범위를 상수로 분리

* feat: 결제되지 않은 상품에 대한 별점 생성을 예외 처리

* test: 별점 조회 기능 인수 테스트

* config: 별정 정보 경로가 jwt 시큐리티 필터 통과하도록 수정

* feat: 상품 별점 조회 기능 구현

* refactor: 소수점 버림

* refactor: 중복된 메서드 분리

* refactor: rate 생성을 위한 테스트 api 를 ApiUtils 이동

* refactor: mockServer 를 ApiUtils 로 이동

* refactor: 줄바꿈 변경

* refactor: final 추가

* refactor: final 추가 & dto validation 제거

* refactor: private 추가

* refactor: 미사용 변수 제거

* refactor: OrderItemResponse 에서 productId 제거

* refactor: averageRate 계산을 별도 메서드로 분리

* refactor: mock server 요청 처리 횟수 조정

* refactor: round 를 floor 로 변경

* fix: 자동 배포시 컨테이너 실행 실패하는 문제 해결 (#86)

* fix: workflow 파일 변경

* fix: path 삭제

* fix: Dockerfile 변경

* fix: Dockerfile 변경

* fix: workflow 파일 변경

* feat: 포인트샵 충전 및 결제 기능 구현 (#82)

* test: 포인트 통합 테스트 작성

* test: 포인트 결제 통합 테스트와 토스 결제 통합 테스트 분리

* test: 포인트 dto 생성

* refactor: 기존 결제 dto 전부 토스 dto로 구분

* refactor: 기존 테스트 통과하도록 api endpoint 설정

* feat: Point 도메인 객체 구현

* style: final 추가, 네이밍 수정

* fix: 테이블 생성 및 BaseTimeEntity 추가

* feat: 포인트 충전 기능 구현

* refactor: Point에서 Money 객체 제거

* feat: 포인트 결제 기능 구현

* feat: 포인트로 결제 페이지 구현

* fix: 포인트 저장되도록 수정

* feat: 포인트 충전 페이지 구현 및 프론트 페이지 오류 수정

* fix: 포인트 결제 후 장바구니 아이템 삭제

* feat: 프론트 페이지 연동

* refactor: 테스트 보강 및 가독성 개선

* fix: 프론트 수정

* refactor: 프론트 꾸미기

* refactor: 토스 결제 승인 요청 /toss/validate로 변경

* style: 팝업이 아니므로 이름 변경

* style: 포인트 결제 포괄적인 이름으로 변경

* refactor: catchException -> assertThrows로 변경

* refactor: 인수테스에서 order history 조회 확인

* refactor: point 값 Money VO로 래핑

* refactor: Validation 추가해서 0 이하 포인트 충전을 차단

* style: final, private 붙임

* style: EOL 삭제

* style: final 추가

* style: private, method 분리

* feat: 상품 검색 결과를 주문순으로 정렬 (#80)

* feat: 별점 기능 화면 연동 (#85)

* feat: 별점 조회 연동

* refactor: 미사용 pay 기능 제거

* feat: 별점 남기기 버튼 추가

* feat: rate-pop 연동

* fix: order-history 디테일 경로 수정

* fix: 별점 Pop-up 경로 수정

* feat: 에러 로그 메시지 출력

* feat: range input 값 출력

* refactor: 에러 코드 이름 수정

* test: 사용자가 남긴 별점 조회 기능 인수 테스트

* feat: 사용자가 남긴 별점 정보 조회 API 구현

* feat: 별점을 이미 남겼을 때는 이전에 남긴 별점을 보여주는 기능 구현

* feat: 에러가 발생했을 경우 뒤로 가도록 수정

* fix: 각 주문 상품에 별도로 별점을 적용할 수 있도록 수정

* refactor: @PathVariable 을 상위로 올림

* refactor: response dto 생성자를 제거하고 from 메서드 생성

* refactor: 중복된 fetch 를 메서드로 분리

* refactor: final 추가

* refactor: 주문 정보가 존재하지 않을 때 에러 메시지 수정

* refactor: rate 패키지 분리 (#89)

* fix: 배포 시간 단축 (#94)

* feat: 캐시 적용

* style: 줄바꿈 삭제

* Update ErrorCode.java

* fix: 캐시 제거 및 아키텍처 1개만 빌드

* fix: workflow 파일 변경

* Revert "fix: workflow 파일 변경"

This reverts commit ea1c304.

* fix: workflow 파일 변경

* refactor: 결제와 주문 리팩토링 (#98)

* refactor: OrderStatus 세분화

* refactor: 결제 요청 시 Order에서 재고 차감 및 status 업데이트

* refactor: 결제 요청에 PayType 추가

* refactor: 주문 시작 프론트 연동

* test: 토스 결제 인수 테스트

* refactor: 토스 API 대대적 수정

* refactor: 프론트 페이지 연동

* refactor: 사용하지 않는 클래스 제거

* refactor: 결제 완료시 하는 작업 한 메소드로 관리

* refactor: 토스 관련 설정 분리

* refactor: DB 스키마 적용

* refactor: OrderStatus를 매번 검증해준다

* refactor: login api를 변경

* refactor: 장바구니 수량 수정 api 변경

* refactor: api 문서와 통일

* refactor: 재고 부족 에러 메시지 통일

* fix: 결제 수단 정보를 NOT NULL로 수정

* refactor: 결제 중 상태 PAYING으로 변경

* style: Order 상태 변경하는 메소드 네이밍 변경

* refactor: validateMoney 및 Enum type 수정

* refactor: 시큐리티 principal 정보 수정 (#110)

* chore: 스키마 member 테이블에 gender와 birth_date 컬럼 추가

* refactor: member 테이블에 gender와 birth_date 컬럼 추가에 따른 코드 수정

* refactor: 시큐리티에서 id 가 아닌 MemberPrincipal 을 반환하도록 수정

* fix: AuthenticationPrincipal 할당 타입을 MemberPrincipal 로 변경

* refactor: MemberPrincipal 에 member 정보 추가

* refactor: 성별, 년도를 회원가입 페이지와 연동

* test: jwt principal 테스트 보강

* refactor: final 추가

* refactor: toString 제거

* refactor: ux 수정

---------

Co-authored-by: dahyen0o <seeunchoi99@gmail.com>

* 106 별점 높은순 정렬 구현 (#113)

* feat: 별점 높은 순 프론트 페이지 구현

* feat: 별점 높은 순 정렬 기능 구현

* refactor: Sortkey 활용

* style: 테스트 이름 변경

* refactor: rate에 memberId 삭제 (#115)

* feat: 나이대 정보와 생년월일 변환 로직 구현 (#117)

* feat: 나이대 정보와 생년월일 변환 로직 구현

* fix: 마지막 일 더하지 않음

* feat: 주문 목록 페이지네이션 (#118)

* refactor: createdAt 정렬을 id 정렬로 변경

* refactor: OrderHistory API 페이징 적용

* test: 상품 검색 단위 테스트에서 사용되는 createdAt 을 id 로 변경

* fix: merge conflict 해결

* refactor: 사용되지 않는 메서드 제거

* fix: ORDER_COUNT 를 Order_Count_DESC 로 변경

* feat: 페이지네이션을 화면과 연동

* fix: order 페이징 시에 메모리에서 페이징되는 이슈 해결

* refactor: 로그인 화면 영문 변경 (#126)

* refactor: 상품 상세 페이지에 전부 접근 가능 (#124)

* feat: 통계 테이블 스키마 작성 (#122)

* feat: 통계 테이블 스키마 작성

* feat: 엔티티 작성

* fix: 스키마 수정

* fix: 엔티티 수정

* feat: 리포지토리 작성

* fix: 제약조건 추가

* fix: 테이블명 변경

* fix: 어노테이션 삭제

* feat: 데이터 생성 로직 작성

* feat: 현재 접속한 회원과 성별 및 나이대가 같은 주문들의 평균 별점 조회 기능 구현 (#123)

* refactor: 토스 결제 시 필요없는 데이터 제거 (#120)

* refactor: 회원가입시 나이 제약조건 추가 (#119)

* refactor: 회원가입시 나이 제약조건 추가

* fix: 테스트 수정

* fix: 시작일을 포함하도록 제약 조건을 수정한다 (#133)

* feat: 주기적 미결제 주문 취소 기능 구현 (#101)

* feat: 스케줄링 설정 추가

* feat: 리포지토리 메서드 추가

* feat: 리포지토리 메서드 추가

* feat: 메서드 추가

* feat: 서비스 메서드 추가

* feat: 주문 취소 스케줄링 로직 작성

* chore: 테스트를 위한 설정 추가

* fix: 리포지토리 메서드 변경

* fix: 메서드 트랜잭션 전파 수준 변경

* feat: 메서드 추가

* feat: 테스트 유틸 메서드 작성

* test: 테스트 작성

* fix: 여러 개 주문 취소 중 에러가 발생하면 재고를 복구한 주문이 미취소 상태가 되는 문제 해결

* test: 테스트 클래스 병합

* chore: 스키마 파일에 인덱스 추가

* fix: 생성 상태 주문의 경우 재고를 복구하지 않도록 변경

* test: 테스트 추가

* test: 테스트 유틸 메서드 추가

* test: 단위 테스트 추가

* feat: 상품 전체 조회 시 필터링 추가 (#130)

* feat: 통계 테이블 스키마 작성

* feat: 엔티티 작성

* fix: 스키마 수정

* fix: 엔티티 수정

* feat: 리포지토리 작성

* fix: 제약조건 추가

* fix: 테이블명 변경

* fix: 어노테이션 삭제

* feat: 데이터 생성 로직 작성

* feat: enum 컨버터 작성 및 설정 추가

* feat: 컨트롤러 메서드 작성

* feat: 리포지토리 메서드 작성

* feat: 도메인 작성

* feat: 서비스 메서드 작성 및 리팩토링

* feat: 테스트 작성

* fix: 어노테이션 제거

* test: 사용하지 않는 변수 제거

* feat: 통계 테이블 업데이트 로직 작성 (#137)

* feat: 통계 테이블 스키마 작성

* feat: 엔티티 작성

* fix: 스키마 수정

* fix: 엔티티 수정

* feat: 리포지토리 작성

* fix: 제약조건 추가

* fix: 테이블명 변경

* fix: 어노테이션 삭제

* feat: 데이터 생성 로직 작성

* feat: enum 컨버터 작성 및 설정 추가

* feat: 컨트롤러 메서드 작성

* feat: 리포지토리 메서드 작성

* feat: 도메인 작성

* feat: 서비스 메서드 작성 및 리팩토링

* feat: 테스트 작성

* fix: 어노테이션 제거

* feat: 현재 접속한 회원과 성별 및 나이대가 같은 주문들의 평균 별점 조회 기능 구현 (#123)

* feat: 리포지토리 메서드 작성

* feat: 별점 생성 메서드에 업데이트 로직 추가

* feat: 결제 메서드에 업데이트 로직 추가

* feat: 컨트롤러 변경

* fix: 버그 회피

* test: 유틸 메서드 추가

* test: 테스트 변경

* fix: 결제 로직 순서 변경

* style: 줄바꿈 변경

* fix: final 키워드 추가

---------

Co-authored-by: sen <64001680+dahyen0o@users.noreply.github.com>

* fix: 재고 감소 트랜잭션에 락 추가 (#103)

* fix: 재고 감소 트랜잭션에 락 추가

* fix: Order 조회 시에 비관적 락 추가, 주문이 취소되었는지 상태 검증하는 로직 추가

* refactor: final 추가

* feat: 상품 추천 기능 구현 (#134)

* test: 함께 구매한 상품 추천 기능 인수 테스트

* feat: 함께 구매한 상품 추천 기능 구현

* refactor: 구매 수가 같으면 최근에 생성된 상품이 먼저 조회되도록 수정

* feat: 추천 상품 페이징 적용

* fix: count 쿼리 작성
- JPA 에서 자동 생성한 count 쿼리에서는 syntax 에러가 발생

* feat: 추천 상품 화면 연동

* refactor: 페이징 응답을 Slice 로 변경

* refactor: slice 페이징을 화면과 연동

* refactor: 불필요한 countQuery 제거

* delete: 사용되지 않는 클래스 제거

* refactor: 상위 30개의 상품만 보여주도록 프론트 수정

* fix: 추천 상품 정렬 기준 수정

* refactor: 별점 높은 순 정렬에 countQuery를 적용한다 (#140)

* feat: 물품 상세 페이지에 현재 접속한 유저에 따른 평균 별점 항목 추가 (#136)

* refactor: PayService가 OrderService를 참조하도록 리팩토링 (#144)

* refactor: 별점 & 상품 조회에 통계 테이블 적용 (#145)

* feat: stats 테이블에 인덱스 추가

* refactor: Product repository 에 stats 적용

* refactor: Rate repository 에 stats 적용

* test: DomainUtils 적용

* test: 테스트에 주문 통계 적용

* refactor: final 추가

* refactor: Product repository 에 stats 적용

* refactor: StatsUtils 적용

* fix: join 조건 명시

* test: 통합 테스트에 stats 연동

* refactor: 정렬 수정

* refactor: 오타 수정

* refactor: StatsUtils 에서 LocalDate 타입을 BirthYearRange 로 수정

* test: 테스트에 연령, 성별 통계 정보 추가

* 142 성별 나이별 검색 필터링 기능 프론트 연동 (#147)

* feat: 필터링 기능 프론트 반영

* refactor: 검색바 분리

* chore: 테스트 불가능한 코드를 Jacoco 검사에서 제외 (#143)

* 148 모니터링 대시보드 구축 (#153)

* config: actuator prometheus 추가

* config: prometheus 포트 설정 추가

* fix: 페이지 flex 제거 (#151)

* test: 테스트 커버리지 높이기 (#154)

* test: 테스트 추가

* test: 테스트 추가

* test: 테스트 추가

* test: 테스트 추가

* refactor: PayType from 메서드 삭제

* test: 테스트 추가

* test: 테스트 수정

* chore: jacoco 설정 변경

* test: 테스트 추가

* fix: 불필요한 로그 제거

* test: 테스트 추가

* refactor: 중복 인덱스 제거 및 재배치 (#155)

* feat: 물품 주문자들의 성별 및 나이대별 평균 별점 구현 (#161)

* config: docker 포트 오픈 (#158)

* feat: 프론트에 api 추가하기 (#159)

* refactor: ProductDetailResponse 에 stock 정보 추가

* feat: 상품 상세 페이지에 장바구니 기능 추가

* feat: 상품 상세 페이지에 검색 기능 추가

* refactor: 주문 목록 페이지에 css 적용

* favicon 추가

* title 변경

* css: 메인 컬러 변경

* refactor: 차트 색상 변경

---------

Co-authored-by: sen <64001680+dahyen0o@users.noreply.github.com>
Co-authored-by: 건 <gunner6603@snu.ac.kr>
Co-authored-by: rimrim990 <62409503+rimrim990@users.noreply.github.com>
Co-authored-by: JoJo <buyongjo@gmail.com>
Co-authored-by: sen <seeunchoi99@gmail.com>
  • Loading branch information
6 people committed Aug 30, 2023
1 parent 607cc15 commit c0c9363
Show file tree
Hide file tree
Showing 230 changed files with 13,450 additions and 15 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 도커 이미지 빌드 후 도커 허브에 배포

on:
push:
branches:
- develop

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/arm64
push: true
tags: gunner6603/shopping-dev:latest
72 changes: 72 additions & 0 deletions .github/workflows/ci-gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Gradle로 CI 구축

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]

permissions:
contents: read
pull-requests: write
issues: write
checks: write

jobs:
build:

runs-on: ubuntu-latest
environment: shopping-mall-secrets

steps:
- uses: actions/checkout@v3
- name: JDK 17 설정
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew

- name: 프로젝트 빌드 및 테스트
run: ./gradlew clean build

- name: 테스트 결과를 PR에 코멘트로 등록
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: '**/build/test-results/test/TEST-*.xml'

- name: 테스트 커버리지를 PR에 코멘트로 등록합니다
if: always()
id: jacoco
uses: madrapps/jacoco-report@v1.2
with:
title: 📝 테스트 커버리지 리포트입니다
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: 테스트 실패 시, 실패한 코드 라인에 Check 코멘트를 등록
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
token: ${{ secrets.GITHUB_TOKEN }}

- name: 빌드 실패 시 Slack으로 알림
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 빌드 실패 알림
fields: repo, message, commit, author, action, eventName, ref, workflow, job, took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ FROM eclipse-temurin:17-jre
WORKDIR /app
COPY --from=builder /app/build/libs/shopping-0.0.1-SNAPSHOT.jar /app/app.jar
EXPOSE 8080
EXPOSE 9098
ENTRYPOINT ["java", "-jar", "/app/app.jar", "--spring.profiles.active=${SPRING_PROFILES_ACTIVE}"]
38 changes: 37 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.2'
id 'io.spring.dependency-management' version '1.1.2'
id 'jacoco'
}

group = 'com.gugucon'
Expand All @@ -11,6 +12,33 @@ java {
sourceCompatibility = '17'
}

jacoco {
toolVersion = '0.8.8'
}

test {
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn(test)
reports {
html.required.set(true)
xml.required.set(true)
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"com/gugucon/**/*DTO.*",
"com/gugucon/**/*Scheduler.*",
"com/gugucon/**/*PageController.*",
"com/gugucon/**/ShoppingApplication.*",
"**/config/*"
])
}))
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand All @@ -25,13 +53,21 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.security:spring-security-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'dev.akkinoc.spring.boot:logback-access-spring-boot-starter:4.0.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.3.1'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured:5.3.1'
}

tasks.named('test') {
Expand Down
4 changes: 4 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This will add the @lombok.Generated annotation
# to all the code generated by Lombok,
# so it can be excluded from coverage by jacoco.
lombok.addLombokGeneratedAnnotation = true
2 changes: 2 additions & 0 deletions src/main/java/com/gugucon/shopping/ShoppingApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@ConfigurationPropertiesScan
@SpringBootApplication
public class ShoppingApplication {

Expand Down
79 changes: 79 additions & 0 deletions src/main/java/com/gugucon/shopping/auth/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.gugucon.shopping.auth.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.gugucon.shopping.auth.security.JwtAuthenticationEntryPoint;
import com.gugucon.shopping.auth.security.JwtAuthenticationFilter;
import com.gugucon.shopping.auth.security.JwtAuthenticationProvider;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

@Configuration
@RequiredArgsConstructor
public class SecurityConfig {

private final ObjectMapper objectMapper;
private final JwtAuthenticationProvider jwtAuthenticationProvider;
private final AuthenticationConfiguration authenticationConfiguration;

@Bean
public SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.securityMatchers(security -> security
.requestMatchers(new AntPathRequestMatcher("/api/v1/**"))
)
.authorizeHttpRequests(authorize -> authorize
.requestMatchers(new AntPathRequestMatcher("/api/v1/login"),
new AntPathRequestMatcher("/api/v1/signup"),
new AntPathRequestMatcher("/api/v1/products/**"),
new AntPathRequestMatcher("/api/v1/rate/product/*"),
new AntPathRequestMatcher("/api/v1/rate/product/*/all"))
.permitAll()
.anyRequest().authenticated()
)
.authenticationProvider(jwtAuthenticationProvider)
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint()))
.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);

return http.build();
}

@Bean
public JwtAuthenticationFilter jwtAuthenticationFilter() throws Exception {
return new JwtAuthenticationFilter(authenticationManager(authenticationConfiguration));
}

@Bean
public FilterRegistrationBean<JwtAuthenticationFilter> register(final JwtAuthenticationFilter authFilter) {
final FilterRegistrationBean<JwtAuthenticationFilter> registerBean = new FilterRegistrationBean<>(authFilter);
registerBean.setEnabled(false);
return registerBean;
}

@Bean
public AuthenticationManager authenticationManager(final AuthenticationConfiguration config) throws Exception {
return config.getAuthenticationManager();
}

@Bean
public AuthenticationEntryPoint jwtAuthenticationEntryPoint() {
return new JwtAuthenticationEntryPoint(objectMapper);
}

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gugucon.shopping.auth.domain.vo;

import com.gugucon.shopping.auth.dto.MemberPrincipal;
import java.util.Collection;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

@Getter
@EqualsAndHashCode(callSuper = false)
public class JwtAuthenticationToken extends AbstractAuthenticationToken {

private String jwtToken;

private MemberPrincipal principal;

private Object credentials;

public JwtAuthenticationToken(final String jwtToken) {
super(null);
this.jwtToken = jwtToken;
setAuthenticated(false);
}

public JwtAuthenticationToken(final MemberPrincipal principal,
final Object credentials,
final Collection<? extends GrantedAuthority> authorities) {
super(authorities);
this.principal = principal;
this.credentials = credentials;
super.setAuthenticated(true);
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/gugucon/shopping/auth/dto/MemberPrincipal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gugucon.shopping.auth.dto;

import com.gugucon.shopping.member.domain.entity.Member;
import com.gugucon.shopping.member.domain.vo.Email;
import com.gugucon.shopping.member.domain.vo.Gender;
import com.gugucon.shopping.member.domain.vo.Nickname;
import java.time.LocalDate;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class MemberPrincipal {

private final Long id;
private final LocalDate birthDate;
private final Gender gender;
private final Email email;
private final Nickname nickname;

public static MemberPrincipal from(final Member member) {
return new MemberPrincipal(member.getId(),
member.getBirthDate(),
member.getGender(),
member.getEmail(),
member.getNickname());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gugucon.shopping.auth.security;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.gugucon.shopping.common.exception.ErrorResponse;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import java.io.IOException;

import static com.gugucon.shopping.common.exception.ErrorCode.LOGIN_REQUESTED;

@RequiredArgsConstructor
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {

private final ObjectMapper objectMapper;

@Override
public void commence(final HttpServletRequest request,
final HttpServletResponse response,
final AuthenticationException authException) throws IOException {

final ErrorResponse errorResponse = ErrorResponse.from(LOGIN_REQUESTED);
final ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(objectMapper.writeValueAsBytes(errorResponse));

response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setStatus(LOGIN_REQUESTED.getStatus().value());
}
}
Loading

0 comments on commit c0c9363

Please sign in to comment.