Skip to content

Commit

Permalink
Merge pull request #313 from WE-ARE-RACCOONS/RAC-426
Browse files Browse the repository at this point in the history
RAC-426 feat : Flyway ์ถ”๊ฐ€ + ํŠœํ† ๋ฆฌ์–ผ ์—ฌ๋ถ€ ์‘๋‹ต ์ถ”๊ฐ€
  • Loading branch information
ywj9811 authored Aug 22, 2024
2 parents 37d2ca8 + ff17e68 commit b5e045d
Show file tree
Hide file tree
Showing 29 changed files with 76 additions and 44 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ dependencies {
implementation 'org.redisson:redisson-spring-boot-starter:3.18.0'

implementation 'com.github.ywj9811:querydsl-itemreader:v1.0.1'

// flyway ์ถ”๊ฐ€
implementation 'org.flywaydb:flyway-mysql'
implementation 'org.flywaydb:flyway-core'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import com.postgraduate.domain.user.user.domain.entity.constant.Role;

public record JwtTokenResponse(String accessToken, int accessExpiration,
String refreshToken, int refreshExpiration, Role role) implements AuthResponse{}
String refreshToken, int refreshExpiration, Role role, boolean isTutorial) implements AuthResponse{}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private JwtTokenResponse generateToken(User user, Role role) {
checkDelete(user);
String accessToken = jwtUtils.generateAccessToken(user.getUserId(), role);
String refreshToken = jwtUtils.generateRefreshToken(user.getUserId(), role);
return new JwtTokenResponse(accessToken, accessExpiration, refreshToken, refreshExpiration, role);
return new JwtTokenResponse(accessToken, accessExpiration, refreshToken, refreshExpiration, role, user.isTutorial());
}

