-
Notifications
You must be signed in to change notification settings - Fork 8
feat: 어드민 멘토 승격 요청 페이징 조회 기능 추가 #576
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
Merged
sukangpunch
merged 7 commits into
solid-connection:develop
from
sukangpunch:feat/528-admin-mentor-application-pagination
Nov 24, 2025
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4947174
feat: 어드민 멘토 지원서 페이징 조회 기능 추가
sukangpunch 28a97e7
test: 어드민 멘토 지원서 페이징 조회 테스트 추가
sukangpunch 4f66034
feat: MentorApplication 엔티티에 approved_at 필드 추가 flyway 스크립트 작성
sukangpunch ed318cb
fix: 파일 끝에 개행 추가
sukangpunch bbde8fc
refactor: 페이징 조회 시 count 쿼리에 불필요한 조인 막기
sukangpunch 5613500
fix: 코드래빗 리뷰 적용
sukangpunch 06a0492
test: 기대하는 값이랑 다른 테스트 응답을 수정합니다
sukangpunch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...n/java/com/example/solidconnection/admin/controller/AdminMentorApplicationController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.example.solidconnection.admin.controller; | ||
|
|
||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchCondition; | ||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchResponse; | ||
| import com.example.solidconnection.admin.service.AdminMentorApplicationService; | ||
| import com.example.solidconnection.common.response.PageResponse; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.ModelAttribute; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RequestMapping("/admin/mentor-applications") | ||
| @RestController | ||
| @Slf4j | ||
| public class AdminMentorApplicationController { | ||
| private final AdminMentorApplicationService adminMentorApplicationService; | ||
|
|
||
| @GetMapping | ||
| public ResponseEntity<PageResponse<MentorApplicationSearchResponse>> searchMentorApplications( | ||
| @Valid @ModelAttribute MentorApplicationSearchCondition mentorApplicationSearchCondition, | ||
| Pageable pageable | ||
| ) { | ||
| Page<MentorApplicationSearchResponse> page = adminMentorApplicationService.searchMentorApplications( | ||
| mentorApplicationSearchCondition, | ||
| pageable | ||
| ); | ||
|
|
||
| return ResponseEntity.ok(PageResponse.of(page)); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/example/solidconnection/admin/dto/MentorApplicationResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| import com.example.solidconnection.mentor.domain.MentorApplicationStatus; | ||
| import java.time.ZonedDateTime; | ||
|
|
||
| public record MentorApplicationResponse( | ||
| long id, | ||
| String region, | ||
| String country, | ||
| String university, | ||
| String mentorProofUrl, | ||
| MentorApplicationStatus mentorApplicationStatus, | ||
| String rejectedReason, | ||
| ZonedDateTime createdAt, | ||
| ZonedDateTime approvedAt | ||
| ) { | ||
|
|
||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/example/solidconnection/admin/dto/MentorApplicationSearchCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| import com.example.solidconnection.mentor.domain.MentorApplicationStatus; | ||
| import java.time.LocalDate; | ||
|
|
||
| public record MentorApplicationSearchCondition( | ||
| MentorApplicationStatus mentorApplicationStatus, | ||
| String keyword, | ||
| LocalDate createdAt | ||
| ) { | ||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/example/solidconnection/admin/dto/MentorApplicationSearchResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| public record MentorApplicationSearchResponse( | ||
| SiteUserResponse siteUserResponse, | ||
| MentorApplicationResponse mentorApplicationResponse | ||
| ) { | ||
|
|
||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/example/solidconnection/admin/service/AdminMentorApplicationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.example.solidconnection.admin.service; | ||
|
|
||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchCondition; | ||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchResponse; | ||
| import com.example.solidconnection.mentor.repository.MentorApplicationRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class AdminMentorApplicationService { | ||
|
|
||
| private final MentorApplicationRepository mentorApplicationRepository; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public Page<MentorApplicationSearchResponse> searchMentorApplications( | ||
| MentorApplicationSearchCondition mentorApplicationSearchCondition, | ||
| Pageable pageable | ||
| ) { | ||
| return mentorApplicationRepository.searchMentorApplications(mentorApplicationSearchCondition, pageable); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...m/example/solidconnection/mentor/repository/custom/MentorApplicationFilterRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.example.solidconnection.mentor.repository.custom; | ||
|
|
||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchCondition; | ||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchResponse; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
|
|
||
| public interface MentorApplicationFilterRepository { | ||
|
|
||
| Page<MentorApplicationSearchResponse> searchMentorApplications(MentorApplicationSearchCondition mentorApplicationSearchCondition, Pageable pageable); | ||
|
|
||
| } |
145 changes: 145 additions & 0 deletions
145
...ample/solidconnection/mentor/repository/custom/MentorApplicationFilterRepositoryImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| package com.example.solidconnection.mentor.repository.custom; | ||
|
|
||
| import static com.example.solidconnection.location.country.domain.QCountry.country; | ||
| import static com.example.solidconnection.location.region.domain.QRegion.region; | ||
| import static com.example.solidconnection.mentor.domain.QMentorApplication.mentorApplication; | ||
| import static com.example.solidconnection.siteuser.domain.QSiteUser.siteUser; | ||
| import static com.example.solidconnection.university.domain.QUniversity.university; | ||
| import static org.springframework.util.StringUtils.hasText; | ||
|
|
||
| import com.example.solidconnection.admin.dto.MentorApplicationResponse; | ||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchCondition; | ||
| import com.example.solidconnection.admin.dto.MentorApplicationSearchResponse; | ||
| import com.example.solidconnection.admin.dto.SiteUserResponse; | ||
| import com.example.solidconnection.mentor.domain.MentorApplicationStatus; | ||
| import com.querydsl.core.types.ConstructorExpression; | ||
| import com.querydsl.core.types.Projections; | ||
| import com.querydsl.core.types.dsl.BooleanExpression; | ||
| import com.querydsl.jpa.impl.JPAQuery; | ||
| import com.querydsl.jpa.impl.JPAQueryFactory; | ||
| import jakarta.persistence.EntityManager; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.ZoneId; | ||
| import java.util.List; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageImpl; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public class MentorApplicationFilterRepositoryImpl implements MentorApplicationFilterRepository { | ||
|
|
||
| private static final ZoneId SYSTEM_ZONE_ID = ZoneId.systemDefault(); | ||
|
|
||
| private static final ConstructorExpression<SiteUserResponse> SITE_USER_RESPONSE_PROJECTION = | ||
| Projections.constructor( | ||
| SiteUserResponse.class, | ||
| siteUser.id, | ||
| siteUser.nickname, | ||
| siteUser.profileImageUrl | ||
| ); | ||
|
|
||
| private static final ConstructorExpression<MentorApplicationResponse> MENTOR_APPLICATION_RESPONSE_PROJECTION = | ||
| Projections.constructor( | ||
| MentorApplicationResponse.class, | ||
| mentorApplication.id, | ||
| region.koreanName, | ||
| country.koreanName, | ||
| university.koreanName, | ||
| mentorApplication.mentorProofUrl, | ||
| mentorApplication.mentorApplicationStatus, | ||
| mentorApplication.rejectedReason, | ||
| mentorApplication.createdAt, | ||
| mentorApplication.approvedAt | ||
| ); | ||
|
|
||
| private static final ConstructorExpression<MentorApplicationSearchResponse> MENTOR_APPLICATION_SEARCH_RESPONSE_PROJECTION = | ||
| Projections.constructor( | ||
| MentorApplicationSearchResponse.class, | ||
| SITE_USER_RESPONSE_PROJECTION, | ||
| MENTOR_APPLICATION_RESPONSE_PROJECTION | ||
| ); | ||
|
|
||
| private final JPAQueryFactory queryFactory; | ||
|
|
||
| @Autowired | ||
| public MentorApplicationFilterRepositoryImpl(EntityManager em) { | ||
| this.queryFactory = new JPAQueryFactory(em); | ||
| } | ||
|
|
||
| @Override | ||
| public Page<MentorApplicationSearchResponse> searchMentorApplications(MentorApplicationSearchCondition condition, Pageable pageable) { | ||
| List<MentorApplicationSearchResponse> content = queryFactory | ||
| .select(MENTOR_APPLICATION_SEARCH_RESPONSE_PROJECTION) | ||
| .from(mentorApplication) | ||
| .join(siteUser).on(mentorApplication.siteUserId.eq(siteUser.id)) | ||
| .leftJoin(university).on(mentorApplication.universityId.eq(university.id)) | ||
| .leftJoin(region).on(university.region.eq(region)) | ||
| .leftJoin(country).on(university.country.eq(country)) | ||
| .where( | ||
| verifyMentorStatusEq(condition.mentorApplicationStatus()), | ||
| keywordContains(condition.keyword()), | ||
| createdAtEq(condition.createdAt()) | ||
| ) | ||
| .orderBy(mentorApplication.createdAt.desc()) | ||
| .offset(pageable.getOffset()) | ||
| .limit(pageable.getPageSize()) | ||
| .fetch(); | ||
|
|
||
| Long totalCount = createCountQuery(condition).fetchOne(); | ||
|
|
||
| return new PageImpl<>(content, pageable, totalCount != null ? totalCount : 0L); | ||
| } | ||
|
|
||
| private JPAQuery<Long> createCountQuery(MentorApplicationSearchCondition condition) { | ||
| JPAQuery<Long> query = queryFactory | ||
| .select(mentorApplication.count()) | ||
| .from(mentorApplication); | ||
|
|
||
| String keyword = condition.keyword(); | ||
|
|
||
| if (hasText(keyword)) { | ||
| query.join(siteUser).on(mentorApplication.siteUserId.eq(siteUser.id)) | ||
| .leftJoin(university).on(mentorApplication.universityId.eq(university.id)) | ||
| .leftJoin(region).on(university.region.eq(region)) | ||
| .leftJoin(country).on(university.country.eq(country)); | ||
| } | ||
|
|
||
| return query.where( | ||
| verifyMentorStatusEq(condition.mentorApplicationStatus()), | ||
| keywordContains(condition.keyword()), | ||
| createdAtEq(condition.createdAt()) | ||
| ); | ||
| } | ||
|
|
||
| private BooleanExpression verifyMentorStatusEq(MentorApplicationStatus status) { | ||
| return status != null ? mentorApplication.mentorApplicationStatus.eq(status) : null; | ||
| } | ||
|
|
||
| private BooleanExpression keywordContains(String keyword) { | ||
| if (!hasText(keyword)) { | ||
| return null; | ||
| } | ||
|
|
||
| return siteUser.nickname.containsIgnoreCase(keyword) | ||
| .or(university.koreanName.containsIgnoreCase(keyword)) | ||
| .or(region.koreanName.containsIgnoreCase(keyword)) | ||
| .or(country.koreanName.containsIgnoreCase(keyword)); | ||
|
Comment on lines
+126
to
+129
Contributor
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. 개인적인 생각으로는 일단 컬럼별 우선순위 없이 현재 방식을 유지해도 될 것 같습니다! |
||
| } | ||
|
|
||
| private BooleanExpression createdAtEq(LocalDate createdAt) { | ||
| if (createdAt == null) { | ||
| return null; | ||
| } | ||
|
|
||
| LocalDateTime startOfDay = createdAt.atStartOfDay(); | ||
| LocalDateTime endOfDay = createdAt.plusDays(1).atStartOfDay().minusNanos(1); | ||
|
|
||
| return mentorApplication.createdAt.between( | ||
| startOfDay.atZone(SYSTEM_ZONE_ID), | ||
| endOfDay.atZone(SYSTEM_ZONE_ID) | ||
| ); | ||
| } | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
src/main/resources/db/migration/V39__add_approved_at_mentro_application.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ALTER TABLE mentor_application | ||
| ADD COLUMN approved_at DATETIME(6); | ||
|
|
||
| UPDATE mentor_application | ||
| SET approved_at = NOW() | ||
| WHERE mentor_application_status = 'APPROVED' | ||
| AND approved_at IS NULL; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
함수로 나눠져 있어서 깔끔하네요!
조건이 더 복잡해지면 BooleanBuilder를 사용하는 것도 좋을 것 같습니다