From 2afc5cbe3b05c5dcb08376613da65e0836e2b147 Mon Sep 17 00:00:00 2001 From: whitemark Date: Wed, 21 Feb 2024 17:21:30 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[feature/#237]=20Member=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oauth2/member/dto/ExecutiveMemberDto.java | 53 +++++++++++++++++ .../oauth2/member/dto/HallOfFameDto.java | 57 +++++++++++++++++++ .../member/repository/MemberRepository.java | 5 +- .../inhabas/api/config/WebSecurityConfig.java | 6 +- .../member/usecase/MemberManageService.java | 10 +++- .../usecase/MemberManageServiceImpl.java | 51 ++++++++++++++++- .../com/inhabas/api/web/MemberController.java | 49 ++++++++++++---- 7 files changed, 210 insertions(+), 21 deletions(-) create mode 100644 module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/ExecutiveMemberDto.java create mode 100644 module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java diff --git a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/ExecutiveMemberDto.java b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/ExecutiveMemberDto.java new file mode 100644 index 00000000..fad17c2a --- /dev/null +++ b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/ExecutiveMemberDto.java @@ -0,0 +1,53 @@ +package com.inhabas.api.auth.domain.oauth2.member.dto; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.Role; +import org.hibernate.validator.constraints.Length; + +@Getter +@NoArgsConstructor +public class ExecutiveMemberDto { + + @NotBlank + @Length(max = 50) + private String name; + + @NotNull @Positive private Long memberId; + + @NotNull private String studentId; + + @NotBlank private Role role; + + @NotNull private Integer generation; + + @NotBlank + @Length(max = 50) + private String major; + + private String picture; + + @Builder + public ExecutiveMemberDto( + String name, + Long memberId, + String studentId, + Role role, + Integer generation, + String major, + String picture) { + this.name = name; + this.memberId = memberId; + this.studentId = studentId; + this.role = role; + this.generation = generation; + this.major = major; + this.picture = picture; + } +} diff --git a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java new file mode 100644 index 00000000..ab6f6eee --- /dev/null +++ b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java @@ -0,0 +1,57 @@ +package com.inhabas.api.auth.domain.oauth2.member.dto; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import org.hibernate.validator.constraints.Length; + +@Getter +@NoArgsConstructor +public class HallOfFameDto { + + @NotBlank + @Length(max = 50) + private String name; + + @NotNull @Positive private Long memberId; + + @NotNull private String studentId; + + @NotNull private Integer generation; + + @NotBlank + @Length(max = 50) + private String major; + + private String picture; + + @NotNull private String intro; + + @NotNull @Email private String email; + + @Builder + public HallOfFameDto( + String name, + Long memberId, + String studentId, + Integer generation, + String major, + String picture, + String intro, + String email) { + this.name = name; + this.memberId = memberId; + this.studentId = studentId; + this.generation = generation; + this.major = major; + this.picture = picture; + this.intro = intro; + this.email = email; + } +} diff --git a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepository.java b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepository.java index 94d2ebd9..8bd1e2a4 100644 --- a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepository.java +++ b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepository.java @@ -8,17 +8,16 @@ import com.inhabas.api.auth.domain.oauth2.OAuth2Provider; import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.Role; -import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.StudentId; import com.inhabas.api.auth.domain.oauth2.socialAccount.domain.valueObject.UID; public interface MemberRepository extends JpaRepository, MemberRepositoryCustom { List findAllById(Iterable memberIdList); - Member getByStudentId(StudentId studentId); - Member findByIbasInformation_Role(Role role); + List findAllByIbasInformation_IsHOF(boolean IsHOF); + // OAuth boolean existsByProviderAndUid(OAuth2Provider provider, UID uid); diff --git a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java index 83374417..1914db84 100644 --- a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java +++ b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java @@ -109,7 +109,7 @@ protected void configure(HttpSecurity http) throws Exception { .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() - // API이므로 CORS 활성화, CSRF 비활성화 + // API 이므로 CORS 활성화, CSRF 비활성화 .cors() .and() .csrf() @@ -126,12 +126,14 @@ protected void configure(HttpSecurity http) throws Exception { // Preflight 방식 .requestMatchers(CorsUtils::isPreFlightRequest) .permitAll() - .antMatchers("/myInfo/reqeusts") + .antMatchers("/myInfo/requests") .hasAnyRole(CHIEF.toString(), VICE_CHIEF.toString()) .antMatchers("/myInfo/request/**") .hasAnyRole(CHIEF.toString(), VICE_CHIEF.toString()) // 회원 관리 + .antMatchers("/members/executive", "/members/hof") + .hasRole(ANONYMOUS.toString()) .antMatchers("/members/approved/role") .hasRole(SECRETARY.toString()) .antMatchers("/members/approved/type") diff --git a/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageService.java b/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageService.java index 3bcb5475..8f27966c 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageService.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageService.java @@ -4,7 +4,11 @@ import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.MemberType; import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.Role; -import com.inhabas.api.auth.domain.oauth2.member.dto.*; +import com.inhabas.api.auth.domain.oauth2.member.dto.ApprovedMemberManagementDto; +import com.inhabas.api.auth.domain.oauth2.member.dto.ContactDto; +import com.inhabas.api.auth.domain.oauth2.member.dto.ExecutiveMemberDto; +import com.inhabas.api.auth.domain.oauth2.member.dto.HallOfFameDto; +import com.inhabas.api.auth.domain.oauth2.member.dto.NotApprovedMemberManagementDto; public interface MemberManageService { @@ -14,6 +18,10 @@ public interface MemberManageService { List getGraduatedMembersBySearch(String search); + List getExecutiveMembers(); + + List getHallOfFame(); + void updateUnapprovedMembers(List memberIdList, String state); void updateApprovedMembersRole(List memberIdList, Role role); diff --git a/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java index c5c6ac36..3d08f914 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java @@ -19,6 +19,8 @@ import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.Role; import com.inhabas.api.auth.domain.oauth2.member.dto.ApprovedMemberManagementDto; import com.inhabas.api.auth.domain.oauth2.member.dto.ContactDto; +import com.inhabas.api.auth.domain.oauth2.member.dto.ExecutiveMemberDto; +import com.inhabas.api.auth.domain.oauth2.member.dto.HallOfFameDto; import com.inhabas.api.auth.domain.oauth2.member.dto.NotApprovedMemberManagementDto; import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; import com.inhabas.api.auth.domain.oauth2.member.service.SMTPService; @@ -32,16 +34,19 @@ public class MemberManageServiceImpl implements MemberManageService { private static final Role DEFAULT_ROLE_AFTER_FINISH_SIGNUP = NOT_APPROVED; - private static final List OLD_ROLES = - Arrays.asList(ADMIN, CHIEF, VICE_CHIEF, EXECUTIVES, SECRETARY, BASIC, DEACTIVATED); + private static final Set OLD_ROLES = + Set.of(ADMIN, CHIEF, VICE_CHIEF, EXECUTIVES, SECRETARY, BASIC, DEACTIVATED); private static final Set CHIEF_CHANGEABLE_ROLES = Set.of(ADMIN, CHIEF, VICE_CHIEF, EXECUTIVES, SECRETARY, BASIC, DEACTIVATED); private static final Set SECRETARY_CHANGEABLE_ROLES = Set.of(BASIC, DEACTIVATED); + private static final Set EXECUTIVE_ROLES = + Set.of(ADMIN, CHIEF, VICE_CHIEF, EXECUTIVES, SECRETARY); private static final String PASS_STATE = "pass"; private static final String FAIL_STATE = "fail"; private static final String PASS_EMAIL_SUBJECT = "[IBAS] 축하합니다. 동아리에 입부되셨습니다."; private static final String FAIL_EMAIL_SUBJECT = "[IBAS] 입부 신청 결과를 알립니다."; private static final String ROLE_PREFIX = "ROLE_"; + private static final String BLANK = ""; private final MemberRepository memberRepository; private final SMTPService amazonSMTPService; private final AnswerRepository answerRepository; @@ -117,6 +122,44 @@ public List getGraduatedMembersBySearch(String sear .collect(Collectors.toList()); } + @Override + @Transactional(readOnly = true) + public List getExecutiveMembers() { + final List members = + memberRepository.findAllByRolesInAndNameLike(EXECUTIVE_ROLES, BLANK); + return members.stream() + .map( + member -> + new ExecutiveMemberDto( + member.getName(), + member.getId(), + member.getStudentId(), + member.getRole(), + member.getSchoolInformation().getGeneration(), + member.getSchoolInformation().getMajor(), + member.getPicture())) + .collect(Collectors.toList()); + } + + @Override + @Transactional(readOnly = true) + public List getHallOfFame() { + final List members = memberRepository.findAllByIbasInformation_IsHOF(true); + return members.stream() + .map( + member -> + new HallOfFameDto( + member.getName(), + member.getId(), + member.getStudentId(), + member.getSchoolInformation().getGeneration(), + member.getSchoolInformation().getMajor(), + member.getPicture(), + member.getIbasInformation().getIntroduce(), + member.getEmail())) + .collect(Collectors.toList()); + } + @Override @Transactional public void updateUnapprovedMembers(List memberIdList, String state) { @@ -177,7 +220,9 @@ public void updateApprovedMembersType(List memberIdList, MemberType type) throw new InvalidInputException(); } - for (Member member : members) member.setMemberType(type); + for (Member member : members) { + member.setMemberType(type); + } memberRepository.saveAll(members); } diff --git a/resource-server/src/main/java/com/inhabas/api/web/MemberController.java b/resource-server/src/main/java/com/inhabas/api/web/MemberController.java index 53dc29b3..6a69e8f1 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/MemberController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/MemberController.java @@ -58,15 +58,16 @@ public ResponseEntity> getUnapp String search) { Pageable pageable = PageRequest.of(page, size); - List allDtos = + List allDtoList = memberManageService.getNotApprovedMembersBySearchAndRole(search); - List pagedDtos = PageUtil.getPagedDtoList(pageable, allDtos); + List pagedDtoList = + PageUtil.getPagedDtoList(pageable, allDtoList); PageImpl newMemberManagementDtoPage = - new PageImpl<>(pagedDtos, pageable, allDtos.size()); + new PageImpl<>(pagedDtoList, pageable, allDtoList.size()); PageInfoDto pageInfoDto = new PageInfoDto(newMemberManagementDtoPage); - return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtos)); + return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtoList)); } @Operation( @@ -138,15 +139,15 @@ public ResponseEntity> getGraduate String search) { Pageable pageable = PageRequest.of(page, size); - List allDtos = + List allDtoList = memberManageService.getGraduatedMembersBySearch(search); - List pagedDtos = PageUtil.getPagedDtoList(pageable, allDtos); + List pagedDtoList = PageUtil.getPagedDtoList(pageable, allDtoList); PageImpl graduatedMemberManagementDtoPage = - new PageImpl<>(pagedDtos, pageable, allDtos.size()); + new PageImpl<>(pagedDtoList, pageable, allDtoList.size()); PageInfoDto pageInfoDto = new PageInfoDto(graduatedMemberManagementDtoPage); - return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtos)); + return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtoList)); } @Operation(summary = "비활동 이상 졸업자 아닌 멤버 목록 조회", description = "이름, 학번 검색 가능") @@ -169,15 +170,39 @@ public ResponseEntity> getNotGradu String search) { Pageable pageable = PageRequest.of(page, size); - List allDtos = + List allDtoList = memberManageService.getApprovedMembersBySearchAndRole(search); - List pagedDtos = PageUtil.getPagedDtoList(pageable, allDtos); + List pagedDtoList = PageUtil.getPagedDtoList(pageable, allDtoList); PageImpl oldMemberManagementDtoPage = - new PageImpl<>(pagedDtos, pageable, allDtos.size()); + new PageImpl<>(pagedDtoList, pageable, allDtoList.size()); PageInfoDto pageInfoDto = new PageInfoDto(oldMemberManagementDtoPage); - return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtos)); + return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtoList)); + } + + @Operation(summary = "총무 이상 멤버 목록 조회", description = "총무 이상 멤버 목록 조회") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + content = {@Content(schema = @Schema(implementation = ExecutiveMemberDto.class))}), + }) + @GetMapping("/members/executive") + public ResponseEntity> getExecutiveMembers() { + return ResponseEntity.ok(memberManageService.getExecutiveMembers()); + } + + @Operation(summary = "명예의 전당 조회", description = "명예의 전당 조회") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + content = {@Content(schema = @Schema(implementation = ExecutiveMemberDto.class))}), + }) + @GetMapping("/members/hof") + public ResponseEntity> getHallOfFameDto() { + return ResponseEntity.ok(memberManageService.getHallOfFame()); } @Operation( From 335ba579e840cb7b48f8a322e408599b946c93b5 Mon Sep 17 00:00:00 2001 From: scheduled-for-hacker Date: Wed, 21 Feb 2024 22:11:31 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[feature/#237]=20Member=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20test=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/domain/valueObject/MemberType.java | 4 +- .../repository/MemberRepositoryImpl.java | 24 +++++++++-- .../signUp/dto/ApplicationDetailDto.java | 4 ++ .../signUp/usecase/AnswerServiceImpl.java | 1 + .../com/inhabas/api/web/MemberController.java | 4 +- .../inhabas/api/web/MemberControllerTest.java | 41 +++++++++++++++++++ 6 files changed, 70 insertions(+), 8 deletions(-) diff --git a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/domain/valueObject/MemberType.java b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/domain/valueObject/MemberType.java index 894ca54b..9436f54f 100644 --- a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/domain/valueObject/MemberType.java +++ b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/domain/valueObject/MemberType.java @@ -2,8 +2,8 @@ public enum MemberType { UNDERGRADUATE("학부생"), - BACHELOR("학사"), - GRADUATED("대학원생"), + BACHELOR("대학원생"), + GRADUATED("학사"), PROFESSOR("교수"), OTHER("기타"); diff --git a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepositoryImpl.java b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepositoryImpl.java index 44e584a8..b570edbb 100644 --- a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepositoryImpl.java +++ b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/repository/MemberRepositoryImpl.java @@ -1,6 +1,7 @@ package com.inhabas.api.auth.domain.oauth2.member.repository; import static com.inhabas.api.auth.domain.oauth2.member.domain.entity.QMember.member; +import static com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.MemberType.*; import static com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.Role.*; import java.util.Collection; @@ -50,6 +51,21 @@ public class MemberRepositoryImpl implements MemberRepositoryCustom { .otherwise(8) .asc(); + private static final OrderSpecifier ORDER_BY_TYPE = + new CaseBuilder() + .when(member.schoolInformation.memberType.eq(PROFESSOR)) + .then(1) + .when(member.schoolInformation.memberType.eq(BACHELOR)) + .then(2) + .when(member.schoolInformation.memberType.eq(UNDERGRADUATE)) + .then(3) + .when(member.schoolInformation.memberType.eq(GRADUATED)) + .then(4) + .when(member.schoolInformation.memberType.eq(OTHER)) + .then(5) + .otherwise(6) + .asc(); + @Override public MemberAuthorityProvider.RoleDto fetchRoleByStudentId(Long id) { Role role = @@ -102,7 +118,7 @@ public List findAllByRolesInAndStudentIdLike(Collection roles, Str .in(roles) .and(member.studentId.id.like("%" + studentId + "%")) .and(member.schoolInformation.memberType.ne(MemberType.GRADUATED))) - .orderBy(ORDER_BY_ROLE, orderByStudentId) + .orderBy(ORDER_BY_ROLE, ORDER_BY_TYPE, orderByStudentId) .fetch(); } @@ -120,7 +136,7 @@ public List findAllByRolesInAndNameLike(Collection roles, String n .in(roles) .and(member.name.value.like("%" + name + "%")) .and(member.schoolInformation.memberType.ne(MemberType.GRADUATED))) - .orderBy(ORDER_BY_ROLE, orderByStudentId) + .orderBy(ORDER_BY_ROLE, ORDER_BY_TYPE, orderByStudentId) .fetch(); } @@ -139,7 +155,7 @@ public List findAllGraduatedByRolesInAndStudentLike( .in(roles) .and(member.schoolInformation.memberType.eq(MemberType.GRADUATED)) .and(member.studentId.id.like("%" + studentId + "%"))) - .orderBy(ORDER_BY_ROLE, orderByStudentId) + .orderBy(ORDER_BY_ROLE, ORDER_BY_TYPE, orderByStudentId) .fetch(); } @@ -157,7 +173,7 @@ public List findAllGraduatedByRolesInAndNameLike(Collection roles, .in(roles) .and(member.schoolInformation.memberType.eq(MemberType.GRADUATED)) .and(member.name.value.like("%" + name + "%"))) - .orderBy(ORDER_BY_ROLE, orderByStudentId) + .orderBy(ORDER_BY_ROLE, ORDER_BY_TYPE, orderByStudentId) .fetch(); } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/dto/ApplicationDetailDto.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/dto/ApplicationDetailDto.java index 47d1ce6d..a950f8bd 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/dto/ApplicationDetailDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/dto/ApplicationDetailDto.java @@ -18,6 +18,8 @@ public class ApplicationDetailDto { @NotNull @Positive private Long memberId; + @NotBlank private String studentId; + @NotBlank private String name; @NotNull @Positive private Integer grade; @@ -39,6 +41,7 @@ public class ApplicationDetailDto { @Builder public ApplicationDetailDto( Long memberId, + String studentId, String name, Integer grade, String major, @@ -47,6 +50,7 @@ public ApplicationDetailDto( LocalDateTime dateJoined, List answers) { this.memberId = memberId; + this.studentId = studentId; this.name = name; this.grade = grade; this.major = major; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/AnswerServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/AnswerServiceImpl.java index f1a6af7e..5a17e5ab 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/AnswerServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/AnswerServiceImpl.java @@ -126,6 +126,7 @@ public ApplicationDetailDto getApplication(Long memberId) { return ApplicationDetailDto.builder() .memberId(member.getId()) + .studentId(member.getStudentId()) .name(member.getName()) .grade(member.getSchoolInformation().getGrade()) .major(member.getSchoolInformation().getMajor()) diff --git a/resource-server/src/main/java/com/inhabas/api/web/MemberController.java b/resource-server/src/main/java/com/inhabas/api/web/MemberController.java index 6a69e8f1..8d54b816 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/MemberController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/MemberController.java @@ -198,10 +198,10 @@ public ResponseEntity> getExecutiveMembers() { value = { @ApiResponse( responseCode = "200", - content = {@Content(schema = @Schema(implementation = ExecutiveMemberDto.class))}), + content = {@Content(schema = @Schema(implementation = HallOfFameDto.class))}), }) @GetMapping("/members/hof") - public ResponseEntity> getHallOfFameDto() { + public ResponseEntity> getHallOfFameMembers() { return ResponseEntity.ok(memberManageService.getHallOfFame()); } diff --git a/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java index 1184b8a0..306245f4 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java @@ -122,6 +122,7 @@ public void getUnapprovedMemberApplication() throws Exception { ApplicationDetailDto applicationDetailDto = new ApplicationDetailDto( 1L, + "12171707", "조승현", 1, "컴공", @@ -186,6 +187,46 @@ public void getGraduatedMembers() throws Exception { .andExpect(jsonPath("$.data[0].major").value(equalTo("컴퓨터공학과"))); } + @DisplayName("총무 이상 멤버 목록 조회 성공 200") + @Test + public void getExecutiveMembers() throws Exception { + + // given + List dtoList = new ArrayList<>(); + ExecutiveMemberDto dto1 = + new ExecutiveMemberDto("홍길동", 1L, "12171707", BASIC, 1, "컴퓨터공학", null); + dtoList.add(dto1); + + given(memberManageService.getExecutiveMembers()).willReturn(dtoList); + + // then + mvc.perform(get("/members/executive")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.[0].name").value(equalTo("홍길동"))) + .andExpect(jsonPath("$.[0].memberId").value(equalTo(1))) + .andExpect(jsonPath("$.[0].studentId").value(equalTo("12171707"))); + } + + @DisplayName("명예의 전당 조회 성공 200") + @Test + public void getHallOfFameMembers() throws Exception { + + // given + List dtoList = new ArrayList<>(); + HallOfFameDto dto1 = + new HallOfFameDto("홍길동", 1L, "12171707", 1, "컴퓨터공학", null, "자기소개", "email@google.com"); + dtoList.add(dto1); + + given(memberManageService.getHallOfFame()).willReturn(dtoList); + + // then + mvc.perform(get("/members/hof")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.[0].name").value(equalTo("홍길동"))) + .andExpect(jsonPath("$.[0].memberId").value(equalTo(1))) + .andExpect(jsonPath("$.[0].studentId").value(equalTo("12171707"))); + } + @DisplayName("비활동 이상 멤버 권한을 변경할 때 가능한 권한이면 204, 아니면 400을 반환한다.") @ParameterizedTest @ValueSource(strings = {"ADMIN", "SIGNING_UP"}) From 0d5527f1d58cc53558bec466bfabf1a6c9a64cb3 Mon Sep 17 00:00:00 2001 From: whitemark Date: Thu, 22 Feb 2024 08:29:38 +0900 Subject: [PATCH 3/4] [feature/#237] Member config --- .../main/java/com/inhabas/api/config/WebSecurityConfig.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java index 1914db84..1639ef2d 100644 --- a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java +++ b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java @@ -132,8 +132,10 @@ protected void configure(HttpSecurity http) throws Exception { .hasAnyRole(CHIEF.toString(), VICE_CHIEF.toString()) // 회원 관리 - .antMatchers("/members/executive", "/members/hof") + .antMatchers("/members/executive") .hasRole(ANONYMOUS.toString()) + .antMatchers("/members/hof") + .hasRole(DEACTIVATED.toString()) .antMatchers("/members/approved/role") .hasRole(SECRETARY.toString()) .antMatchers("/members/approved/type") From 16246a8e8a342fa032f07c4a977ef99abe5a691f Mon Sep 17 00:00:00 2001 From: whitemark Date: Thu, 22 Feb 2024 08:47:08 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[feature/#237]=20Member=20review=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/domain/oauth2/member/dto/HallOfFameDto.java | 10 +++++++++- .../domain/member/usecase/MemberManageServiceImpl.java | 3 ++- .../java/com/inhabas/api/web/MemberControllerTest.java | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java index ab6f6eee..e8c0c311 100644 --- a/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java +++ b/module-auth/src/main/java/com/inhabas/api/auth/domain/oauth2/member/dto/HallOfFameDto.java @@ -3,12 +3,14 @@ import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; import javax.validation.constraints.Positive; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import io.swagger.v3.oas.annotations.media.Schema; import org.hibernate.validator.constraints.Length; @Getter @@ -35,6 +37,10 @@ public class HallOfFameDto { @NotNull @Email private String email; + @Pattern(regexp = "^(010)-\\d{4}-\\d{4}$") + @Schema(example = "010-0101-0101") + private String phoneNumber; + @Builder public HallOfFameDto( String name, @@ -44,7 +50,8 @@ public HallOfFameDto( String major, String picture, String intro, - String email) { + String email, + String phoneNumber) { this.name = name; this.memberId = memberId; this.studentId = studentId; @@ -53,5 +60,6 @@ public HallOfFameDto( this.picture = picture; this.intro = intro; this.email = email; + this.phoneNumber = phoneNumber; } } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java index 3d08f914..a360f276 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/member/usecase/MemberManageServiceImpl.java @@ -156,7 +156,8 @@ public List getHallOfFame() { member.getSchoolInformation().getMajor(), member.getPicture(), member.getIbasInformation().getIntroduce(), - member.getEmail())) + member.getEmail(), + member.getPhone())) .collect(Collectors.toList()); } diff --git a/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java index 306245f4..bd64fefa 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/MemberControllerTest.java @@ -214,7 +214,8 @@ public void getHallOfFameMembers() throws Exception { // given List dtoList = new ArrayList<>(); HallOfFameDto dto1 = - new HallOfFameDto("홍길동", 1L, "12171707", 1, "컴퓨터공학", null, "자기소개", "email@google.com"); + new HallOfFameDto( + "홍길동", 1L, "12171707", 1, "컴퓨터공학", null, "자기소개", "email@google.com", "010-0101-0101"); dtoList.add(dto1); given(memberManageService.getHallOfFame()).willReturn(dtoList);