Skip to content

Commit

Permalink
feat: 어드민 대기중인 멤버 조회 api 구현 (#44)
Browse files Browse the repository at this point in the history
* chore: 파일 구조 수정

* chore: 파일 구조 수정

* feat: 대기중인 멤버 조회 기능 추가

* feat: 대기중인 멤버 조회 기능 추가

* docs: 어드민 controller 문서 작업

* style: spotless apply

* style: spotless apply
  • Loading branch information
Sangwook02 authored Feb 11, 2024
1 parent 8796e8f commit e27bc82
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest;
import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest;
import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberPendingFindAllResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -41,6 +42,13 @@ public ResponseEntity<Void> withdrawMember(@PathVariable Long memberId) {
return ResponseEntity.ok().build();
}

@Operation(summary = "대기중인 회원 목록 조회", description = "대기중인 회원 목록을 조회합니다.")
@GetMapping("/pending")
public ResponseEntity<Page<MemberPendingFindAllResponse>> getPendingMembers(Pageable pageable) {
Page<MemberPendingFindAllResponse> response = memberService.findAllPendingMembers(pageable);
return ResponseEntity.ok().body(response);
}

@Operation(summary = "회원 정보 수정", description = "회원 정보를 수정합니다.")
@PutMapping("/{memberId}")
public ResponseEntity<Void> updateMember(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import com.gdschongik.gdsc.domain.member.dao.MemberRepository;
import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.member.domain.MemberRole;
import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest;
import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest;
import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberPendingFindAllResponse;
import com.gdschongik.gdsc.global.exception.CustomException;
import com.gdschongik.gdsc.global.exception.ErrorCode;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -39,4 +41,9 @@ public void updateMember(Long memberId, MemberUpdateRequest request) {
memberRepository.findById(memberId).orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND));
member.updateMemberInfo(request);
}

public Page<MemberPendingFindAllResponse> findAllPendingMembers(Pageable pageable) {
Page<Member> members = memberRepository.findAllByRole(MemberRole.GUEST, pageable);
return members.map(MemberPendingFindAllResponse::of);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.gdschongik.gdsc.domain.member.dao;

import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.member.domain.MemberRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MemberRepository extends JpaRepository<Member, Long>, MemberCustomRepository {}
public interface MemberRepository extends JpaRepository<Member, Long>, MemberCustomRepository {

Page<Member> findAllByRole(MemberRole role, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.gdschongik.gdsc.domain.common.model.BaseTimeEntity;
import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest;
import com.gdschongik.gdsc.domain.requirement.domain.Requirement;
import com.gdschongik.gdsc.global.exception.CustomException;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gdschongik.gdsc.domain.requirement.domain;
package com.gdschongik.gdsc.domain.member.domain;

import static com.gdschongik.gdsc.domain.requirement.domain.RequirementStatus.*;
import static com.gdschongik.gdsc.domain.member.domain.RequirementStatus.*;

import jakarta.persistence.Embeddable;
import jakarta.persistence.EnumType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gdschongik.gdsc.domain.requirement.domain;
package com.gdschongik.gdsc.domain.member.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gdschongik.gdsc.domain.member.dto.response;

import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.member.domain.Requirement;

public record MemberPendingFindAllResponse(
Long memberId,
String studentId,
String name,
String phone,
String department,
String email,
String discordUsername,
String nickname,
Requirement requirement) {

public static MemberPendingFindAllResponse of(Member member) {
return new MemberPendingFindAllResponse(
member.getId(),
member.getStudentId(),
member.getName(),
member.getPhone(),
member.getDepartment(),
member.getEmail(),
member.getDiscordUsername(),
member.getNickname(),
member.getRequirement());
}
}

0 comments on commit e27bc82

Please sign in to comment.