diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequest.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequest.java index 66521413..38e56512 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequest.java +++ b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequest.java @@ -3,5 +3,5 @@ import jakarta.validation.constraints.NotBlank; public record SeniorChangeRequest(@NotBlank String major, @NotBlank String postgradu, @NotBlank String professor, - @NotBlank String lab, @NotBlank String field, @NotBlank String keyword, @NotBlank String certification) { + @NotBlank String lab, @NotBlank String field, @NotBlank String keyword) { } \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequestB.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequestB.java deleted file mode 100644 index f422b021..00000000 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequestB.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.postgraduate.domain.auth.application.dto.req; - -import jakarta.validation.constraints.NotBlank; - -public record SeniorChangeRequestB(@NotBlank String major, @NotBlank String postgradu, @NotBlank String professor, - @NotBlank String lab, @NotBlank String field, @NotBlank String keyword) { -} \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequest.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequest.java index 13fa0473..58fe9563 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequest.java +++ b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequest.java @@ -8,5 +8,5 @@ public record SeniorSignUpRequest(@NotNull Long socialId, @NotBlank String phone @Size(max = 6, message = "6글자까지 입력 가능합니다.") @NotBlank String nickName, Boolean marketingReceive, @NotBlank String major, @NotBlank String postgradu, @NotBlank String professor, @NotBlank String lab, @NotBlank String field, - @NotBlank String keyword, @NotBlank String certification) { + @NotBlank String keyword) { } diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequestB.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequestB.java deleted file mode 100644 index 43aed1a0..00000000 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorSignUpRequestB.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.postgraduate.domain.auth.application.dto.req; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -public record SeniorSignUpRequestB(@NotNull Long socialId, @NotBlank String phoneNumber, - @Size(max = 6, message = "6글자까지 입력 가능합니다.") @NotBlank String nickName, - Boolean marketingReceive, @NotBlank String major, @NotBlank String postgradu, - @NotBlank String professor, @NotBlank String lab, @NotBlank String field, - @NotBlank String keyword) { -} diff --git a/src/main/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseCase.java b/src/main/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseCase.java index 04412568..548ec6c6 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseCase.java +++ b/src/main/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseCase.java @@ -98,22 +98,4 @@ private User changeSeniorFin(Senior senior, User user) { bizppurioSeniorMessage.signUp(user); return user; } - - /** - * 여기부터 Case B를 위한 코드 - */ - public User seniorSignUpB(SeniorSignUpRequestB request) { - seniorUtils.checkKeyword(request.keyword()); - userUtils.checkPhoneNumber(request.phoneNumber()); - User user = mapToUser(request, profile); - userSaveService.save(user); - Senior senior = mapToSenior(user, request); - return seniorSignUpFin(senior); - } - - public User changeSeniorB(User user, SeniorChangeRequestB changeRequest) { - seniorUtils.checkKeyword(changeRequest.keyword()); - Senior senior = mapToSenior(user, changeRequest); - return changeSeniorFin(senior, user); - } } diff --git a/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java b/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java index f992b8fc..4cc9c96f 100644 --- a/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java +++ b/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java @@ -136,8 +136,8 @@ public ResponseDto refresh(@AuthenticationPrincipal User user, @PostMapping("/senior/signup/b") @Operation(summary = "대학원생 가입(Case B) - 필수 과정만", description = "대학원생 회원가입 - 필수 과정만") - public ResponseDto singUpSeniorB(@RequestBody @Valid SeniorSignUpRequestB request) { - User user = signUpUseCase.seniorSignUpB(request); + public ResponseDto singUpSeniorB(@RequestBody @Valid SeniorSignUpRequest request) { + User user = signUpUseCase.seniorSignUp(request); JwtTokenResponse jwtToken = jwtUseCase.signIn(user); return ResponseDto.create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage(), jwtToken); } @@ -145,8 +145,8 @@ public ResponseDto singUpSeniorB(@RequestBody @Valid SeniorSig @PostMapping("/senior/change/b") @Operation(summary = "선배로 추가 가입(Case B) | 토큰 필요", description = "대학생 대학원생으로 변경 추가 가입") public ResponseDto changeSeniorB(@AuthenticationPrincipal User user, - @RequestBody @Valid SeniorChangeRequestB changeRequest) { - User changeUser = signUpUseCase.changeSeniorB(user, changeRequest); + @RequestBody @Valid SeniorChangeRequest changeRequest) { + User changeUser = signUpUseCase.changeSenior(user, changeRequest); JwtTokenResponse jwtToken = jwtUseCase.changeSenior(changeUser); return ResponseDto.create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage(), jwtToken); } diff --git a/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepository.java b/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepository.java index 4e2a1f99..42ccfe7b 100644 --- a/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepository.java +++ b/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepository.java @@ -9,8 +9,4 @@ public interface AvailableDslRepository { List findAllBySenior(Senior senior); List findAllByMine(Senior senior); - /** - * Case B - */ - List findAllByAnySenior(Senior senior); } diff --git a/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepositoryImpl.java b/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepositoryImpl.java index d0554bae..860b84d2 100644 --- a/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepositoryImpl.java +++ b/src/main/java/com/postgraduate/domain/available/domain/repository/AvailableDslRepositoryImpl.java @@ -9,7 +9,6 @@ import java.util.List; import static com.postgraduate.domain.available.domain.entity.QAvailable.available; -import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE; @RequiredArgsConstructor @Repository @@ -17,14 +16,6 @@ public class AvailableDslRepositoryImpl implements AvailableDslRepository { private final JPAQueryFactory queryFactory; @Override public List findAllBySenior(Senior senior) { - return queryFactory.selectFrom(available) - .distinct() - .where(available.senior.eq(senior), available.senior.status.eq(APPROVE)) - .fetch(); - } - - @Override - public List findAllByMine(Senior senior) { return queryFactory.selectFrom(available) .distinct() .where(available.senior.eq(senior)) @@ -32,7 +23,7 @@ public List findAllByMine(Senior senior) { } @Override - public List findAllByAnySenior(Senior senior) { + public List findAllByMine(Senior senior) { return queryFactory.selectFrom(available) .distinct() .where(available.senior.eq(senior)) diff --git a/src/main/java/com/postgraduate/domain/available/domain/service/AvailableGetService.java b/src/main/java/com/postgraduate/domain/available/domain/service/AvailableGetService.java index 4bdcd162..79509c17 100644 --- a/src/main/java/com/postgraduate/domain/available/domain/service/AvailableGetService.java +++ b/src/main/java/com/postgraduate/domain/available/domain/service/AvailableGetService.java @@ -13,18 +13,11 @@ public class AvailableGetService { private final AvailableRepository availableRepository; - public List bySenior(Senior senior) { - return availableRepository.findAllBySenior(senior); - } - public List byMine(Senior senior) { return availableRepository.findAllByMine(senior); } - /** - * Case B - */ - public List bySeniorWithAny(Senior senior) { - return availableRepository.findAllByAnySenior(senior); + public List bySenior(Senior senior) { + return availableRepository.findAllBySenior(senior); } } diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/AllSeniorSearchResponseB.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/AllSeniorSearchResponseB.java deleted file mode 100644 index f8ebaf05..00000000 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/AllSeniorSearchResponseB.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.postgraduate.domain.senior.application.dto.res; - -import java.util.List; - -public record AllSeniorSearchResponseB( - List seniorSearchResponses, - Long totalElements -) {} diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponse.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponse.java index 635c0f1e..0866a50a 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponse.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponse.java @@ -6,6 +6,7 @@ public record SeniorDetailResponse( boolean isMine, + boolean certification, String nickName, int term, String profile, diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponseB.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponseB.java deleted file mode 100644 index da440df0..00000000 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorDetailResponseB.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.postgraduate.domain.senior.application.dto.res; - -import com.postgraduate.domain.available.application.dto.res.AvailableTimeResponse; - -import java.util.List; - -public record SeniorDetailResponseB( - boolean isMine, - boolean certification, - String nickName, - int term, - String profile, - String postgradu, - String major, - String lab, - String professor, - String[] keyword, - String info, - String oneLiner, - String target, - List times -) { } diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponse.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponse.java index 12ebbb2d..65ffadac 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponse.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponse.java @@ -2,6 +2,7 @@ public record SeniorSearchResponse( Long seniorId, + boolean certification, String profile, String nickName, String postgradu, diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponseB.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponseB.java deleted file mode 100644 index 3887e7ba..00000000 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponseB.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.postgraduate.domain.senior.application.dto.res; - -public record SeniorSearchResponseB( - Long seniorId, - boolean certification, - String profile, - String nickName, - String postgradu, - String major, - String lab, - String professor, - String[] keyword -) {} diff --git a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java index 402d7e81..4b4fa803 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java +++ b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java @@ -2,9 +2,7 @@ import com.postgraduate.domain.account.domain.entity.Account; import com.postgraduate.domain.auth.application.dto.req.SeniorChangeRequest; -import com.postgraduate.domain.auth.application.dto.req.SeniorChangeRequestB; import com.postgraduate.domain.auth.application.dto.req.SeniorSignUpRequest; -import com.postgraduate.domain.auth.application.dto.req.SeniorSignUpRequestB; import com.postgraduate.domain.available.application.dto.res.AvailableTimeResponse; import com.postgraduate.domain.senior.application.dto.req.SeniorMyPageProfileRequest; import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; @@ -21,7 +19,8 @@ import java.util.List; import java.util.Set; -import static com.postgraduate.domain.senior.domain.entity.constant.Status.*; +import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE; +import static com.postgraduate.domain.senior.domain.entity.constant.Status.NONE; public class SeniorMapper { private SeniorMapper() { @@ -32,7 +31,7 @@ public static Senior mapToSenior(User user, SeniorSignUpRequest request) { return Senior.builder() .user(user) .info(mapToInfo(request)) - .certification(request.certification()) + .status(NONE) .build(); } @@ -40,11 +39,11 @@ public static Senior mapToSenior(User user, SeniorChangeRequest request) { return Senior.builder() .user(user) .info(mapToInfo(request)) - .certification(request.certification()) + .status(NONE) .build(); } - public static Info mapToInfo(SeniorChangeRequest request) { + private static Info mapToInfo(SeniorSignUpRequest request) { String[] fields = request.field().split(","); Set fieldNames = Field.fieldNames(); Set postgraduNames = Postgradu.postgraduNames(); @@ -56,8 +55,8 @@ public static Info mapToInfo(SeniorChangeRequest request) { .lab(request.lab()) .keyword(request.keyword()) .field(request.field()) - .etcPostgradu(true) - .etcField(true) + .etcPostgradu(false) + .etcField(false) .totalInfo(request.major() + request.lab() + request.field() + request.professor() + request.postgradu() + request.keyword()); @@ -73,7 +72,7 @@ public static Info mapToInfo(SeniorChangeRequest request) { return infoBuilder.build(); } - public static Info mapToInfo(SeniorSignUpRequest request) { + private static Info mapToInfo(SeniorChangeRequest request) { String[] fields = request.field().split(","); Set fieldNames = Field.fieldNames(); Set postgraduNames = Postgradu.postgraduNames(); @@ -206,129 +205,11 @@ public static SeniorMyPageUserAccountResponse mapToMyPageUserAccount(Senior seni } public static SeniorDetailResponse mapToSeniorDetail(Senior senior, List times, boolean isMine) { - Info info = senior.getInfo(); - Profile profile = senior.getProfile(); - String[] keyword = info.getKeyword().split(","); - return new SeniorDetailResponse( - isMine, - senior.getUser().getNickName(), - profile.getTerm(), - senior.getUser().getProfile(), - info.getPostgradu(), - info.getMajor(), - info.getLab(), - info.getProfessor(), - keyword, - profile.getInfo(), - profile.getOneLiner(), - profile.getTarget(), - times - ); - } - - public static SeniorSearchResponse mapToSeniorSearch(Senior senior) { - User user = senior.getUser(); - Info info = senior.getInfo(); - String[] allKeywords = info.getKeyword().split(","); - String[] keyword = Arrays.copyOf(allKeywords, Math.min(3, allKeywords.length)); - - return new SeniorSearchResponse(senior.getSeniorId(), user.getProfile(), user.getNickName(), - info.getPostgradu(), info.getMajor(), info.getLab(), info.getProfessor(), - keyword); - } - - public static SeniorProfileResponse mapToSeniorProfile(User user, Senior senior) { - User seniorUser = senior.getUser(); - Info info = senior.getInfo(); - Profile profile = senior.getProfile(); - return new SeniorProfileResponse(seniorUser.getNickName(), seniorUser.getProfile(), - info.getPostgradu(), info.getMajor(), info.getLab(), profile.getTerm(), user.getUserId(), user.getPhoneNumber()); - } - - /** - * 여기서부터 Case B 위한 코드 - */ - - public static Senior mapToSenior(User user, SeniorSignUpRequestB request) { - return Senior.builder() - .user(user) - .info(mapToInfo(request)) - .status(NONE) - .build(); - } - - public static Senior mapToSenior(User user, SeniorChangeRequestB request) { - return Senior.builder() - .user(user) - .info(mapToInfo(request)) - .status(NONE) - .build(); - } - - private static Info mapToInfo(SeniorSignUpRequestB request) { - String[] fields = request.field().split(","); - Set fieldNames = Field.fieldNames(); - Set postgraduNames = Postgradu.postgraduNames(); - - Info.InfoBuilder infoBuilder = Info.builder() - .major(request.major()) - .postgradu(request.postgradu()) - .professor(request.professor()) - .lab(request.lab()) - .keyword(request.keyword()) - .field(request.field()) - .etcPostgradu(false) - .etcField(false) - .totalInfo(request.major() + request.lab() + request.field() - + request.professor() + request.postgradu() + request.keyword()); - - for (String field : fields) { - if (!fieldNames.contains(field)) { - infoBuilder.etcField(true); - break; - } - } - if (!postgraduNames.contains(request.postgradu())) - infoBuilder.etcPostgradu(true); - - return infoBuilder.build(); - } - - private static Info mapToInfo(SeniorChangeRequestB request) { - String[] fields = request.field().split(","); - Set fieldNames = Field.fieldNames(); - Set postgraduNames = Postgradu.postgraduNames(); - - Info.InfoBuilder infoBuilder = Info.builder() - .major(request.major()) - .postgradu(request.postgradu()) - .professor(request.professor()) - .lab(request.lab()) - .keyword(request.keyword()) - .field(request.field()) - .etcPostgradu(false) - .etcField(false) - .totalInfo(request.major() + request.lab() + request.field() - + request.professor() + request.postgradu() + request.keyword()); - - for (String field : fields) { - if (!fieldNames.contains(field)) { - infoBuilder.etcField(true); - break; - } - } - if (!postgraduNames.contains(request.postgradu())) - infoBuilder.etcPostgradu(true); - - return infoBuilder.build(); - } - - public static SeniorDetailResponseB mapToSeniorDetailWithNull(Senior senior, List times, boolean isMine) { Info info = senior.getInfo(); String[] keyword = info.getKeyword().split(","); if (senior.getProfile() != null) { Profile profile = senior.getProfile(); - return new SeniorDetailResponseB( + return new SeniorDetailResponse( isMine, senior.getStatus().equals(APPROVE), senior.getUser().getNickName(), @@ -345,7 +226,7 @@ public static SeniorDetailResponseB mapToSeniorDetailWithNull(Senior senior, Lis times ); } - return new SeniorDetailResponseB( + return new SeniorDetailResponse( isMine, senior.getStatus().equals(APPROVE), senior.getUser().getNickName(), @@ -375,13 +256,13 @@ public static SeniorProfileResponse mapToSeniorProfileWithNull(User user, Senior info.getPostgradu(), info.getMajor(), info.getLab(), 30, user.getUserId(), user.getPhoneNumber()); } - public static SeniorSearchResponseB mapToSeniorSearchWithStatus(Senior senior) { + public static SeniorSearchResponse mapToSeniorSearchWithStatus(Senior senior) { User user = senior.getUser(); Info info = senior.getInfo(); String[] allKeywords = info.getKeyword().split(","); String[] keyword = Arrays.copyOf(allKeywords, Math.min(3, allKeywords.length)); - return new SeniorSearchResponseB(senior.getSeniorId(), senior.getStatus().equals(APPROVE),user.getProfile(), user.getNickName(), + return new SeniorSearchResponse(senior.getSeniorId(), senior.getStatus().equals(APPROVE),user.getProfile(), user.getNickName(), info.getPostgradu(), info.getMajor(), info.getLab(), info.getProfessor(), keyword); } diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java index 36a75987..13cbe79b 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseCase.java @@ -43,7 +43,7 @@ private SeniorDetailResponse checkIsMine(User user, Long seniorId) { } private SeniorDetailResponse getResponse(Long seniorId, boolean isMine) { - Senior senior = seniorGetService.bySeniorIdWithCertification(seniorId); + Senior senior = seniorGetService.bySeniorId(seniorId); seniorUpdateService.updateHit(senior); List availables = availableGetService.bySenior(senior); List times = availables.stream() @@ -64,7 +64,7 @@ private SeniorDetailResponse getResponseMine(Senior senior, boolean isMine) { public AllSeniorSearchResponse getSearchSenior(String search, Integer page, String sort) { Page seniors = seniorGetService.bySearch(search, page, sort); List selectSeniors = seniors.stream() - .map(SeniorMapper::mapToSeniorSearch) + .map(SeniorMapper::mapToSeniorSearchWithStatus) .toList(); long totalElements = seniors.getTotalElements(); return new AllSeniorSearchResponse(selectSeniors, totalElements); @@ -74,7 +74,7 @@ public AllSeniorSearchResponse getSearchSenior(String search, Integer page, Stri public AllSeniorSearchResponse getFieldSenior(String field, String postgradu, Integer page) { Page seniors = seniorGetService.byField(field, postgradu, page); List selectSeniors = seniors.stream() - .map(SeniorMapper::mapToSeniorSearch) + .map(SeniorMapper::mapToSeniorSearchWithStatus) .toList(); long totalElements = seniors.getTotalElements(); return new AllSeniorSearchResponse(selectSeniors, totalElements); @@ -82,13 +82,13 @@ public AllSeniorSearchResponse getFieldSenior(String field, String postgradu, In @Transactional(readOnly = true) public SeniorProfileResponse getSeniorProfile(User user, Long seniorId) { - Senior senior = seniorGetService.bySeniorIdWithCertification(seniorId); - return mapToSeniorProfile(user, senior); + Senior senior = seniorGetService.bySeniorId(seniorId); + return mapToSeniorProfileWithNull(user, senior); } @Transactional(readOnly = true) public AvailableTimesResponse getSeniorTimes(Long seniorId) { - Senior senior = seniorGetService.bySeniorIdWithCertification(seniorId); + Senior senior = seniorGetService.bySeniorId(seniorId); List availables = availableGetService.bySenior(senior); List times = availables.stream() .map(AvailableMapper::mapToAvailableTimes) @@ -104,74 +104,4 @@ public AllSeniorIdResponse getAllSeniorId() { .toList(); return new AllSeniorIdResponse(seniorIds); } - - /** - * 여기서부터 Case B를 위한 코드 - */ - public SeniorDetailResponseB getSeniorDetailB(User user, Long seniorId) { - if (user != null && user.getRole() == SENIOR) - return checkIsMineB(user, seniorId); - return getResponseB(seniorId, false); - } - - private SeniorDetailResponseB checkIsMineB(User user, Long seniorId) { - Senior mySenior = seniorGetService.byUser(user); - if (mySenior.getSeniorId().equals(seniorId)) - return getResponseMineB(mySenior, true); - return getResponseB(seniorId, false); - } - - private SeniorDetailResponseB getResponseB(Long seniorId, boolean isMine) { - Senior senior = seniorGetService.bySeniorIdWithAnyCertification(seniorId); - seniorUpdateService.updateHit(senior); - List availables = availableGetService.bySeniorWithAny(senior); - List times = availables.stream() - .map(AvailableMapper::mapToAvailableTimes) - .toList(); - return mapToSeniorDetailWithNull(senior, times, isMine); - } - - private SeniorDetailResponseB getResponseMineB(Senior senior, boolean isMine) { - List availables = availableGetService.byMine(senior); - List times = availables.stream() - .map(AvailableMapper::mapToAvailableTimes) - .toList(); - return mapToSeniorDetailWithNull(senior, times, isMine); - } - - @Transactional(readOnly = true) - public SeniorProfileResponse getSeniorProfileB(User user, Long seniorId) { - Senior senior = seniorGetService.bySeniorIdWithAnyCertification(seniorId); - return mapToSeniorProfileWithNull(user, senior); - } - - @Transactional(readOnly = true) - public AvailableTimesResponse getSeniorTimesB(Long seniorId) { - Senior senior = seniorGetService.bySeniorIdWithAnyCertification(seniorId); - List availables = availableGetService.bySeniorWithAny(senior); - List times = availables.stream() - .map(AvailableMapper::mapToAvailableTimes) - .toList(); - return new AvailableTimesResponse(senior.getUser().getNickName(), times); - } - - @Transactional(readOnly = true) - public AllSeniorSearchResponseB getSearchSeniorB(String search, Integer page, String sort) { - Page seniors = seniorGetService.bySearchWithAny(search, page, sort); - List selectSeniors = seniors.stream() - .map(SeniorMapper::mapToSeniorSearchWithStatus) - .toList(); - long totalElements = seniors.getTotalElements(); - return new AllSeniorSearchResponseB(selectSeniors, totalElements); - } - - @Transactional(readOnly = true) - public AllSeniorSearchResponseB getFieldSeniorB(String field, String postgradu, Integer page) { - Page seniors = seniorGetService.byFieldWithAny(field, postgradu, page); - List selectSeniors = seniors.stream() - .map(SeniorMapper::mapToSeniorSearchWithStatus) - .toList(); - long totalElements = seniors.getTotalElements(); - return new AllSeniorSearchResponseB(selectSeniors, totalElements); - } } diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java index 371e129b..00688c11 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java @@ -70,13 +70,4 @@ public SeniorPossibleResponse checkUser(User user) { return new SeniorPossibleResponse(FALSE, user.getSocialId()); return new SeniorPossibleResponse(TRUE, user.getSocialId()); } - - /** - * Case B 코드 - */ - public SeniorMyPageResponse getSeniorMyPageB(User user) { - Senior senior = seniorGetService.byUser(user); - Optional profile = ofNullable(senior.getProfile()); - return mapToSeniorMyPageInfo(senior, senior.getStatus(), profile.isPresent()); - } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepository.java b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepository.java index 687a44dd..d8a5c5c5 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepository.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepository.java @@ -10,18 +10,11 @@ import java.util.Optional; public interface SeniorDslRepository { - Page findAllBySearchSenior(String search, String sort, Pageable pageable); - Page findAllByFieldSenior(String field, String postgradu, Pageable pageable); Page findAllBySearchSeniorWithAdmin(String search, Pageable pageable); Optional findBySeniorId(Long seniorId); Optional findByUserWithAll(User user); List findAllSeniorAndAccount(); List findAllSenior(); - - /** - * Case B - */ - Optional findBySeniorIdWithAnyCertification(Long seniorId); - Page findAllByFieldAnySenior(String field, String postgradu, Pageable pageable); - Page findAllBySearchAnySenior(String search, String sort, Pageable pageable); + Page findAllByFieldSenior(String field, String postgradu, Pageable pageable); + Page findAllBySearchSenior(String search, String sort, Pageable pageable); } 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 dda35f89..e484d5b7 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 @@ -21,7 +21,6 @@ import static com.postgraduate.domain.account.domain.entity.QAccount.account; import static com.postgraduate.domain.senior.domain.entity.QSenior.senior; -import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE; import static com.postgraduate.domain.user.domain.entity.QUser.user; import static com.querydsl.core.types.Order.ASC; import static com.querydsl.core.types.Order.DESC; @@ -46,9 +45,7 @@ public Page findAllBySearchSenior(String search, String sort, Pageable p .where( senior.info.totalInfo.like("%" + search + "%") .or(senior.user.nickName.like("%" + search + "%")), - senior.status.eq(APPROVE), - senior.user.isDelete.eq(FALSE), - senior.profile.isNotNull() + senior.user.isDelete.eq(FALSE) ) .orderBy(orderSpecifier(sort)) .orderBy(senior.user.nickName.asc()). @@ -63,9 +60,7 @@ public Page findAllBySearchSenior(String search, String sort, Pageable p .where( senior.info.totalInfo.like("%" + search + "%") .or(senior.user.nickName.like("%" + search + "%")), - senior.status.eq(APPROVE), - senior.user.isDelete.eq(FALSE), - senior.profile.isNotNull() + senior.user.isDelete.eq(FALSE) ) .fetchOne(); @@ -90,9 +85,7 @@ public Page findAllByFieldSenior(String field, String postgradu, Pageabl .where( fieldSpecifier(field), postgraduSpecifier(postgradu), - senior.status.eq(APPROVE), - senior.user.isDelete.eq(FALSE), - senior.profile.isNotNull() + senior.user.isDelete.eq(FALSE) ) .orderBy(senior.hit.desc()) .orderBy(senior.user.nickName.asc()) @@ -107,9 +100,7 @@ public Page findAllByFieldSenior(String field, String postgradu, Pageabl .where( fieldSpecifier(field), postgraduSpecifier(postgradu), - senior.status.eq(APPROVE), - senior.user.isDelete.eq(FALSE), - senior.profile.isNotNull() + senior.user.isDelete.eq(FALSE) ) .fetchOne(); @@ -185,21 +176,6 @@ private BooleanExpression searchLike(String search) { return null; } - @Override - public Optional findBySeniorId(Long seniorId) { - return ofNullable(queryFactory.selectFrom(senior) - .distinct() - .leftJoin(senior.user, user) - .fetchJoin() - .where( - senior.seniorId.eq(seniorId), - senior.profile.isNotNull(), - senior.status.eq(APPROVE), - senior.user.isDelete.isFalse() - ) - .fetchOne()); - } - @Override public Optional findByUserWithAll(User seniorUser) { return ofNullable(queryFactory.selectFrom(senior) @@ -247,11 +223,8 @@ public List findAllSenior() { .fetch(); } - /** - * Case B를 위한 코드 - */ @Override - public Optional findBySeniorIdWithAnyCertification(Long seniorId) { + public Optional findBySeniorId(Long seniorId) { return ofNullable(queryFactory.selectFrom(senior) .distinct() .leftJoin(senior.user, user) @@ -262,67 +235,4 @@ public Optional findBySeniorIdWithAnyCertification(Long seniorId) { ) .fetchOne()); } - - @Override - public Page findAllBySearchAnySenior(String search, String sort, Pageable pageable) { - List seniors = queryFactory.selectFrom(senior) - .distinct() - .leftJoin(senior.user, user) - .fetchJoin() - .where( - senior.info.totalInfo.like("%" + search + "%") - .or(senior.user.nickName.like("%" + search + "%")), - senior.user.isDelete.eq(FALSE) - ) - .orderBy(orderSpecifier(sort)) - .orderBy(senior.user.nickName.asc()). - offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); - - Long total = queryFactory.select(senior.count()) - .from(senior) - .distinct() - .leftJoin(senior.user, user) - .where( - senior.info.totalInfo.like("%" + search + "%") - .or(senior.user.nickName.like("%" + search + "%")), - senior.user.isDelete.eq(FALSE) - ) - .fetchOne(); - - - return new PageImpl<>(seniors, pageable, total); - } - - @Override - public Page findAllByFieldAnySenior(String field, String postgradu, Pageable pageable) { - List seniors = queryFactory.selectFrom(senior) - .distinct() - .leftJoin(senior.user, user) - .fetchJoin() - .where( - fieldSpecifier(field), - postgraduSpecifier(postgradu), - senior.user.isDelete.eq(FALSE) - ) - .orderBy(senior.hit.desc()) - .orderBy(senior.user.nickName.asc()) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); - - Long total = queryFactory.select(senior.count()) - .from(senior) - .distinct() - .leftJoin(senior.user, user) - .where( - fieldSpecifier(field), - postgraduSpecifier(postgradu), - senior.user.isDelete.eq(FALSE) - ) - .fetchOne(); - - return new PageImpl<>(seniors, pageable, total); - } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java index 40752f36..a2428c43 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java @@ -9,7 +9,6 @@ public interface SeniorRepository extends JpaRepository, SeniorDslRepository { Optional findByUser(User user); - Optional findBySeniorIdAndUser_IsDelete(Long seniorId, Boolean isDelete); Optional findByUser_NickNameAndUser_IsDelete(String nickName, Boolean isDelete); List findAllByUser_IsDelete(Boolean isDelete); } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java index a5db08a9..dc609f30 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java @@ -35,41 +35,17 @@ public Senior byUserWithAll(User user) { .orElseThrow(NoneSeniorException::new); } - public Senior bySeniorId(Long seniorId) { - return seniorRepository.findBySeniorIdAndUser_IsDelete(seniorId, FALSE) - .orElseThrow(NoneSeniorException::new); - } - public Senior bySeniorNickName(String nickName) { return seniorRepository.findByUser_NickNameAndUser_IsDelete(nickName, FALSE) .orElseThrow(NoneSeniorException::new); } - public Senior bySeniorIdWithCertification(Long seniorId) { - return seniorRepository.findBySeniorId(seniorId) - .orElseThrow(NoneSeniorException::new); - } - public Page all(Integer page, String search) { page = page == null ? 1 : page; Pageable pageable = PageRequest.of(page - 1, ADMIN_PAGE_SIZE); return seniorRepository.findAllBySearchSeniorWithAdmin(search, pageable); } - public Page bySearch(String search, Integer page, String sort) { - if (page == null) - page = 1; - Pageable pageable = PageRequest.of(page-1, SENIOR_PAGE_SIZE); - return seniorRepository.findAllBySearchSenior(search, sort, pageable); - } - - public Page byField(String field, String postgradu, Integer page) { - if (page == null) - page = 1; - Pageable pageable = PageRequest.of(page-1, SENIOR_PAGE_SIZE); - return seniorRepository.findAllByFieldSenior(field, postgradu, pageable); - } - public List allSeniorId() { return seniorRepository.findAllByUser_IsDelete(FALSE); } @@ -78,25 +54,22 @@ public List allSenior() { return seniorRepository.findAllSenior(); } - /** - * Case B - */ - public Senior bySeniorIdWithAnyCertification(Long seniorId) { - return seniorRepository.findBySeniorIdWithAnyCertification(seniorId) + public Senior bySeniorId(Long seniorId) { + return seniorRepository.findBySeniorId(seniorId) .orElseThrow(NoneSeniorException::new); } - public Page bySearchWithAny(String search, Integer page, String sort) { + public Page bySearch(String search, Integer page, String sort) { if (page == null) page = 1; Pageable pageable = PageRequest.of(page-1, SENIOR_PAGE_SIZE); - return seniorRepository.findAllBySearchAnySenior(search, sort, pageable); + return seniorRepository.findAllBySearchSenior(search, sort, pageable); } - public Page byFieldWithAny(String field, String postgradu, Integer page) { + public Page byField(String field, String postgradu, Integer page) { if (page == null) page = 1; Pageable pageable = PageRequest.of(page-1, SENIOR_PAGE_SIZE); - return seniorRepository.findAllByFieldAnySenior(field, postgradu, pageable); + return seniorRepository.findAllByFieldSenior(field, postgradu, pageable); } } diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java index 79c616a9..93ad3895 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java @@ -148,48 +148,48 @@ public ResponseDto checkRole(@AuthenticationPrincipal Us */ @GetMapping("/{seniorId}/b") @Operation(summary = "대학원생 상세 조회(Case B) | 토큰 필요") - public ResponseDto getSeniorDetailsB(@AuthenticationPrincipal User user, + public ResponseDto getSeniorDetailsB(@AuthenticationPrincipal User user, @PathVariable Long seniorId) { - SeniorDetailResponseB seniorDetail = seniorInfoUseCase.getSeniorDetailB(user, seniorId); + SeniorDetailResponse seniorDetail = seniorInfoUseCase.getSeniorDetail(user, seniorId); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_INFO.getMessage(), seniorDetail); } @GetMapping("/{seniorId}/profile/b") @Operation(summary = "대학원생 닉네임~연구실 등 기본 정보 확인(Case B) | 토큰 필요", description = "신청서 완료 후 결제시 노출 필요") public ResponseDto getSeniorProfileB(@AuthenticationPrincipal User user, @PathVariable Long seniorId) { - SeniorProfileResponse seniorProfile = seniorInfoUseCase.getSeniorProfileB(user, seniorId); + SeniorProfileResponse seniorProfile = seniorInfoUseCase.getSeniorProfile(user, seniorId); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_INFO.getMessage(), seniorProfile); } @GetMapping("/{seniorId}/times/b") @Operation(summary = "대학원생 가능 시간 확인(Case B) | 토큰 필요", description = "신청서 작성에서 가능 시간 작성시 노출 필요") public ResponseDto getSeniorTimesB(@PathVariable Long seniorId) { - AvailableTimesResponse times = seniorInfoUseCase.getSeniorTimesB(seniorId); + AvailableTimesResponse times = seniorInfoUseCase.getSeniorTimes(seniorId); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_TIME.getMessage(), times); } @GetMapping("/search/b") @Operation(summary = "대학원생 검색어 검색(Case B)", description = "find 필수, sort 선택 - 안보낼 경우 아예 파라미터 추가x (조회수 낮은순 low, 높은순 high), page선택 (안보내면 기본 1페이지)") - public ResponseDto getSearchSeniorB(@RequestParam String find, + public ResponseDto getSearchSeniorB(@RequestParam String find, @RequestParam(required = false) String sort, @RequestParam(required = false) Integer page) { - AllSeniorSearchResponseB searchSenior = seniorInfoUseCase.getSearchSeniorB(find, page, sort); + AllSeniorSearchResponse searchSenior = seniorInfoUseCase.getSearchSenior(find, page, sort); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), searchSenior); } @GetMapping("/field/b") @Operation(summary = "대학원생 필드 검색(Case B)", description = "분야 (분야1,분야2 이런식으로, 다른분야 : others), 대학원 필수 (대학원1,대학원2 이런식으로, 다른학교 : others, 전체 : all), 페이지 선택 ") - public ResponseDto getFieldSeniorB(@RequestParam String field, + public ResponseDto getFieldSeniorB(@RequestParam String field, @RequestParam String postgradu, @RequestParam(required = false) Integer page) { - AllSeniorSearchResponseB searchSenior = seniorInfoUseCase.getFieldSeniorB(field, postgradu, page); + AllSeniorSearchResponse searchSenior = seniorInfoUseCase.getFieldSenior(field, postgradu, page); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_LIST_INFO.getMessage(), searchSenior); } @GetMapping("/me/b") @Operation(summary = "대학원생 마이페이지 기본 정보 조회 | 토큰 필요(Case B)", description = "닉네임, 프로필 사진, 프로필 작성 여부") public ResponseDto getSeniorInfoB(@AuthenticationPrincipal User user) { - SeniorMyPageResponse seniorMyPageResponse = seniorMyPageUseCase.getSeniorMyPageB(user); + SeniorMyPageResponse seniorMyPageResponse = seniorMyPageUseCase.getSeniorMyPage(user); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_INFO.getMessage(), seniorMyPageResponse); } } diff --git a/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java b/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java index 1317061e..e7f861cd 100644 --- a/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java +++ b/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java @@ -1,7 +1,6 @@ package com.postgraduate.domain.user.application.mapper; import com.postgraduate.domain.auth.application.dto.req.SeniorSignUpRequest; -import com.postgraduate.domain.auth.application.dto.req.SeniorSignUpRequestB; import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; import com.postgraduate.domain.user.application.dto.res.UserInfoResponse; import com.postgraduate.domain.user.application.dto.res.UserMyPageResponse; @@ -50,18 +49,4 @@ public static User mapToUser(SeniorSignUpRequest request, String profile) { .role(SENIOR) .build(); } - - /** - * 여기부터 Case B를 위한 코드 - */ - public static User mapToUser(SeniorSignUpRequestB request, String profile) { - return User.builder() - .socialId(request.socialId()) - .nickName(request.nickName()) - .phoneNumber(request.phoneNumber()) - .marketingReceive(request.marketingReceive()) - .profile(profile) - .role(SENIOR) - .build(); - } } diff --git a/src/test/java/com/postgraduate/Integration/AuthControllerTest.java b/src/test/java/com/postgraduate/Integration/AuthControllerTest.java index 2e0d74e6..72e7c18b 100644 --- a/src/test/java/com/postgraduate/Integration/AuthControllerTest.java +++ b/src/test/java/com/postgraduate/Integration/AuthControllerTest.java @@ -224,7 +224,7 @@ void singUpSenior() throws Exception { String request = objectMapper.writeValueAsString( new SeniorSignUpRequest(anonymousUserSocialId, "01012345678", "새로운닉네임", true, "전공", "서울대학교", "교수", "연구실", - "AI", "키워드", "certification") + "AI", "키워드") ); mvc.perform(post("/auth/senior/signup") @@ -244,7 +244,7 @@ void singUpSenior() throws Exception { void singUpSenior(String empty) throws Exception { String request = objectMapper.writeValueAsString( new SeniorSignUpRequest(anonymousUserSocialId, "01012345678", "새로운닉네임", - true, empty, empty, empty, empty, empty, empty, empty) + true, empty, empty, empty, empty, empty, empty) ); mvc.perform(post("/auth/senior/signup") @@ -262,7 +262,7 @@ void changeSenior() throws Exception { String request = objectMapper.writeValueAsString( new SeniorChangeRequest("major", "field", "교수", "연구실", - "AI", "키워드", "certification") + "AI", "키워드") ); mvc.perform(post("/auth/senior/change") @@ -284,7 +284,7 @@ void changeSenior(String empty) throws Exception { String userAccessToken = jwtUtil.generateAccessToken(user.getUserId(), USER); String request = objectMapper.writeValueAsString( - new SeniorChangeRequest(empty, empty, empty, empty, empty, empty, empty) + new SeniorChangeRequest(empty, empty, empty, empty, empty, empty) ); mvc.perform(post("/auth/senior/change") diff --git a/src/test/java/com/postgraduate/Integration/SeniorControllerTest.java b/src/test/java/com/postgraduate/Integration/SeniorControllerTest.java index 5d647244..c282e102 100644 --- a/src/test/java/com/postgraduate/Integration/SeniorControllerTest.java +++ b/src/test/java/com/postgraduate/Integration/SeniorControllerTest.java @@ -529,20 +529,6 @@ void getSeniorDetailsOthers() throws Exception { .andExpect(jsonPath("$.data.times").isNotEmpty()); } - @ParameterizedTest - @EnumSource(value = Status.class, names = {"NOT_APPROVE", "WAITING"}) - @WithMockUser(authorities = {"USER", "SENIOR", "ADMIN"}) - @DisplayName("승인되지 않은 대학원생은 조회되지 않는다.") - void getNotApprovedSeniorDetails(Status status) throws Exception { - senior.updateStatus(status); - seniorRepository.save(senior); - - mvc.perform(get("/senior/{seniorId}", senior.getSeniorId())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.code").value(SENIOR_NOT_FOUND.getCode())) - .andExpect(jsonPath("$.message").value(NOT_FOUND_SENIOR.getMessage())); - } - @Test @WithMockUser(authorities = {"USER"}) @DisplayName("결제 시 대학원생의 기본 정보를 확인한다") diff --git a/src/test/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseTypeTest.java b/src/test/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseTypeTest.java index ce403141..63e7b156 100644 --- a/src/test/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseTypeTest.java +++ b/src/test/java/com/postgraduate/domain/auth/application/usecase/oauth/SignUpUseTypeTest.java @@ -121,7 +121,7 @@ void invalidPhoneNumber() { void seniorSignUp() { SeniorSignUpRequest request = new SeniorSignUpRequest(user.getSocialId(), user.getPhoneNumber(), user.getNickName(), user.getMarketingReceive(), info.getMajor(), info.getPostgradu(), info.getProfessor(), info.getLab(), info.getField(), - info.getKeyword(), senior.getCertification()); + info.getKeyword()); User saveUser = signUpUseCase.seniorSignUp(request); @@ -138,7 +138,7 @@ void seniorSignUp() { void invalidKeyword() { SeniorSignUpRequest request = new SeniorSignUpRequest(user.getSocialId(), user.getPhoneNumber(), user.getNickName(), user.getMarketingReceive(), info.getMajor(), info.getPostgradu(), info.getProfessor(), info.getLab(), info.getField(), - info.getKeyword(), senior.getCertification()); + info.getKeyword()); doThrow(KeywordException.class) .when(seniorUtils) @@ -152,8 +152,7 @@ void invalidKeyword() { @DisplayName("선배 변경 테스트") void changeSenior() { SeniorChangeRequest seniorChangeRequest = new SeniorChangeRequest(info.getMajor(), info.getPostgradu(), info.getProfessor(), - info.getLab(), info.getField(), info.getKeyword(), - senior.getCertification()); + info.getLab(), info.getField(), info.getKeyword()); given(userGetService.byUserId(user.getUserId())) .willReturn(user); diff --git a/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java b/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java index fd72a84c..95c08702 100644 --- a/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java +++ b/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java @@ -172,7 +172,7 @@ void singUpSenior() throws Exception { String request = objectMapper.writeValueAsString( new SeniorSignUpRequest(user.getSocialId(), "01012345678", "새로운닉네임", true, "전공", "서울대학교", "교수", "연구실", - "AI", "키워드", "certification") + "AI", "키워드") ); JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER); @@ -202,7 +202,7 @@ void singUpSenior() throws Exception { void changeSenior() throws Exception { String request = objectMapper.writeValueAsString( new SeniorChangeRequest("major", "field", "교수", "연구실", - "AI", "키워드", "certification") + "AI", "키워드") ); JwtTokenResponse tokenResponse = new JwtTokenResponse("access", 10, "refresh", 10, USER); diff --git a/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseTypeTest.java b/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseTypeTest.java index 6ca67f28..833e7398 100644 --- a/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseTypeTest.java +++ b/src/test/java/com/postgraduate/domain/senior/application/usecase/SeniorInfoUseTypeTest.java @@ -74,7 +74,7 @@ void getSeniorDetail() { Available available3 = new Available(3L, "수", "12:00", "18:00", senior); List availables = List.of(available1, available2, available3); - given(seniorGetService.bySeniorIdWithCertification(any())) + given(seniorGetService.bySeniorId(any())) .willReturn(senior); given(availableGetService.bySenior(senior)) .willReturn(availables); @@ -163,7 +163,7 @@ void getFieldSeniorWithPage() { @Test @DisplayName("선배 프로필 조회") void getSeniorProfile() { - given(seniorGetService.bySeniorIdWithCertification(senior.getSeniorId())) + given(seniorGetService.bySeniorId(senior.getSeniorId())) .willReturn(senior); SeniorProfileResponse seniorProfile = seniorInfoUseCase.getSeniorProfile(originUser, senior.getSeniorId()); @@ -192,7 +192,7 @@ void getSeniorTimes() { Available available3 = new Available(3L, "수", "12:00", "18:00", senior); List availables = List.of(available1, available2, available3); - given(seniorGetService.bySeniorIdWithCertification(senior.getSeniorId())) + given(seniorGetService.bySeniorId(senior.getSeniorId())) .willReturn(senior); given(availableGetService.bySenior(senior)) .willReturn(availables); diff --git a/src/test/java/com/postgraduate/domain/senior/domain/service/SeniorGetServiceTest.java b/src/test/java/com/postgraduate/domain/senior/domain/service/SeniorGetServiceTest.java index 7c6d59d9..3bcefca9 100644 --- a/src/test/java/com/postgraduate/domain/senior/domain/service/SeniorGetServiceTest.java +++ b/src/test/java/com/postgraduate/domain/senior/domain/service/SeniorGetServiceTest.java @@ -74,7 +74,7 @@ void byUserWithAll() { @Test @DisplayName("SeniorId 기반 Senior 조회 예외 테스트") void bySeniorIdFail() { - given(seniorRepository.findBySeniorIdAndUser_IsDelete(seniorId, FALSE)) + given(seniorRepository.findBySeniorId(seniorId)) .willReturn(ofNullable(null)); assertThatThrownBy(() -> seniorGetService.bySeniorId(seniorId)) @@ -84,7 +84,7 @@ void bySeniorIdFail() { @Test @DisplayName("SeniorId 기반 Senior 조회 테스트") void bySeniorId() { - given(seniorRepository.findBySeniorIdAndUser_IsDelete(seniorId, FALSE)) + given(seniorRepository.findBySeniorId(seniorId)) .willReturn(of(senior)); assertThat(seniorGetService.bySeniorId(seniorId)) @@ -110,24 +110,4 @@ void bySeniorNickName() { assertThat(seniorGetService.bySeniorNickName(nickName)) .isEqualTo(senior); } - - @Test - @DisplayName("Certification 기반 Senior 조회 예외 테스트") - void byCertificationFail() { - given(seniorRepository.findBySeniorId(seniorId)) - .willReturn(ofNullable(null)); - - assertThatThrownBy(() -> seniorGetService.bySeniorIdWithCertification(seniorId)) - .isInstanceOf(NoneSeniorException.class); - } - - @Test - @DisplayName("Certification 기반 Senior 조회 테스트") - void byCertification() { - given(seniorRepository.findBySeniorId(seniorId)) - .willReturn(of(senior)); - - assertThat(seniorGetService.bySeniorIdWithCertification(seniorId)) - .isEqualTo(senior); - } } \ No newline at end of file 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 d28a4446..000863b9 100644 --- a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java +++ b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java @@ -22,6 +22,7 @@ import java.util.List; +import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.*; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.*; import static org.mockito.ArgumentMatchers.any; @@ -286,7 +287,7 @@ void getSeniorDetails(boolean tf) throws Exception { .map(available -> new AvailableTimeResponse(available.getDay(), available.getStartTime(), available.getEndTime())) .toList(); SeniorDetailResponse response = new SeniorDetailResponse( - tf, userOfSenior.getNickName(), profile.getTerm(), userOfSenior.getProfile(), info.getPostgradu(), info.getMajor(), + tf, tf, userOfSenior.getNickName(), profile.getTerm(), userOfSenior.getProfile(), info.getPostgradu(), info.getMajor(), info.getLab(), info.getProfessor(), info.getKeyword().split(","), profile.getInfo(), profile.getOneLiner(), profile.getTarget(), availableTimeResponses ); @@ -300,6 +301,7 @@ void getSeniorDetails(boolean tf) throws Exception { .andExpect(jsonPath("$.code").value(SENIOR_FIND.getCode())) .andExpect(jsonPath("$.message").value(GET_SENIOR_INFO.getMessage())) .andExpect(jsonPath("$.data.isMine").value(tf)) + .andExpect(jsonPath("$.data.certification").value(tf)) .andExpect(jsonPath("$.data.nickName").value(response.nickName())) .andExpect(jsonPath("$.data.term").value(response.term())) .andExpect(jsonPath("$.data.profile").value(response.profile())) @@ -363,13 +365,14 @@ void getSeniorTimes() throws Exception { .andExpect(jsonPath("$.data.times").isArray()); } - @Test + @ParameterizedTest + @ValueSource(booleans = {true, false}) @WithMockUser @DisplayName("대학원생을 검색한다") - void getSearchSenior() throws Exception { + void getSearchSenior(boolean tf) throws Exception { Info info = senior.getInfo(); SeniorSearchResponse searchResponse = new SeniorSearchResponse( - senior.getSeniorId(), userOfSenior.getProfile(), userOfSenior.getNickName(), + senior.getSeniorId(), tf, userOfSenior.getProfile(), userOfSenior.getNickName(), info.getPostgradu(), info.getMajor(), info.getLab(), info.getProfessor(), info.getKeyword().split(",") ); List seniorSearchResponses = List.of(searchResponse, mock(SeniorSearchResponse.class), mock(SeniorSearchResponse.class)); @@ -384,6 +387,7 @@ void getSearchSenior() throws Exception { .andExpect(jsonPath("$.code").value(SENIOR_FIND.getCode())) .andExpect(jsonPath("$.message").value(GET_SENIOR_LIST_INFO.getMessage())) .andExpect(jsonPath("$.data.seniorSearchResponses[0].seniorId").value(searchResponse.seniorId())) + .andExpect(jsonPath("$.data.seniorSearchResponses[0].certification").value(tf)) .andExpect(jsonPath("$.data.seniorSearchResponses[0].profile").value(searchResponse.profile())) .andExpect(jsonPath("$.data.seniorSearchResponses[0].nickName").value(searchResponse.nickName())) .andExpect(jsonPath("$.data.seniorSearchResponses[0].postgradu").value(searchResponse.postgradu())) @@ -393,13 +397,14 @@ void getSearchSenior() throws Exception { .andExpect(jsonPath("$.data.totalElements").value(seniorSearchResponses.size())); } - @Test + @ParameterizedTest + @ValueSource(booleans = {true, false}) @WithMockUser @DisplayName("대학원생을 분야와 대학교로 검색한다") - void getFieldSenior() throws Exception { + void getFieldSenior(boolean tf) throws Exception { Info info = senior.getInfo(); SeniorSearchResponse searchResponse = new SeniorSearchResponse( - senior.getSeniorId(), userOfSenior.getProfile(), userOfSenior.getNickName(), + senior.getSeniorId(), tf, userOfSenior.getProfile(), userOfSenior.getNickName(), info.getPostgradu(), info.getMajor(), info.getLab(), info.getProfessor(), info.getKeyword().split(",") ); List seniorSearchResponses = List.of(searchResponse, mock(SeniorSearchResponse.class), mock(SeniorSearchResponse.class)); @@ -416,6 +421,7 @@ void getFieldSenior() throws Exception { .andExpect(jsonPath("$.code").value(SENIOR_FIND.getCode())) .andExpect(jsonPath("$.message").value(GET_SENIOR_LIST_INFO.getMessage())) .andExpect(jsonPath("$.data.seniorSearchResponses[0].seniorId").value(searchResponse.seniorId())) + .andExpect(jsonPath("$.data.seniorSearchResponses[0].certification").value(tf)) .andExpect(jsonPath("$.data.seniorSearchResponses[0].profile").value(searchResponse.profile())) .andExpect(jsonPath("$.data.seniorSearchResponses[0].nickName").value(searchResponse.nickName())) .andExpect(jsonPath("$.data.seniorSearchResponses[0].postgradu").value(searchResponse.postgradu()))