-
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
base: htdufhc-bit
Are you sure you want to change the base?
Changes from 93 commits
db19123
b6ba2cb
5e7b687
ec6ee6d
b17debb
6e1c475
ba98c27
2b95ab2
1c8cfde
ab7f70c
eae5e9a
bf6ac7b
fd847c1
8acaa21
787f1a6
6d4cc45
219413c
5d94f7e
7daa481
1e3fdb3
aac8aa3
4093c0b
557971d
1d58693
7c289c3
a5fa426
50a30f4
31bb114
4975da3
5bc54ca
6eb6095
b400cf2
753f82a
dded032
5e0c8a7
ccb028c
e1b65c3
ce5ad9a
0a3086e
0a7c180
da760e9
b325fc5
3c1f8f2
4108114
f7b7531
f16fde7
084d3eb
4b53082
1902301
6813feb
fb8ea71
72a68ca
0a710ce
5a080cf
85ad22d
363a773
436ecde
8d117f1
dc5b5e7
621f6a1
f81cc37
322d8c1
fa7cd36
787091a
2343bc4
e1fac12
c3bda17
6402408
eaec41b
63bc184
6eaf8f3
ca1f694
6e99544
f2fd69f
4ff2550
795d0ad
d1da150
1e36599
69db99b
5b1a969
72349b2
773b636
e385e04
1ca564b
f55a622
bd048d0
dfba04f
bada4a5
14acc26
76c94c9
d7f4d4b
ba175a0
4076e21
1be017e
6097143
79b95a4
5471951
d67fb2a
29b58ca
c9146dc
901db81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/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 -x test | ||
|
|
||
| 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)" |
| 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 21 설치" | ||
| sudo apt install -y openjdk-21-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] 초기 설정 완료" | ||
|
Comment on lines
+1
to
+25
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. 빌드 실패 시 어떻게 할 지도 다뤄주면 좋을 거 같아요. 또, 스크립트에 테스트를 포함하면 버그를 운영 환경이 아닌 배포 단계에서 잡을 수 있어요. :)
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. deploy.sh 파일에 빌드를 하고, 실패했을 때 에러 로그를 띄우도록 수정했습니다!! [반영 커밋] - d67fb2a |
||
| 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()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,15 @@ public class RefreshToken { | |
| public RefreshToken() { | ||
| } | ||
|
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. @NoArgsConstructor어노테이션에 대해 알아볼까요?
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. Lombok 라이브러리에서 제공하는 어노테이션으로, final 필드가 없을 때 파라미터가 없는 생성자를 만들어줍니다! [반영 커밋] - 1be017e |
||
|
|
||
| public RefreshToken(Member member, String token) { | ||
| private RefreshToken(Member member, String token) { | ||
| this.member = member; | ||
| this.token = token; | ||
| } | ||
|
|
||
| public static RefreshToken of(Member member, String token) { | ||
| return new RefreshToken(member, token); | ||
| } | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,17 @@ | ||
| 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); | ||
|
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. 안 쓰이는 메서드는 지워주는 게 좋을 거 같아요!! 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.
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. 제가 잘못 파악한 것일 수도 있지만, RefreshTokenRepository에 사용되지 않는 메서드가 하나 있어 제거했습니다. [반영 커밋] - 79b95a4 |
||
|
|
||
| void deleteByMemberId(Long memberId); | ||
|
|
||
| void flush(); | ||
| } | ||
| 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(); | ||
| } | ||
| } |
| 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); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package roomescape.global.entity; | ||
|
|
||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.MappedSuperclass; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.time.ZoneId; | ||
|
|
||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| public class BaseSoftDeleteEntity { | ||
|
|
||
| private static final ZoneId KST_ZONE = ZoneId.of("Asia/Seoul"); | ||
|
|
||
| private LocalDateTime deletedAt; | ||
|
|
||
| public void markDeleted() { | ||
| this.deletedAt = LocalDateTime.now(KST_ZONE); | ||
| } | ||
|
|
||
| public LocalDateTime getDeletedAt() { | ||
| return deletedAt; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package roomescape.exception; | ||
| package roomescape.global.exception; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
|
|
||
|
|
||




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.
현재 명준님의 프로젝트는 java17을 쓰고 있는 데 java 21을 설치하고 있네요!
버전을 맞춰주는 게 좋을 거 같습니다!
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.
수정했습니다!!
[반영 커밋] - 5471951