Skip to content

Commit

Permalink
feat : 동아리 모든 멤버 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
Changha-dev committed Nov 25, 2023
1 parent 13de2a7 commit 436eeb5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/donggram/back/controller/AdminController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.donggram.back.service.ClubService;
import com.donggram.back.service.MemberService;
import lombok.RequiredArgsConstructor;
import org.apache.coyote.Response;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -53,6 +54,13 @@ public ResponseEntity getSelectedClub(@PathVariable("id") Long clubId){
return ResponseEntity.ok(clubDetails);
}

@GetMapping("/clubs/{id}/members")
public ResponseEntity getAllMemberBySelectedClub(@PathVariable("id") Long clubId){
ResponseDto allMemberBySelectedClub = adminService.getAllMemberBySelectedClub(clubId);

return ResponseEntity.ok(allMemberBySelectedClub);
}

@PutMapping("/clubs/{id}/approve")
public ResponseEntity approveClubCreation(@PathVariable Long id){
ResponseDto approve = adminService.approve(id);
Expand All @@ -77,4 +85,6 @@ public ResponseEntity rejectClubJoin(@RequestParam Long memberId, @RequestParam
return ResponseEntity.ok(reject);
}



}
20 changes: 20 additions & 0 deletions src/main/java/com/donggram/back/dto/ClubMemberDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.donggram.back.dto;

import com.donggram.back.entity.RequestStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
public class ClubMemberDto {

private Long id;
private String name;
private String division;
private String join_dated;
private RequestStatus status;
}
24 changes: 24 additions & 0 deletions src/main/java/com/donggram/back/service/AdminService.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ public ResponseDto reject(Long clubId){
.responseMessage("동아리 생성 요청 거절").build();
}

@Transactional
public ResponseDto getAllMemberBySelectedClub(Long clubId){
List<ClubMemberDto> clubMemberDtos = new ArrayList<>();

Club club = clubRepository.findById(clubId).orElseThrow(() -> new RuntimeException("해당 동아리가 존재하지 않습니다."));
for ( ClubJoin clubJoin : club.getClubJoinList()) {
ClubMemberDto clubMemberDto = ClubMemberDto.builder()
.division(clubJoin.getMember().getMajor1())
.name(clubJoin.getMember().getName())
.join_dated(clubJoin.getJoinDate())
.id(clubJoin.getId())
.status(clubJoin.getStatus())
.build();

clubMemberDtos.add(clubMemberDto);
}

return ResponseDto.builder()
.data(clubMemberDtos)
.status(200)
.responseMessage("동아리 멤버 목록 API")
.build();
}

}


Expand Down

0 comments on commit 436eeb5

Please sign in to comment.