Skip to content
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

Feature/#105 #110

Merged
merged 8 commits into from
Sep 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers(GET, "/member/my").authenticated()
.requestMatchers(GET, "/member/check/broadcast-club-member").hasAnyRole(STUDENT, ADMIN)
.requestMatchers(GET, "/member/**").hasAnyRole(TEACHER, ADMIN)
.requestMatchers(PATCH, "/member/student/info/**").hasAnyRole(TEACHER, ADMIN)
.requestMatchers(PATCH, "/member/teacher/info/**").hasAnyRole(TEACHER, ADMIN)
.requestMatchers(PATCH, "/member/status/**").hasRole(ADMIN)
.requestMatchers(PATCH, "/member/active/**").hasRole(ADMIN)
.requestMatchers(PATCH, "/member/deactivate").authenticated()
.requestMatchers(PATCH, "/member/deactivate/**").hasRole(ADMIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public Response delete(String id) {
return Response.noContent("멤버 삭제 성공");
}

@CacheEvict(value = "members-cache", key = "'activeMembers'")
public Response status(String id, ActiveStatus status) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateStatus 같이 동사를 추가해서 네이밍해주세요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 updateStatus메서드를 사용하는 기존 메서드가 있어서 임시로 네이밍을 해뒀습니다
웹에서 변경사항에 맞춰 수정하면 기존메서드를 삭제하고 메서드 명도 updateStatus로 변경할 예정입니다.

Member member = memberRepository.getById(id);
member.updateStatus(status);
return Response.ok("멤버 상태변경 성공");
}

@CacheEvict(value = "members-cache", key = "'activeMembers'")
public Response active(String id) {
updateStatus(id, ActiveStatus.ACTIVE);
Expand Down Expand Up @@ -130,22 +137,16 @@ public Response updateStudentInfo(UpdateStudentInfoReq req) {
return Response.noContent("내 학생 정보 수정 성공");
}

@CacheEvict(value = "members-cache", key = "'activeMembers'")
public Response updateStudentParentPhone(String id, UpdateStudentForAdminReq req){
Member current = memberAuthenticationHolder.current();
if (!(current.getRole() == MemberRole.TEACHER || current.getRole() == MemberRole.ADMIN)){
throw new UnauthorizedException();
}
Member member = memberRepository.getById(id);
Student student = studentRepository.getByMember(member);
student.updateParentPhone(req.parentPhone());
return Response.noContent("학생 정보 수정 성공");
}

@CacheEvict(value = "members-cache", key = "'activeMembers'")
public Response updateTeacherForAdmin(String id, UpdateTeacherForAdminReq req){
Member current = memberAuthenticationHolder.current();
if (!(current.getRole() == MemberRole.TEACHER)){
throw new UnauthorizedException();
}
Member member = memberRepository.getById(id);
Teacher teacher = teacherRepository.getByMember(member);
teacher.updateInfo(req.tel(), req.position());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public ResponseData<List<MemberInfoRes>> getDeactivateMembers() {
.toList());
}

public ResponseData<List<MemberInfoRes>> getPendingMembers(){
return ResponseData.ok("보류중인 멤버 조회 성공", memberRepository.findByStatusOrderByStudent(ActiveStatus.PENDING)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보류 -> 대기 라고 바꿔도 좋을 것 같습니다

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 메서드도 pending만 불러오는것이 아닌 한개의 메서드로 통일시켜 파라미터로 구분하도록 수정하겠습니다

.parallelStream()
.map(this::getMemberInfo)
.toList());
}

@Cacheable(value = "members-cache", key = "'activeMembers'")
public List<MemberInfoRes> getAll() {
return memberRepository.findByStatusOrderByStudent(ActiveStatus.ACTIVE).parallelStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Member mapToMember(String encodedPw) {
.name(name)
.role(MemberRole.STUDENT)
.phone(phone)
.status(ActiveStatus.DEACTIVATE)
.status(ActiveStatus.PENDING)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Member mapToMember(String encodedPw) {
.name(name)
.role(MemberRole.TEACHER)
.phone(phone)
.status(ActiveStatus.DEACTIVATE)
.status(ActiveStatus.PENDING)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package b1nd.dodam.restapi.member.presentation;

import b1nd.dodam.domain.rds.member.enumeration.ActiveStatus;
import b1nd.dodam.restapi.member.application.MemberCommandUseCase;
import b1nd.dodam.restapi.member.application.MemberQueryUseCase;
import b1nd.dodam.restapi.member.application.data.req.*;
Expand Down Expand Up @@ -40,6 +41,11 @@ public Response delete(@PathVariable String id) {
return commandUseCase.delete(id);
}

@PatchMapping("/status/{id}")
public Response updateStatus(@PathVariable("id") String id, @RequestParam ActiveStatus status){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

("id")는 삭제해도 될 것 같습니다

return commandUseCase.status(id, status);
}

@PatchMapping("/active/{id}")
public Response active(@PathVariable("id") String id) {
return commandUseCase.active(id);
Expand Down Expand Up @@ -100,6 +106,11 @@ public ResponseData<List<MemberInfoRes>> getDeactivateMembers() {
return queryUseCase.getDeactivateMembers();
}

@GetMapping("/pending")
public ResponseData<List<MemberInfoRes>> getPendingMembers(){
return queryUseCase.getPendingMembers();
}

@GetMapping("/all")
public ResponseData<List<MemberInfoRes>> getAll() {
return ResponseData.ok("모든 멤버 정보 조회 성공", queryUseCase.getAll());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public enum ActiveStatus {

ACTIVE, DEACTIVATE
ACTIVE, DEACTIVATE, PENDING

}