From 91268ad53a1f971787290eada37ac7c6c95db2ad Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Wed, 6 Mar 2024 22:56:35 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=BF=BC=EB=A6=AC=EC=98=B5?= =?UTF-8?q?=EC=85=98=20DTO=20=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/api/AdminMemberController.java | 22 +++++++++---------- .../application/AdminMemberService.java | 22 +++++++++---------- .../member/dao/MemberCustomRepository.java | 8 +++---- .../dao/MemberCustomRepositoryImpl.java | 20 ++++++++--------- .../domain/member/dao/MemberQueryMethod.java | 18 +++++++-------- ...eryRequest.java => MemberQueryOption.java} | 2 +- 6 files changed, 46 insertions(+), 46 deletions(-) rename src/main/java/com/gdschongik/gdsc/domain/member/dto/request/{MemberQueryRequest.java => MemberQueryOption.java} (95%) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java index 139e6f896..28b747dd5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java @@ -4,7 +4,7 @@ import com.gdschongik.gdsc.domain.member.domain.RequirementStatus; import com.gdschongik.gdsc.domain.member.dto.request.MemberGrantRequest; import com.gdschongik.gdsc.domain.member.dto.request.MemberPaymentRequest; -import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; +import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryOption; import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest; import com.gdschongik.gdsc.domain.member.dto.response.AdminMemberResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberGrantResponse; @@ -37,8 +37,8 @@ public class AdminMemberController { @Operation(summary = "전체 회원 목록 조회", description = "전체 회원 목록을 조회합니다.") @GetMapping - public ResponseEntity> getMembers(MemberQueryRequest queryRequest, Pageable pageable) { - Page response = adminMemberService.findAll(queryRequest, pageable); + public ResponseEntity> getMembers(MemberQueryOption queryOption, Pageable pageable) { + Page response = adminMemberService.findAll(queryOption, pageable); return ResponseEntity.ok().body(response); } @@ -52,8 +52,8 @@ public ResponseEntity withdrawMember(@PathVariable Long memberId) { @Operation(summary = "대기중인 회원 목록 조회", description = "대기중인 회원 목록을 조회합니다.") @GetMapping("/pending") public ResponseEntity> getPendingMembers( - MemberQueryRequest queryRequest, Pageable pageable) { - Page response = adminMemberService.findAllPendingMembers(queryRequest, pageable); + MemberQueryOption queryOption, Pageable pageable) { + Page response = adminMemberService.findAllPendingMembers(queryOption, pageable); return ResponseEntity.ok().body(response); } @@ -75,19 +75,19 @@ public ResponseEntity grantMember(@Valid @RequestBody Membe @Operation(summary = "승인 가능 회원 전체 조회", description = "승인 가능한 회원 전체를 조회합니다.") @GetMapping("/grantable") public ResponseEntity> getGrantableMembers( - MemberQueryRequest queryRequest, Pageable pageable) { - Page response = adminMemberService.getGrantableMembers(queryRequest, pageable); + MemberQueryOption queryOption, Pageable pageable) { + Page response = adminMemberService.getGrantableMembers(queryOption, pageable); return ResponseEntity.ok().body(response); } @Operation(summary = "회비 납부 상태에 따른 회원 전체 조회", description = "회비 납부 상태에 따라 회원 목록을 조회합니다.") @GetMapping("/payment") public ResponseEntity> getMembersByPaymentStatus( - MemberQueryRequest queryRequest, + MemberQueryOption queryOption, @RequestParam(name = "status", required = false) RequirementStatus paymentStatus, Pageable pageable) { Page response = - adminMemberService.getMembersByPaymentStatus(queryRequest, paymentStatus, pageable); + adminMemberService.getMembersByPaymentStatus(queryOption, paymentStatus, pageable); return ResponseEntity.ok().body(response); } @@ -102,8 +102,8 @@ public ResponseEntity updatePayment( @Operation(summary = "승인된 회원 전체 조회", description = "승인된 회원 전체를 조회합니다.") @GetMapping("/granted") public ResponseEntity> getGrantedMembers( - MemberQueryRequest queryRequest, Pageable pageable) { - Page response = adminMemberService.findAllGrantedMembers(queryRequest, pageable); + MemberQueryOption queryOption, Pageable pageable) { + Page response = adminMemberService.findAllGrantedMembers(queryOption, pageable); return ResponseEntity.ok().body(response); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/AdminMemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/AdminMemberService.java index 76f55ac08..243e6917f 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/AdminMemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/AdminMemberService.java @@ -8,7 +8,7 @@ import com.gdschongik.gdsc.domain.member.domain.RequirementStatus; import com.gdschongik.gdsc.domain.member.dto.request.MemberGrantRequest; import com.gdschongik.gdsc.domain.member.dto.request.MemberPaymentRequest; -import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; +import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryOption; import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest; import com.gdschongik.gdsc.domain.member.dto.response.AdminMemberResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberGrantResponse; @@ -32,8 +32,8 @@ public class AdminMemberService { private final MemberRepository memberRepository; private final ExcelUtil excelUtil; - public Page findAll(MemberQueryRequest queryRequest, Pageable pageable) { - Page members = memberRepository.findAllByRole(queryRequest, pageable, null); + public Page findAll(MemberQueryOption queryOption, Pageable pageable) { + Page members = memberRepository.findAllByRole(queryOption, pageable, null); return members.map(AdminMemberResponse::from); } @@ -57,8 +57,8 @@ public void updateMember(Long memberId, MemberUpdateRequest request) { request.nickname()); } - public Page findAllPendingMembers(MemberQueryRequest queryRequest, Pageable pageable) { - Page members = memberRepository.findAllByRole(queryRequest, pageable, GUEST); + public Page findAllPendingMembers(MemberQueryOption queryOption, Pageable pageable) { + Page members = memberRepository.findAllByRole(queryOption, pageable, GUEST); return members.map(AdminMemberResponse::from); } @@ -70,14 +70,14 @@ public MemberGrantResponse grantMember(MemberGrantRequest request) { return MemberGrantResponse.from(classifiedMember); } - public Page getGrantableMembers(MemberQueryRequest queryRequest, Pageable pageable) { - Page members = memberRepository.findAllGrantable(queryRequest, pageable); + public Page getGrantableMembers(MemberQueryOption queryOption, Pageable pageable) { + Page members = memberRepository.findAllGrantable(queryOption, pageable); return members.map(AdminMemberResponse::from); } public Page getMembersByPaymentStatus( - MemberQueryRequest queryRequest, RequirementStatus paymentStatus, Pageable pageable) { - Page members = memberRepository.findAllByPaymentStatus(queryRequest, paymentStatus, pageable); + MemberQueryOption queryOption, RequirementStatus paymentStatus, Pageable pageable) { + Page members = memberRepository.findAllByPaymentStatus(queryOption, paymentStatus, pageable); return members.map(AdminMemberResponse::from); } @@ -87,8 +87,8 @@ public void updatePaymentStatus(Long memberId, MemberPaymentRequest request) { member.updatePaymentStatus(request.status()); } - public Page findAllGrantedMembers(MemberQueryRequest queryRequest, Pageable pageable) { - Page members = memberRepository.findAllByRole(queryRequest, pageable, USER); + public Page findAllGrantedMembers(MemberQueryOption queryOption, Pageable pageable) { + Page members = memberRepository.findAllByRole(queryOption, pageable, USER); return members.map(AdminMemberResponse::from); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java index fc7e5b3ea..3d38a932e 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java @@ -3,7 +3,7 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.member.domain.MemberRole; import com.gdschongik.gdsc.domain.member.domain.RequirementStatus; -import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; +import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryOption; import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; @@ -14,12 +14,12 @@ public interface MemberCustomRepository { Optional findNormalByOauthId(String oauthId); - Page findAllGrantable(MemberQueryRequest queryRequest, Pageable pageable); + Page findAllGrantable(MemberQueryOption queryOption, Pageable pageable); - Page findAllByRole(MemberQueryRequest queryRequest, Pageable pageable, @Nullable MemberRole role); + Page findAllByRole(MemberQueryOption queryOption, Pageable pageable, @Nullable MemberRole role); Page findAllByPaymentStatus( - MemberQueryRequest queryRequest, RequirementStatus paymentStatus, Pageable pageable); + MemberQueryOption queryOption, RequirementStatus paymentStatus, Pageable pageable); Map> groupByVerified(List memberIdList); diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java index faa5b4c1e..4b52752af 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java @@ -6,7 +6,7 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.member.domain.MemberRole; import com.gdschongik.gdsc.domain.member.domain.RequirementStatus; -import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; +import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryOption; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.annotation.Nullable; @@ -32,10 +32,10 @@ public Optional findNormalByOauthId(String oauthId) { } @Override - public Page findAllGrantable(MemberQueryRequest queryRequest, Pageable pageable) { + public Page findAllGrantable(MemberQueryOption queryOption, Pageable pageable) { List fetch = queryFactory .selectFrom(member) - .where(matchesQueryOption(queryRequest), eqRole(MemberRole.GUEST), isGrantAvailable()) + .where(matchesQueryOption(queryOption), eqRole(MemberRole.GUEST), isGrantAvailable()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) .orderBy(member.createdAt.desc()) @@ -44,16 +44,16 @@ public Page findAllGrantable(MemberQueryRequest queryRequest, Pageable p JPAQuery countQuery = queryFactory .select(member.count()) .from(member) - .where(matchesQueryOption(queryRequest), eqRole(MemberRole.GUEST), isGrantAvailable()); + .where(matchesQueryOption(queryOption), eqRole(MemberRole.GUEST), isGrantAvailable()); return PageableExecutionUtils.getPage(fetch, pageable, countQuery::fetchOne); } @Override - public Page findAllByRole(MemberQueryRequest queryRequest, Pageable pageable, @Nullable MemberRole role) { + public Page findAllByRole(MemberQueryOption queryOption, Pageable pageable, @Nullable MemberRole role) { List fetch = queryFactory .selectFrom(member) - .where(matchesQueryOption(queryRequest), eqRole(role), isStudentIdNotNull()) + .where(matchesQueryOption(queryOption), eqRole(role), isStudentIdNotNull()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) .orderBy(member.createdAt.desc()) @@ -62,18 +62,18 @@ public Page findAllByRole(MemberQueryRequest queryRequest, Pageable page JPAQuery countQuery = queryFactory .select(member.count()) .from(member) - .where(matchesQueryOption(queryRequest), eqRole(role), isStudentIdNotNull()); + .where(matchesQueryOption(queryOption), eqRole(role), isStudentIdNotNull()); return PageableExecutionUtils.getPage(fetch, pageable, countQuery::fetchOne); } @Override public Page findAllByPaymentStatus( - MemberQueryRequest queryRequest, RequirementStatus paymentStatus, Pageable pageable) { + MemberQueryOption queryOption, RequirementStatus paymentStatus, Pageable pageable) { List fetch = queryFactory .selectFrom(member) .where( - matchesQueryOption(queryRequest), + matchesQueryOption(queryOption), eqRequirementStatus(member.requirement.paymentStatus, paymentStatus), isStudentIdNotNull()) .offset(pageable.getOffset()) @@ -85,7 +85,7 @@ public Page findAllByPaymentStatus( .select(member.count()) .from(member) .where( - matchesQueryOption(queryRequest), + matchesQueryOption(queryOption), eqRequirementStatus(member.requirement.paymentStatus, paymentStatus), isStudentIdNotNull()); diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberQueryMethod.java b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberQueryMethod.java index 9bcda6fb6..172eb661d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberQueryMethod.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberQueryMethod.java @@ -6,7 +6,7 @@ import com.gdschongik.gdsc.domain.member.domain.Department; import com.gdschongik.gdsc.domain.member.domain.MemberRole; import com.gdschongik.gdsc.domain.member.domain.RequirementStatus; -import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; +import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryOption; import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.EnumPath; @@ -67,14 +67,14 @@ protected BooleanBuilder isGrantAvailable() { .and(eqRequirementStatus(member.requirement.bevyStatus, VERIFIED)); } - protected BooleanBuilder matchesQueryOption(MemberQueryRequest queryRequest) { + protected BooleanBuilder matchesQueryOption(MemberQueryOption queryOption) { return new BooleanBuilder() - .and(eqStudentId(queryRequest.studentId())) - .and(eqName(queryRequest.name())) - .and(eqPhone(queryRequest.phone())) - .and(inDepartmentList(Department.searchDepartments(queryRequest.department()))) - .and(eqEmail(queryRequest.email())) - .and(eqDiscordUsername(queryRequest.discordUsername())) - .and(eqNickname(queryRequest.nickname())); + .and(eqStudentId(queryOption.studentId())) + .and(eqName(queryOption.name())) + .and(eqPhone(queryOption.phone())) + .and(inDepartmentList(Department.searchDepartments(queryOption.department()))) + .and(eqEmail(queryOption.email())) + .and(eqDiscordUsername(queryOption.discordUsername())) + .and(eqNickname(queryOption.nickname())); } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberQueryRequest.java b/src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberQueryOption.java similarity index 95% rename from src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberQueryRequest.java rename to src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberQueryOption.java index 56ac95fa8..26daf58e2 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberQueryRequest.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberQueryOption.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; -public record MemberQueryRequest( +public record MemberQueryOption( @Schema(description = "학번", pattern = STUDENT_ID) String studentId, @Schema(description = "이름") String name, @Schema(description = "전화번호", pattern = PHONE_WITHOUT_HYPHEN) String phone,