private void checkDelete(User user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public void updateInfo(User user, UserInfoRequest userInfoRequest) {
userUpdateService.updateInfo(user, userInfoRequest);
}

public void tutorialFin(User user) {
user = userGetService.byUserId(user.getUserId());
userUpdateService.tutorialFin(user);
}

@Transactional(readOnly = true)
public Boolean duplicatedNickName(String nickName) {
return userGetService.byNickName(nickName).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class UserUtils {

@PostConstruct
public void init() {
archiveUser = new User(-100L, -100L, null, "์•Œ์ˆ˜์—†์Œ", "ํƒˆํ‡ดํ•œํšŒ์›", profile, 0, null, false, null, null, false);
archiveUser = new User(-100L, -100L, null, "์•Œ์ˆ˜์—†์Œ", "ํƒˆํ‡ดํ•œํšŒ์›", profile, 0, null, false, null, null, false, false);
}

public User getArchiveUser() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public class User {
@UpdateTimestamp
private LocalDateTime updatedAt;

@Column(nullable = false)
@Builder.Default
private boolean isTutorial = false;

@Column(nullable = false)
@Builder.Default
private boolean isDelete = false;
Expand Down Expand Up @@ -91,6 +95,14 @@ public boolean isDelete() {
return this.isDelete;
}

public boolean isTutorial() {
return this.isTutorial;
}

public void tutorialFin() {
this.isTutorial = true;
}

public boolean isDefaultProfile(List<String> defaultProfile) {
return defaultProfile.contains(profile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ public void updateSeniorUserAccount(User user, SeniorMyPageUserAccountRequest my
public void updateRestore(User user) {
user.restoreDelete();
}

public void tutorialFin(User user) {
user.tutorialFin();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public class UserController {
private final UserMyPageUseCase myPageUseCase;
private final UserManageUseCase manageUseCase;

@PatchMapping("/me/tutorial")
@Operation(summary = "ํŠœํ† ๋ฆฌ์–ผ ์™„๋ฃŒ์‹œ ์ƒํƒœ ์—…๋ฐ์ดํŠธ")
public ResponseEntity<ResponseDto<Void>> updateTutorialFin(@AuthenticationPrincipal User user) {
manageUseCase.tutorialFin(user);
return ResponseEntity.ok(create(UserResponseCode.USER_UPDATE.getCode(), UserResponseMessage.UPDATE_USER_INFO.getMessage()));
}

@GetMapping("/me")
@Operation(summary = "์‚ฌ์šฉ์ž ๋งˆ์ดํŽ˜์ด์ง€ ์ •๋ณด ์กฐํšŒ | ํ† ํฐ ํ•„์š”", description = "๋‹‰๋„ค์ž„, ํ”„๋กœํ•„")
public ResponseEntity<ResponseDto<UserMyPageResponse>> getUserInfo(@AuthenticationPrincipal User user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ public class BizppurioSend {

@Value("${bizppurio.message}")
private String messageUrl;
@Value("${bizppurio.status}")
private String status;

protected void sendMessageWithExceptionHandling(Supplier<CommonRequest> messageSupplier) {
if (status.equals(DEV))
return;
try {
CommonRequest commonRequest = messageSupplier.get();
String accessToken = bizppurioAuth.getAuth();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/db/migration/V1_202408230112__alter.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE user ADD COLUMN is_tutorial BIT(1) DEFAULT false;
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JwtUseTypeTest {
void setting() {
user = new User(1L, 1L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE, FALSE);
}

@Test
Expand Down Expand Up @@ -74,7 +74,7 @@ void signInWithUser() {
void signInWithSenior() {
user = new User(1L, 1L, "a",
"a", "123", "a",
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE);
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE, FALSE);
given(jwtUtils.generateAccessToken(user.getUserId(), user.getRole()))
.willReturn("accessToken");
given(jwtUtils.generateRefreshToken(user.getUserId(), user.getRole()))
Expand Down Expand Up @@ -104,7 +104,7 @@ void logout() {
void signInWithUserDelete() {
user = new User(1L, 1L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now().minusDays(20), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now().minusDays(20), TRUE, TRUE);

assertThatThrownBy(() -> jwtUseCase.signIn(user))
.isInstanceOf(UserNotFoundException.class);
Expand All @@ -115,7 +115,7 @@ void signInWithUserDelete() {
void signInWithSeniorDelete() {
user = new User(1L, 1L, "a",
"a", "123", "a",
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now().minusDays(20), TRUE);
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now().minusDays(20), TRUE, TRUE);

assertThatThrownBy(() -> jwtUseCase.signIn(user))
.isInstanceOf(DeletedUserException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(1L, 1234L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE, TRUE);
wish = new Wish(1L, "major", "field", TRUE, user, Status.WAITING);
senior = new Senior(1L, user, "a",
APPROVE,1, 1, info, profile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class KakaoSignInUseTypeTest {
void setting() {
user = new User(1L, 1L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
}
@Test
@DisplayName("๊ธฐ์กด ํšŒ์› ํ…Œ์ŠคํŠธ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_CREATE;
import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.CREATE_SENIOR;
import static com.postgraduate.domain.user.user.domain.entity.constant.Role.USER;
import static java.lang.Boolean.TRUE;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willDoNothing;
Expand All @@ -37,7 +38,7 @@ void authLoginByUser() throws Exception {
CodeRequest codeRequest = new CodeRequest("code");
String request = objectMapper.writeValueAsString(codeRequest);
AuthUserResponse response = new AuthUserResponse(user, user.getSocialId());
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);
given(selectOauth.selectSignIn(Provider.KAKAO))
.willReturn(kakaoSignInUseCase);
given(kakaoSignInUseCase.getUser(codeRequest))
Expand Down Expand Up @@ -91,7 +92,7 @@ void signUpUser() throws Exception {
SignUpRequest signUpRequest = new SignUpRequest(user.getSocialId(), user.getPhoneNumber(), user.getNickName(),
user.getMarketingReceive(), "major", "field", true);
String request = objectMapper.writeValueAsString(signUpRequest);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

given(signUpUseCase.userSignUp(signUpRequest))
.willReturn(user);
Expand All @@ -117,7 +118,7 @@ void signUpUser() throws Exception {
@WithMockUser
@DisplayName("๋Œ€ํ•™์›์ƒ์ด ๋Œ€ํ•™์ƒ์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.")
void changeUserToken() throws Exception {
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

given(jwtUseCase.changeUser(any()))
.willReturn(tokenResponse);
Expand All @@ -142,7 +143,7 @@ void changeUser() throws Exception {
String request = objectMapper.writeValueAsString(
new UserChangeRequest("major", "field", true)
);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

willDoNothing().given(signUpUseCase)
.changeUser(any(), any());
Expand Down Expand Up @@ -174,7 +175,7 @@ void singUpSenior() throws Exception {
true, "์ „๊ณต", "์„œ์šธ๋Œ€ํ•™๊ต", "๊ต์ˆ˜", "์—ฐ๊ตฌ์‹ค",
"AI", "ํ‚ค์›Œ๋“œ", "chatLink")
);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

given(signUpUseCase.seniorSignUp(any()))
.willReturn(user);
Expand Down Expand Up @@ -204,7 +205,7 @@ void changeSenior() throws Exception {
new SeniorChangeRequest("major", "field", "๊ต์ˆ˜", "์—ฐ๊ตฌ์‹ค",
"AI", "ํ‚ค์›Œ๋“œ", "chatLink")
);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

given(signUpUseCase.changeSenior(any(), any()))
.willReturn(user);
Expand All @@ -230,7 +231,7 @@ void changeSenior() throws Exception {
@WithMockUser
@DisplayName("๋Œ€ํ•™์ƒ์ด ๋Œ€ํ•™์›์ƒ์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.")
void changeSeniorToken() throws Exception {
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

given(jwtUseCase.changeSenior(any()))
.willReturn(tokenResponse);
Expand All @@ -252,7 +253,7 @@ void changeSeniorToken() throws Exception {
@WithMockUser
@DisplayName("ํ† ํฐ์„ ์žฌ๋ฐœ๊ธ‰ํ•œ๋‹ค.")
void refresh() throws Exception {
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER);
JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER, TRUE);

given(jwtUseCase.regenerateToken(any(), any()))
.willReturn(tokenResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void uploadCertification() {
void uploadProfile() {
User user = new User(-1L, -1234L, "abc.com", "abc"
, " 123123", "abcab", 0
, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE);
, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), FALSE, TRUE);

MockMultipartFile mockMultipartFile = new MockMultipartFile("profile", new byte[]{});
given(s3UploadService.saveProfileFile(mockMultipartFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(-1L, 1234L, "a",
"a", "123", "a",
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
mentoringUser = new User(-2L, 12345L, "a",
"a", "123", "a",
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(-1L, user, "a",
APPROVE,1, 1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(-1L, 1234L, "a",
"a", "123", "a",
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
mentoringUser = new User(-2L, 12345L, "a",
"a", "123", "a",
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(-1L, user, "a",
APPROVE, 1, 1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(-1L, 1234L, "a",
"a", "123", "a",
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
mentoringUser = new User(-2L, 12345L, "a",
"a", "123", "a",
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(-1L, user, "a",
APPROVE, 1, 1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(-1L, 1234L, "a",
"a", "123", "a",
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
mentoringUser = new User(-2L, 12345L, "a",
"a", "123", "a",
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(-1L, user, "a",
APPROVE, 1,1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(-1L, 1234L, "a",
"a", "123", "a",
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
mentoringUser = new User(-2L, 12345L, "a",
"a", "123", "a",
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
0, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(-1L, user, "a",
APPROVE, 1,1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(1L, 1234L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
originUser = new User(2L, 12345L, "a",
"a", "12345", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(1L, user, "a",
APPROVE, 1, 1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(1L, 1234L, "a",
"a", "123", "a",
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(1L, user, "a",
APPROVE, 1, 1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void setting() {
profile = new Profile("a", "a", "a");
user = new User(1L, 1234L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
senior = new Senior(1L, user, "a",
APPROVE, 1, 1, info, profile,
LocalDateTime.now(), LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SeniorUpdateServiceTest {
@InjectMocks
private SeniorUpdateService seniorUpdateService;

private User user = new User(1L, 2L, "a", "b", "c", "d", 0, SENIOR, FALSE, now(), now(), TRUE);
private User user = new User(1L, 2L, "a", "b", "c", "d", 0, SENIOR, FALSE, now(), now(), TRUE, TRUE);
private Senior senior;
@BeforeEach
void setting() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UserMyPageUseTypeTest {
void setting() {
user = new User(1L, 1234L, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
}

@Test
Expand Down Expand Up @@ -73,7 +73,7 @@ void checkSeniorWithUser() {
void checkSeniorWithSenior() {
user = new User(1L, 1234L, "a",
"a", "123", "a",
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, SENIOR, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);

UserPossibleResponse checkSenior = userMyPageUseCase.checkSenior(user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UserGetServiceTest {
void setting() {
user = new User(-1l, -1l, "a",
"a", "123", "a",
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE);
1, USER, TRUE, LocalDateTime.now(), LocalDateTime.now(), TRUE, TRUE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void setting() {
user = new User(1L, 2L, "a",
"b", "c", "d",
0, USER, FALSE,
now(), now(), TRUE);
now(), now(), TRUE, TRUE);
}

@Test
Expand Down
Loading

0 comments on commit b5e045d

Please sign in to comment.