diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/member/controller/MemberController.java b/Server/src/main/java/com/gdscswu_server/server/domain/member/controller/MemberController.java index 24a8330..f5e7275 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/member/controller/MemberController.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/member/controller/MemberController.java @@ -1,8 +1,6 @@ package com.gdscswu_server.server.domain.member.controller; -import com.gdscswu_server.server.domain.member.dto.GenerationResponseDto; import com.gdscswu_server.server.domain.member.dto.MemberResponseDto; -import com.gdscswu_server.server.domain.member.dto.ProjectResponseDto; import com.gdscswu_server.server.domain.member.service.MemberService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -11,8 +9,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - @RestController @Slf4j @RequiredArgsConstructor @@ -34,14 +30,4 @@ public ResponseEntity test(@AuthenticationPrincipal ContextUser con public MemberResponseDto findById(@PathVariable Long id) { return memberService.findById(id); } - - @GetMapping("/generation/{id}") - public List findGenerationByMemberId(@PathVariable Long id) { - return memberService.findGenerationByMemberId(id); - } - - @GetMapping("/project/{id}") - public List findProjectByMemberId(@PathVariable Long id) { - return memberService.findProjectByMemberId(id); - } } diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/member/domain/ProjectRepository.java b/Server/src/main/java/com/gdscswu_server/server/domain/member/domain/ProjectRepository.java index b540e50..52793e7 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/member/domain/ProjectRepository.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/member/domain/ProjectRepository.java @@ -7,5 +7,5 @@ @Repository public interface ProjectRepository extends JpaRepository { - List findAllByMemberOrderById(Member member); + List findAllByMemberOrderByGenerationDesc(Member member); } diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/member/dto/MemberResponseDto.java b/Server/src/main/java/com/gdscswu_server/server/domain/member/dto/MemberResponseDto.java index d5d1666..1eb4ea5 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/member/dto/MemberResponseDto.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/member/dto/MemberResponseDto.java @@ -3,6 +3,8 @@ import com.gdscswu_server.server.domain.member.domain.Member; import lombok.Getter; +import java.util.List; + @Getter public class MemberResponseDto { private String name; @@ -11,13 +13,17 @@ public class MemberResponseDto { private String profileImagePath; private String introduction; private String email; + private List generationResponseDtoList; + private List projectResponseDtoList; - public MemberResponseDto(Member member) { + public MemberResponseDto(Member member, List generationResponseDtoList, List projectResponseDtoList) { this.name = member.getName(); this.major = member.getMajor(); this.admissionYear = member.getAdmissionYear(); this.profileImagePath = member.getProfileImagePath(); this.introduction = member.getIntroduction(); this.email = member.getEmail(); + this.generationResponseDtoList = generationResponseDtoList; + this.projectResponseDtoList = projectResponseDtoList; } } diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/member/service/MemberService.java b/Server/src/main/java/com/gdscswu_server/server/domain/member/service/MemberService.java index becd6dd..a050814 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/member/service/MemberService.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/member/service/MemberService.java @@ -22,7 +22,7 @@ public class MemberService { private final GenerationRepository generationRepository; private final ProjectRepository projectRepository; - // Get Member Information + // Read Member Information(Member Info, Generation, Project) @Transactional(readOnly = true) public MemberResponseDto findById(Long id) { Optional optionalMember = memberRepository.findById(id); @@ -30,30 +30,14 @@ public MemberResponseDto findById(Long id) { throw new IllegalArgumentException("해당 멤버가 없습니다. id = " + id); } - return new MemberResponseDto(optionalMember.get()); - } - - @Transactional(readOnly = true) - public List findGenerationByMemberId(Long id) { - Optional optionalMember = memberRepository.findById(id); - if(optionalMember.isEmpty()) { - throw new IllegalArgumentException("해당 멤버가 없습니다. id = " + id); - } - - return generationRepository.findAllByMemberOrderByNumberDesc(optionalMember.get()).stream() - .map(GenerationResponseDto::new) - .collect(Collectors.toList()); - } - - @Transactional(readOnly = true) - public List findProjectByMemberId(Long id) { - Optional optionalMember = memberRepository.findById(id); - if(optionalMember.isEmpty()) { - throw new IllegalArgumentException("해당 멤버가 없습니다. id = " + id); - } - - return projectRepository.findAllByMemberOrderById(optionalMember.get()).stream() + List generationResponseDtoList = + generationRepository.findAllByMemberOrderByNumberDesc(optionalMember.get()).stream() + .map(GenerationResponseDto::new) + .collect(Collectors.toList()); + List projectResponseDtoList = projectRepository.findAllByMemberOrderByGenerationDesc(optionalMember.get()).stream() .map(ProjectResponseDto::new) .collect(Collectors.toList()); + + return new MemberResponseDto(optionalMember.get(), generationResponseDtoList, projectResponseDtoList); } }