From 96c1615d92784bf39c31d7a6863d5ecfa4cd8c22 Mon Sep 17 00:00:00 2001 From: Yusun Choi Date: Fri, 15 Dec 2023 01:54:31 +0900 Subject: [PATCH] refactor: Rename fields on MemberResponseDto (#6) --- .../networking/dto/GenerationResponseDto.java | 7 +++--- .../networking/dto/MemberResponseDto.java | 6 ++--- .../networking/service/NetworkService.java | 25 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/GenerationResponseDto.java b/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/GenerationResponseDto.java index 74a496a..68a5b36 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/GenerationResponseDto.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/GenerationResponseDto.java @@ -11,13 +11,14 @@ public class GenerationResponseDto { private Integer number; // 기수 (1기, 2기...) private String department; // 부서 (안드, UX/UI...) private String level; // 레벨 (코어, 리드...) - private List projectResponseDtoList; + private List projectList; + @Builder - public GenerationResponseDto(Generation generation, List projectResponseDtoList) { + public GenerationResponseDto(Generation generation, List projectList) { this.number = generation.getNumber(); this.department = generation.getDepartment(); this.level = generation.getLevel(); - this.projectResponseDtoList = projectResponseDtoList; + this.projectList = projectList; } } diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/MemberResponseDto.java b/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/MemberResponseDto.java index 0a842a5..652ab7c 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/MemberResponseDto.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/networking/dto/MemberResponseDto.java @@ -15,16 +15,16 @@ public class MemberResponseDto { private Integer admissionYear; // 학번 private String profileImagePath; // 프로필 사진 private boolean bookmark; // 북마크 저장 여부 - private List generationResponseDtoList; + private List generationList; @Builder - public MemberResponseDto(Member member, boolean bookmark, List generationResponseDtoList) { + public MemberResponseDto(Member member, boolean bookmark, List generationList) { this.name = member.getName(); this.profileImagePath = member.getProfileImagePath(); this.major = member.getMajor(); this.admissionYear = member.getAdmissionYear(); this.bookmark = bookmark; - this.generationResponseDtoList = generationResponseDtoList; + this.generationList = generationList; } diff --git a/Server/src/main/java/com/gdscswu_server/server/domain/networking/service/NetworkService.java b/Server/src/main/java/com/gdscswu_server/server/domain/networking/service/NetworkService.java index c745be0..2b74ae3 100644 --- a/Server/src/main/java/com/gdscswu_server/server/domain/networking/service/NetworkService.java +++ b/Server/src/main/java/com/gdscswu_server/server/domain/networking/service/NetworkService.java @@ -18,8 +18,6 @@ import java.util.Set; import java.util.stream.Collectors; -import static org.apache.logging.log4j.ThreadContext.isEmpty; - @RequiredArgsConstructor @Service public class NetworkService { @@ -40,14 +38,15 @@ public ResponseEntity findAllMembers(FilterOptionsRequestDto filterOptio return memberResponseDto; }) .collect(Collectors.toList()); - memberResponseDtoList=memberResponseDtoList.stream().filter(filteredMembers -> isMemberMatch(filteredMembers, filterOptionsRequestDto)).collect(Collectors.toList()); - return ResponseEntity.ok(memberResponseDtoList); + memberResponseDtoList = memberResponseDtoList.stream().filter(filteredMembers -> isMemberMatch(filteredMembers, filterOptionsRequestDto)).collect(Collectors.toList()); + return ResponseEntity.ok(memberResponseDtoList); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); } } + @Transactional - private boolean isMemberMatch(MemberResponseDto filteredMembers,FilterOptionsRequestDto filterOptionsRequestDto) { + private boolean isMemberMatch(MemberResponseDto filteredMembers, FilterOptionsRequestDto filterOptionsRequestDto) { // 셋다 true 여야 return 해주는 로직 boolean partMatch; boolean levelMatch; @@ -56,20 +55,20 @@ private boolean isMemberMatch(MemberResponseDto filteredMembers,FilterOptionsReq // containsAll 메서드는 파라미터로 전달된 컬렉션이 비어있으면 무조건 true 를 반환 // 조건이 없으면 다 true 처리 함 (어차피 다른 조건 안맞으면 못 나감) partMatch = - filteredMembers.getGenerationResponseDtoList().stream() - .flatMap(generationResponseDto -> generationResponseDto.getProjectResponseDtoList().stream()) + filteredMembers.getGenerationList().stream() + .flatMap(generationResponseDto -> generationResponseDto.getProjectList().stream()) .map(ProjectResponseDto::getPart) .collect(Collectors.toList()) // filteredMembers 의 part 조건이 filterOptionsRequestDto 의 모든 조건을 포함하고 있는지 확인 // 필터링을 하고자 하는 조건을 멤버가 전부 가져야 함 .containsAll(filterOptionsRequestDto.getParts()); levelMatch = - filteredMembers.getGenerationResponseDtoList().stream() + filteredMembers.getGenerationList().stream() .map(GenerationResponseDto::getLevel) .collect(Collectors.toList()) .containsAll(filterOptionsRequestDto.getLevels()); departmentMatch = - filteredMembers.getGenerationResponseDtoList().stream() + filteredMembers.getGenerationList().stream() .map(GenerationResponseDto::getDepartment) .collect(Collectors.toList()) .containsAll(filterOptionsRequestDto.getDepartments()); @@ -125,7 +124,7 @@ private MemberResponseDto createMemberResponseDto(Member member, FilterOptionsRe return MemberResponseDto.builder() .member(member) .bookmark(bookmark) - .generationResponseDtoList(generationResponseDtoList) + .generationList(generationResponseDtoList) .build(); } @@ -140,11 +139,12 @@ private List createGenerationResponseDtoList(Member membe // GenerationResponseDto 생성 return GenerationResponseDto.builder() .generation(generation) - .projectResponseDtoList(projectResponseDtoList) + .projectList(projectResponseDtoList) .build(); }) .collect(Collectors.toList()); } + @Transactional private List createProjectResponseDtoList(Member member, Generation generation, FilterOptionsRequestDto filterOptionsRequestDto) { List projects = projectRepository.findByMemberAndGeneration(member, generation); @@ -157,7 +157,6 @@ private List createProjectResponseDtoList(Member member, Gen } - @Transactional public ResponseEntity bookmarkMember(Long memberIdToBookmark) { try { @@ -174,7 +173,7 @@ public ResponseEntity bookmarkMember(Long memberIdToBookmark) { } return ResponseEntity.ok(bookmarkRepository.existsByTargetMemberId(memberIdToBookmark)); - } catch (Exception e){ + } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); }