-
Notifications
You must be signed in to change notification settings - Fork 97
[그리디] 정명준 Spring Core(배포) 7~9단계 제출합니다. #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
htdufhc-bit
wants to merge
101
commits into
next-step:htdufhc-bit
Choose a base branch
from
htdufhc-bit:roomescape-core
base: htdufhc-bit
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 98 commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
db19123
chore: 초기 세팅 설정
htdufhc-bit b6ba2cb
refactor: 공통 예외 처리 구조 도입
htdufhc-bit 5e7b687
feat: 로그인 및 인증 정보 조회 (1 & 2단계)
htdufhc-bit ec6ee6d
feat: 인증 정보 기반 예약 생성 (1 & 2단계)
htdufhc-bit b17debb
test: 1, 2단계 테스트 추가
htdufhc-bit 6e1c475
chore: 미사용 import 제거 및 코드 포맷 정리
htdufhc-bit ba98c27
refactor: 로그아웃 기능을 auth 도메인으로 이동
htdufhc-bit 2b95ab2
feat: 회원 예외 처리를 위한 MemberErrorCode 추가 및 적용
htdufhc-bit 1c8cfde
fix: SQL 문법 오류 해결
htdufhc-bit ab7f70c
docs: README.md 추가
htdufhc-bit eae5e9a
refactor: 예외 로깅 방식을 printStackTrace에서 Logger로 변경
htdufhc-bit bf6ac7b
refactor: MalformedJwtException UnsupportedJwtException 예외 처리 추가
htdufhc-bit fd847c1
feat: 인증 필요를 가리키는 커스텀 어노테이션 추가
htdufhc-bit 8acaa21
refactor: bean validation을 통해 검증하도록 수정
htdufhc-bit 787f1a6
refactor: CookieUtil의 책임 분리
htdufhc-bit 6d4cc45
fix: 파일 끝에 개행 문자 추가
htdufhc-bit 219413c
refactor: 사용하지 않는 import문 제거
htdufhc-bit 5d94f7e
refactor: 예약자 name 검증을 DTO에서 service로 이동
htdufhc-bit 7daa481
refactor: 도메인별 패키지를 계층 구조로 재구성
htdufhc-bit 1e3fdb3
refactor: 도메인별 패키지를 계층 구조로 추가 재구성
htdufhc-bit aac8aa3
refactor: Member 권한(Role)을 String에서 enum으로 변경
htdufhc-bit 4093c0b
feat: 권한 검증을 위한 인가 Interceptor 추가
htdufhc-bit 557971d
test: 3단계 테스트 추가
htdufhc-bit 1d58693
test: import문 재정렬
htdufhc-bit 7c289c3
Merge remote-tracking branch 'upstream/htdufhc-bit' into roomescape-M…
htdufhc-bit a5fa426
style: 불필요한 개행 문자 제거
htdufhc-bit 50a30f4
refactor: JwtTokenProvider에 name/role 추출 기능 추가 및 파싱 로직 통합
htdufhc-bit 31bb114
refactor: LoginMember에서 email 필드 제거, JWT 기반으로 인증 정보 생성
htdufhc-bit 4975da3
docs: README에 패키지 구조 개편과 관리자 권한 기능 반영
htdufhc-bit 5bc54ca
fix: 회원 저장 시 Role이 ADMIN으로 고정되는 문제 수정
htdufhc-bit 6eb6095
refactor: 로그인 실패 시 EmptyResultDataAccessException 대신 401 응답 반환
htdufhc-bit b400cf2
refactor: 토큰 추출 공통 로직을 TokenExtractor로 분리
htdufhc-bit 753f82a
feat: refresh token 발급·저장 환경 추가
htdufhc-bit dded032
refactor: CookieUtil을 access/refresh 쿠키 지원 구조로 개선
htdufhc-bit 5e0c8a7
feat: refresh token 기반 재발급 구현
htdufhc-bit ccb028c
test: createToken 메서드가 access token을 추출하도록 수정
htdufhc-bit e1b65c3
build: Spring Data JPA 도입
htdufhc-bit ce5ad9a
refactor: DAO를 JPA Repository로 전환하고 엔티티/DTO 재구성
htdufhc-bit 0a3086e
fix: 쿠키 만료 시 path 불일치 문제 해결
htdufhc-bit 0a7c180
refactor: refresh token을 EntityManager 기반 JPA로 전환
htdufhc-bit da760e9
refactor: 서비스 메서드에 Transactional 어노테이션 적용
htdufhc-bit b325fc5
refactor: 토큰 쿠키 설정 로직을 setTokenCookies 메서드로 추출
htdufhc-bit 3c1f8f2
fix: 쓰기 메서드에 Transactional 어노테이션 추가
htdufhc-bit 4108114
refactor: 엔티티의 사용되지 않는 생성자 삭제
htdufhc-bit f7b7531
refactor: RefreshTokenEntity.java를 RefreshToken.java로 수정
htdufhc-bit f16fde7
docs: README.md 업데이트
htdufhc-bit 084d3eb
fix: 존재하지 않는 id 삭제 시 예외가 발생하는 문제 해결
htdufhc-bit 4b53082
fix: 오타 수정 (예약` -> 예약)
htdufhc-bit 1902301
Merge branch 'htdufhc-bit' into roomescape-JPA
htdufhc-bit 6813feb
fix: spring.jpa.ddl-auto 오타 수정
htdufhc-bit fb8ea71
fix: ThemeService.create()에 @Transactional 추가
htdufhc-bit 72a68ca
fix: refresh token 재발급 시 delete-save 쿼리 순서 문제 수정
htdufhc-bit 0a710ce
fix: findAllByMemberId 메서드의 파라미터 오타 수정
htdufhc-bit 5a080cf
chore: schema.sql 파일 끝 개행 추가
htdufhc-bit 85ad22d
chore: JdbcTemplate 시절 잔여 파일 재삭제
htdufhc-bit 363a773
fix: N+1 문제 해결 - Reservation 관련하여 LAZY 로딩 명시 및 fetch join 적용
htdufhc-bit 436ecde
fix: RefreshToken 관련하여 LAZY 로딩 명시
htdufhc-bit 8d117f1
refactor: EntityManager 기반 Repository를 JpaRepository로 전환
htdufhc-bit dc5b5e7
feat: 예약 대기열 구현
htdufhc-bit 621f6a1
feat: Time과 Theme에 soft delete 적용
htdufhc-bit f81cc37
refactor: 불필요한 member의 JOIN FETCH 제거
htdufhc-bit 322d8c1
refactor: 사용하지 않는 필드 제거
htdufhc-bit fa7cd36
refactor: 필드에 final 붙이도록 수정
htdufhc-bit 787091a
test: 변경된 요구사항에 따라 기존 테스트 수정
htdufhc-bit 2343bc4
test: 변경된 요구사항에 따른 test 추가
htdufhc-bit e1fac12
test: 인증과 예약 api에 대한 test 추가
htdufhc-bit c3bda17
Merge branch 'htdufhc-bit' into roomescape-JPA
htdufhc-bit 6402408
refactor: 사용하지 않는 repository 제거
htdufhc-bit eaec41b
refactor: soft delete로 제거된 경우를 제외하고 findAll하도록 수정
htdufhc-bit 63bc184
refactor: repository 필드를 final로 설정
htdufhc-bit 6eaf8f3
refactor: resolveMember 메서드명을 getTargetMember로 변경하여 역할 명확화
htdufhc-bit ca1f694
refactor: 회원 삭제 시 연관 예약 자동 삭제를 위한 `@OnDelete` 추가
htdufhc-bit 6e99544
refactor: config, exception, util을 global 패키지로 이동
htdufhc-bit f2fd69f
refactor: BaseSoftDeleteEntity를 도입해 Theme/Time의 소프트 삭제 공통화
htdufhc-bit 4ff2550
refactor: 불필요한 import문 제거
htdufhc-bit 795d0ad
refactor: 모든 dto를 record로 변경
htdufhc-bit d1da150
refactor: 객체 생성 및 DTO 변환 방식을 정적 팩토리 메서드와 record 접근자로 통일
htdufhc-bit 1e36599
test: API 테스트를 api 패키지로 이동
htdufhc-bit 69db99b
test: 데이터베이스 초기화를 통해 테스트 컨텍스트 재사용
htdufhc-bit 5b1a969
test: 요청별 쿼리 카운터와 N+1 경고 기능 추가
htdufhc-bit 72349b2
test: 리포지토리 테스트와 테스트 픽스처 추가
htdufhc-bit 773b636
style: 대기 도메인 코드 포맷 정리
htdufhc-bit e385e04
test: 사용하지 않는 필드 제거
htdufhc-bit 1ca564b
refactor: JwtTokenProvider를 프로퍼티 객체 대신 값 주입 방식으로 변경
htdufhc-bit f55a622
refactor: 시간과 테마에 따른 예약 유니크 제약조건 추가
htdufhc-bit bd048d0
feat: 운영/테스트 프로필별 초기 데이터 로더 분리 (DataLoader/TestDataLoader)
htdufhc-bit dfba04f
feat: DatabaseCleaner를 사용하는 테스트에 BeforeEachCallback 적용
htdufhc-bit bada4a5
test: Reservation과 Waiting api 테스트 추가
htdufhc-bit 14acc26
refactor: 엔티티 생성자를 비공개로 전환하고 정적 팩토리가 요청 DTO 대신 값을 받도록 변경
htdufhc-bit 76c94c9
refactor: 사용하지 않는 import문 제거
htdufhc-bit d7f4d4b
Merge branch 'roomescape-JPA' into roomescape-core
htdufhc-bit ba175a0
Merge branch 'roomescape-JPA' into roomescape-core
htdufhc-bit 4076e21
feat: 배포 스크립트 구현
htdufhc-bit 1be017e
refactor: `@Getter`와 `@NoArgsConstructor` 적용
htdufhc-bit 6097143
refactor: `@Getter` 적용
htdufhc-bit 79b95a4
refactor: 사용하지 않는 메서드 제거
htdufhc-bit 5471951
fix: 설치 스크립트의 JDK 버전을 21에서 17로 수정
htdufhc-bit d67fb2a
fix: 배포 스크립트에서 빌드 실패 시 배포를 중단하고 테스트를 포함하도록 수정
htdufhc-bit 29b58ca
fix: 로컬로 배포
htdufhc-bit c9146dc
fix: deploy 수정
htdufhc-bit 901db81
fix: test 파일에만 존재하는 yml 설정 삭제
htdufhc-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/bin/bash | ||
|
|
||
| REPOSITORY=/home/ubuntu/app | ||
| REPO_URL="https://github.com/htdufhc-bit/spring-basic-roomescape-playground" | ||
| PID_FILE="$REPOSITORY/app.pid" | ||
|
|
||
| echo "[INFO] 최신 코드 pull" | ||
| cd $REPOSITORY | ||
| git pull $REPO_URL | ||
|
|
||
| echo "[INFO] 프로젝트 빌드" | ||
| cd $REPOSITORY | ||
| ./gradlew build | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| echo "[ERROR] 빌드에 실패했습니다. 배포를 중단합니다." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "[INFO] 기존에 실행 중인 애플리케이션 PID 종료" | ||
| CURRENT_PID=$(pgrep -f "$REPOSITORY/build/libs/*.jar") | ||
|
|
||
| if [ -z "$CURRENT_PID" ]; then | ||
| echo "[INFO] 종료할 애플리케이션이 없습니다." | ||
| else | ||
| echo "[INFO] kill -15 $CURRENT_PID" | ||
| kill -15 $CURRENT_PID | ||
| sleep 5 | ||
| fi | ||
|
|
||
| echo "[INFO] 새 애플리케이션 실행" | ||
| JAR_NAME=$(ls $REPOSITORY/build/libs/*.jar | grep -v plain) | ||
|
|
||
| nohup java -jar $JAR_NAME > $REPOSITORY/nohup.log 2>&1 & | ||
|
|
||
| echo $! > $PID_FILE | ||
| echo "[INFO] 애플리케이션이 실행되었습니다. PID: $(cat $PID_FILE)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
|
|
||
| REPOSITORY=/home/ubuntu/app | ||
| REPO_URL="https://github.com/htdufhc-bit/spring-basic-roomescape-playground" | ||
| PID_FILE="$REPOSITORY/app.pid" | ||
|
|
||
| echo "[INFO] 시스템 패키지 업데이트" | ||
| sudo apt update | ||
|
|
||
| echo "[INFO] JDK 17 설치" | ||
| sudo apt install -y openjdk-17-jdk | ||
|
|
||
| echo "[INFO] 프로젝트 디렉토리 생성 및 이동" | ||
| mkdir -p $REPOSITORY | ||
| cd $REPOSITORY | ||
|
|
||
| echo "[INFO] Git Repository 클론 또는 최신화" | ||
| if [ -d ".git" ]; then | ||
| echo "이미 git repository가 존재합니다. 최신 코드를 받아옵니다." | ||
| git pull | ||
| else | ||
| git clone $REPO_URL . | ||
| fi | ||
|
|
||
| echo "[INFO] 초기 설정 완료" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| package roomescape.auth.dto; | ||
|
|
||
| import roomescape.auth.domain.LoginMember; | ||
|
|
||
| public record LoginCheckResponse( | ||
| String name | ||
| ) { | ||
|
|
||
| public static LoginCheckResponse from(LoginMember loginMember) { | ||
| return new LoginCheckResponse(loginMember.name()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,13 @@ | |
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import roomescape.member.entity.Member; | ||
|
|
||
| @Entity(name = "refresh_token") | ||
| @NoArgsConstructor | ||
| @Getter | ||
| public class RefreshToken { | ||
|
|
||
| @Id | ||
|
|
@@ -24,23 +28,12 @@ public class RefreshToken { | |
| @Column(nullable = false, length = 500) | ||
| private String token; | ||
|
|
||
| public RefreshToken() { | ||
| } | ||
|
|
||
| public RefreshToken(Member member, String token) { | ||
| private RefreshToken(Member member, String token) { | ||
| this.member = member; | ||
| this.token = token; | ||
| } | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public Member getMember() { | ||
| return member; | ||
| } | ||
|
|
||
| public String getToken() { | ||
| return token; | ||
| public static RefreshToken of(Member member, String token) { | ||
| return new RefreshToken(member, token); | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Getter 어노테이션에 대해 알아볼까요?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
src/main/java/roomescape/auth/repository/JpaRefreshTokenRepository.java
This file was deleted.
Oops, something went wrong.
11 changes: 4 additions & 7 deletions
11
src/main/java/roomescape/auth/repository/RefreshTokenRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,15 @@ | ||
| package roomescape.auth.repository; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
| import roomescape.auth.entity.RefreshToken; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface RefreshTokenRepository { | ||
|
|
||
| void save(RefreshToken refreshToken); | ||
| @Repository | ||
| public interface RefreshTokenRepository extends JpaRepository<RefreshToken, Long> { | ||
|
|
||
| Optional<RefreshToken> findByToken(String token); | ||
|
|
||
| Optional<RefreshToken> findByMemberId(Long memberId); | ||
|
|
||
| void deleteByMemberId(Long memberId); | ||
|
|
||
| void flush(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package roomescape.global.config; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.CommandLineRunner; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import roomescape.member.entity.Member; | ||
| import roomescape.member.entity.Role; | ||
| import roomescape.member.repository.MemberRepository; | ||
|
|
||
| @Component | ||
| @Profile("prod") | ||
| public class DataLoader implements CommandLineRunner { | ||
|
|
||
| @Autowired | ||
| private MemberRepository memberRepository; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void run(String... args) throws Exception { | ||
| createMember("어드민", "admil@email.com", "password", Role.ADMIN); | ||
| createMember("브라운", "brown@email.com", "password", Role.USER); | ||
| } | ||
|
|
||
| private void createMember(String name, String email, String password, Role role) { | ||
| if (!validateMemberExists(email)) { | ||
| memberRepository.save( | ||
| Member.of(name, email, password, role) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| private boolean validateMemberExists(String email) { | ||
| return memberRepository.findByEmail(email) | ||
| .isPresent(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package roomescape.global.config; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import roomescape.auth.jwt.JwtTokenProvider; | ||
|
|
||
| @Configuration | ||
| public class SecureConfig { | ||
|
|
||
| @Value("${roomescape.auth.jwt.secret-key}") | ||
| String secretKey; | ||
|
|
||
| @Value("${roomescape.auth.jwt.access-token-expiration}") | ||
| long accessTokenExpiration; | ||
|
|
||
| @Value("${roomescape.auth.jwt.refresh-token-expiration}") | ||
| long refreshTokenExpiration; | ||
|
|
||
| @Bean | ||
| public JwtTokenProvider jwtTokenProvider() { | ||
| return new JwtTokenProvider(secretKey, accessTokenExpiration, refreshTokenExpiration); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빌드 실패 시 어떻게 할 지도 다뤄주면 좋을 거 같아요.
또, 스크립트에 테스트를 포함하면 버그를 운영 환경이 아닌 배포 단계에서 잡을 수 있어요. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deploy.sh 파일에 빌드를 하고, 실패했을 때 에러 로그를 띄우도록 수정했습니다!!
[반영 커밋] - d67fb2a