Skip to content

Commit

Permalink
Merge pull request #160 from WE-ARE-RACCOONS/RAC-304
Browse files Browse the repository at this point in the history
RAC-304 fix : ν”„λ‘œν•„ λ―Έμ™„μ„± μ„ λ°° 쑰회 μˆ˜μ •
  • Loading branch information
ywj9811 authored Mar 5, 2024
2 parents 5a00043 + f201f55 commit 20e367b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public Page<Senior> findAllBySearchSenior(String search, String sort, Pageable p
.where(
senior.info.totalInfo.like("%" + search + "%"),
senior.status.eq(APPROVE),
senior.user.isDelete.eq(FALSE)
senior.user.isDelete.eq(FALSE),
senior.profile.isNotNull()
)
.orderBy(orderSpecifier(sort))
.orderBy(senior.user.nickName.asc()).
Expand Down Expand Up @@ -84,7 +85,8 @@ public Page<Senior> findAllByFieldSenior(String field, String postgradu, Pageabl
fieldSpecifier(field),
postgraduSpecifier(postgradu),
senior.status.eq(APPROVE),
senior.user.isDelete.eq(FALSE)
senior.user.isDelete.eq(FALSE),
senior.profile.isNotNull()
)
.orderBy(senior.hit.desc())
.orderBy(senior.user.nickName.asc())
Expand Down Expand Up @@ -170,7 +172,8 @@ public Page<Senior> findAllBySearchSeniorWithAdmin(String search, Pageable pagea
private BooleanExpression searchLike(String search) {
if (StringUtils.hasText(search)) {
return senior.user.phoneNumber.contains(search)
.or(senior.user.nickName.contains(search));
.or(senior.user.nickName.contains(search))
.and(senior.profile.isNotNull());
}
return null;
}
Expand All @@ -184,8 +187,8 @@ public Optional<Senior> findBySeniorId(Long seniorId) {
.where(
senior.seniorId.eq(seniorId),
senior.profile.isNotNull(),
senior.status.eq(APPROVE)
,senior.user.isDelete.isFalse()
senior.status.eq(APPROVE),
senior.user.isDelete.isFalse()
)
.fetchOne());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class SeniorControllerTest extends IntegrationTest {
private Senior senior;
private Senior otherSenior;
private String token;
private String otherToken;
private String seniorToken;
private String userToken;
private User user;
private User otherUser;

Expand All @@ -86,15 +87,17 @@ void setUp() throws IOException {
userRepository.save(otherUser);

Info info1 = new Info("major", "postgradu", "κ΅μˆ˜λ‹˜", "keyword1,keyword2", "λž©μ‹€", "field", false, false, "field,keyword1,keyword2");
senior = new Senior(0L, user, "certification", Status.APPROVE, 0, info1, null, now(), now());
Profile profile1 = new Profile("info", "one", "u", "chat", 30);
senior = new Senior(0L, user, "certification", Status.APPROVE, 0, info1, profile1, now(), now());
seniorRepository.save(senior);

Info info2 = new Info("major", "postgradu", "κ΅μˆ˜λ‹˜", "keyword1,keyword2", "λž©μ‹€", "field", false, false, "field,keyword1,keyword2");
otherSenior = new Senior(-1L, otherUser, "certification", Status.APPROVE, 0, info2, null, now(), now());
seniorRepository.save(otherSenior);

token = jwtUtil.generateAccessToken(user.getUserId(), Role.SENIOR);
otherToken = jwtUtil.generateAccessToken(otherUser.getUserId(), Role.USER);
seniorToken = jwtUtil.generateAccessToken(otherUser.getUserId(), Role.SENIOR);
userToken = jwtUtil.generateAccessToken(otherUser.getUserId(), Role.USER);

doNothing().when(slackLogErrorMessage).sendSlackLog(any());
}
Expand Down Expand Up @@ -292,7 +295,7 @@ void getSeniorProfile() throws Exception {
@DisplayName("λ“±λ‘λœ ν”„λ‘œν•„μ΄ μ—†λ‹€λ©΄ [λ‚΄ ν”„λ‘œν•„ μˆ˜μ •] κΈ°λ³Έ 정보λ₯Ό μ‘°νšŒν•  수 μ—†λ‹€")
void getEmptySeniorProfile() throws Exception {
mvc.perform(get("/senior/me/profile")
.header(AUTHORIZATION, BEARER + token))
.header(AUTHORIZATION, BEARER + seniorToken))
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(PROFILE_NOT_FOUND.getCode()))
.andExpect(jsonPath("$.message").value(NOT_FOUND_PROFILE.getMessage()));
Expand Down Expand Up @@ -523,7 +526,7 @@ void getSeniorDetailsOthers() throws Exception {
updateAvailable();

mvc.perform(get("/senior/{seniorId}", senior.getSeniorId())
.header(AUTHORIZATION, BEARER + otherToken))
.header(AUTHORIZATION, BEARER + userToken))
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(SENIOR_FIND.getCode()))
.andExpect(jsonPath("$.message").value(GET_SENIOR_INFO.getMessage()))
Expand Down Expand Up @@ -564,7 +567,7 @@ void testGetSeniorProfile() throws Exception {
updateAvailable();

mvc.perform(get("/senior/{seniorId}/profile", senior.getSeniorId())
.header(AUTHORIZATION, BEARER + otherToken))
.header(AUTHORIZATION, BEARER + userToken))
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(SENIOR_FIND.getCode()))
.andExpect(jsonPath("$.message").value(GET_SENIOR_INFO.getMessage()))
Expand Down

0 comments on commit 20e367b

Please sign in to comment.