diff --git a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java index 8fe863a8..0867204e 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java @@ -43,7 +43,8 @@ public Page 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()). @@ -84,7 +85,8 @@ public Page 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()) @@ -170,7 +172,8 @@ public Page 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; } @@ -184,8 +187,8 @@ public Optional 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()); } diff --git a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java index 25b4e4fa..ece47bc6 100644 --- a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java +++ b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java @@ -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; @@ -86,7 +87,8 @@ 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"); @@ -94,7 +96,8 @@ void setUp() throws IOException { 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()); } @@ -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())); @@ -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())) @@ -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()))