From 4d270225ddcf567b8bcb95e3874003868da23d04 Mon Sep 17 00:00:00 2001 From: Wonjeong Kim Date: Sat, 10 Feb 2024 16:12:47 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[Feat]=20=EC=A0=84=EC=B2=B4=20=EA=B8=B0?= =?UTF-8?q?=EC=88=98=20=EB=AA=A9=EB=A1=9D=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B8=B0,=20=EA=B8=B0=EC=88=98=EB=B3=84=20=EA=B7=B8=EB=A3=B9?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0,?= =?UTF-8?q?=20=EC=A0=84=EC=B2=B4=20=ED=8C=8C=ED=8A=B8=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/controller/GroupController.java | 21 +++++++++++++++ .../kr/data/dto/request/GroupRequestDto.java | 2 +- .../response/GroupYearListResponseDto.java | 15 +++++++++++ .../kr/data/repository/GroupRepository.java | 9 +++++++ .../inuappcenter/kr/service/GroupService.java | 26 ++++++++++++++++++- src/main/resources/application.yml | 2 +- 6 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java diff --git a/src/main/java/server/inuappcenter/kr/controller/GroupController.java b/src/main/java/server/inuappcenter/kr/controller/GroupController.java index 4810d71..2e3ed64 100644 --- a/src/main/java/server/inuappcenter/kr/controller/GroupController.java +++ b/src/main/java/server/inuappcenter/kr/controller/GroupController.java @@ -10,7 +10,9 @@ import org.springframework.web.bind.annotation.*; import server.inuappcenter.kr.common.data.dto.CommonResponseDto; import server.inuappcenter.kr.data.dto.request.GroupRequestDto; +import server.inuappcenter.kr.data.dto.response.GroupPartListResponseDto; import server.inuappcenter.kr.data.dto.response.GroupResponseDto; +import server.inuappcenter.kr.data.dto.response.GroupYearListResponseDto; import server.inuappcenter.kr.service.GroupService; import javax.validation.Valid; @@ -72,4 +74,23 @@ public ResponseEntity> searchByMemberName(final @PathVari return ResponseEntity.status(HttpStatus.OK).body(groupService.searchByMemberName(name)); } + @Operation(summary = "전체 기수 목록 가져오기", description = "서버에 등록된 기수 목록을 가져옵니다.") + @GetMapping("/all-groups-years") + public ResponseEntity findAllYears() { + return ResponseEntity.status(HttpStatus.OK).body(groupService.findAllYears()); + } + + @Operation(summary = "기수별 그룹 목록 가져오기", description = "기수와 파트 이름을 통해 기수별 그룹 목록을 가져옵니다.") + @GetMapping("/groups-by-year") + public ResponseEntity> findAllByYear(final @Parameter Double year, + final @Parameter String part) { + return ResponseEntity.status(HttpStatus.OK).body(groupService.findAllByYearAndPart(year, part)); + } + + @Operation(summary = "전체 파트 목록 가져오기", description = "서버에 등록된 파트 목록을 가져옵니다.") + @GetMapping("/all-parts") + public ResponseEntity findAllParts() { + return ResponseEntity.status(HttpStatus.OK).body(groupService.findAllParts()); + } + } diff --git a/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java b/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java index 2ce5e0b..92b7322 100644 --- a/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java +++ b/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java @@ -15,7 +15,7 @@ public class GroupRequestDto { @Schema( - example = "서버", + example = "Server", description = "서버, 안드로이드, iOS등... 파트 중 하나" ) @NotBlank(message = "파트가 비어있을 수 없습니다.") diff --git a/src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java new file mode 100644 index 0000000..b5d2fc3 --- /dev/null +++ b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java @@ -0,0 +1,15 @@ +package server.inuappcenter.kr.data.dto.response; + + +import lombok.Getter; + +import java.util.List; + +@Getter +public class GroupYearListResponseDto { + private final List yearList; + + public GroupYearListResponseDto(List yearList) { + this.yearList = yearList; + } +} diff --git a/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java b/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java index b2523f7..579a116 100644 --- a/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java +++ b/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java @@ -1,6 +1,7 @@ package server.inuappcenter.kr.data.repository; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import server.inuappcenter.kr.data.domain.Group; import server.inuappcenter.kr.data.domain.Member; @@ -16,4 +17,12 @@ public interface GroupRepository extends JpaRepository { List findAllByMember_Name(String name); + @Query("SELECT DISTINCT e.year FROM Group e") + List findAllYears(); + + List findAllByYearAndPart(Double year, String Part); + + @Query("SELECT DISTINCT e.part FROM Group e") + List findAllParts(); + } diff --git a/src/main/java/server/inuappcenter/kr/service/GroupService.java b/src/main/java/server/inuappcenter/kr/service/GroupService.java index 55eb1a5..0fc6a0f 100644 --- a/src/main/java/server/inuappcenter/kr/service/GroupService.java +++ b/src/main/java/server/inuappcenter/kr/service/GroupService.java @@ -8,7 +8,9 @@ import server.inuappcenter.kr.data.domain.Member; import server.inuappcenter.kr.data.domain.Role; import server.inuappcenter.kr.data.dto.request.GroupRequestDto; +import server.inuappcenter.kr.data.dto.response.GroupPartListResponseDto; import server.inuappcenter.kr.data.dto.response.GroupResponseDto; +import server.inuappcenter.kr.data.dto.response.GroupYearListResponseDto; import server.inuappcenter.kr.data.repository.GroupRepository; import server.inuappcenter.kr.data.repository.MemberRepository; import server.inuappcenter.kr.data.repository.RoleRepository; @@ -57,21 +59,43 @@ public GroupResponseDto updateGroup(GroupRequestDto groupRequestDto, Long id) { return GroupResponseDto.entityToDto(savedGroup); } - + @Transactional public CommonResponseDto deleteGroup(Long id) { groupRepository.deleteById(id); return new CommonResponseDto("id: " + id + " has been successfully deleted."); } + @Transactional public CommonResponseDto deleteMultipleGroups(List id) { groupRepository.deleteAllByIdInBatch(id); return new CommonResponseDto("id: " + id + " have been successfully deleted."); } + @Transactional(readOnly = true) public List searchByMemberName(String name) { List foundGroups = groupRepository.findAllByMember_Name(name); return foundGroups.stream() .map(data -> data.toGroupResponseDto(data)) .collect(Collectors.toList()); } + + @Transactional(readOnly = true) + public GroupYearListResponseDto findAllYears() { + List foundYears = groupRepository.findAllYears(); + return new GroupYearListResponseDto(foundYears); + } + + @Transactional(readOnly = true) + public List findAllByYearAndPart(Double year, String part) { + List foundGroups = groupRepository.findAllByYearAndPart(year, part); + return foundGroups.stream() + .map(data -> data.toGroupResponseDto(data)) + .collect(Collectors.toList()); + } + + @Transactional(readOnly = true) + public GroupPartListResponseDto findAllParts() { + List foundParts = groupRepository.findAllParts(); + return new GroupPartListResponseDto(foundParts); + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 277b314..cd4b16a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: password: test1234 jpa: hibernate: - ddl-auto: create + ddl-auto: none show-sql: true open-in-view: false properties: From 49af9d18038aa5d0c462d2a3ca2606ef921a904f Mon Sep 17 00:00:00 2001 From: Wonjeong Kim Date: Sat, 10 Feb 2024 16:13:02 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[Feat]=20=EC=A0=84=EC=B2=B4=20=ED=8C=8C?= =?UTF-8?q?=ED=8A=B8=20=EB=AA=A9=EB=A1=9D=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20#49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/GroupPartListResponseDto.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java diff --git a/src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java new file mode 100644 index 0000000..0c15889 --- /dev/null +++ b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java @@ -0,0 +1,14 @@ +package server.inuappcenter.kr.data.dto.response; + +import lombok.Getter; + +import java.util.List; + +@Getter +public class GroupPartListResponseDto { + private final List parts; + + public GroupPartListResponseDto(List parts) { + this.parts = parts; + } +} From 6e11e7eee944a788cbddc47bbb2c7766da0b1b73 Mon Sep 17 00:00:00 2001 From: Wonjeong Kim Date: Sat, 10 Feb 2024 16:12:47 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[Feat]=20=EC=A0=84=EC=B2=B4=20=EA=B8=B0?= =?UTF-8?q?=EC=88=98=20=EB=AA=A9=EB=A1=9D=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B8=B0,=20=EA=B8=B0=EC=88=98=EB=B3=84=20=EA=B7=B8=EB=A3=B9?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20#49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/controller/GroupController.java | 21 +++++++++++++++ .../kr/data/dto/request/GroupRequestDto.java | 2 +- .../response/GroupYearListResponseDto.java | 15 +++++++++++ .../kr/data/repository/GroupRepository.java | 9 +++++++ .../inuappcenter/kr/service/GroupService.java | 26 ++++++++++++++++++- src/main/resources/application.yml | 2 +- 6 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java diff --git a/src/main/java/server/inuappcenter/kr/controller/GroupController.java b/src/main/java/server/inuappcenter/kr/controller/GroupController.java index 4810d71..2e3ed64 100644 --- a/src/main/java/server/inuappcenter/kr/controller/GroupController.java +++ b/src/main/java/server/inuappcenter/kr/controller/GroupController.java @@ -10,7 +10,9 @@ import org.springframework.web.bind.annotation.*; import server.inuappcenter.kr.common.data.dto.CommonResponseDto; import server.inuappcenter.kr.data.dto.request.GroupRequestDto; +import server.inuappcenter.kr.data.dto.response.GroupPartListResponseDto; import server.inuappcenter.kr.data.dto.response.GroupResponseDto; +import server.inuappcenter.kr.data.dto.response.GroupYearListResponseDto; import server.inuappcenter.kr.service.GroupService; import javax.validation.Valid; @@ -72,4 +74,23 @@ public ResponseEntity> searchByMemberName(final @PathVari return ResponseEntity.status(HttpStatus.OK).body(groupService.searchByMemberName(name)); } + @Operation(summary = "전체 기수 목록 가져오기", description = "서버에 등록된 기수 목록을 가져옵니다.") + @GetMapping("/all-groups-years") + public ResponseEntity findAllYears() { + return ResponseEntity.status(HttpStatus.OK).body(groupService.findAllYears()); + } + + @Operation(summary = "기수별 그룹 목록 가져오기", description = "기수와 파트 이름을 통해 기수별 그룹 목록을 가져옵니다.") + @GetMapping("/groups-by-year") + public ResponseEntity> findAllByYear(final @Parameter Double year, + final @Parameter String part) { + return ResponseEntity.status(HttpStatus.OK).body(groupService.findAllByYearAndPart(year, part)); + } + + @Operation(summary = "전체 파트 목록 가져오기", description = "서버에 등록된 파트 목록을 가져옵니다.") + @GetMapping("/all-parts") + public ResponseEntity findAllParts() { + return ResponseEntity.status(HttpStatus.OK).body(groupService.findAllParts()); + } + } diff --git a/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java b/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java index 2ce5e0b..92b7322 100644 --- a/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java +++ b/src/main/java/server/inuappcenter/kr/data/dto/request/GroupRequestDto.java @@ -15,7 +15,7 @@ public class GroupRequestDto { @Schema( - example = "서버", + example = "Server", description = "서버, 안드로이드, iOS등... 파트 중 하나" ) @NotBlank(message = "파트가 비어있을 수 없습니다.") diff --git a/src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java new file mode 100644 index 0000000..b5d2fc3 --- /dev/null +++ b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupYearListResponseDto.java @@ -0,0 +1,15 @@ +package server.inuappcenter.kr.data.dto.response; + + +import lombok.Getter; + +import java.util.List; + +@Getter +public class GroupYearListResponseDto { + private final List yearList; + + public GroupYearListResponseDto(List yearList) { + this.yearList = yearList; + } +} diff --git a/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java b/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java index b2523f7..579a116 100644 --- a/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java +++ b/src/main/java/server/inuappcenter/kr/data/repository/GroupRepository.java @@ -1,6 +1,7 @@ package server.inuappcenter.kr.data.repository; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import server.inuappcenter.kr.data.domain.Group; import server.inuappcenter.kr.data.domain.Member; @@ -16,4 +17,12 @@ public interface GroupRepository extends JpaRepository { List findAllByMember_Name(String name); + @Query("SELECT DISTINCT e.year FROM Group e") + List findAllYears(); + + List findAllByYearAndPart(Double year, String Part); + + @Query("SELECT DISTINCT e.part FROM Group e") + List findAllParts(); + } diff --git a/src/main/java/server/inuappcenter/kr/service/GroupService.java b/src/main/java/server/inuappcenter/kr/service/GroupService.java index 55eb1a5..0fc6a0f 100644 --- a/src/main/java/server/inuappcenter/kr/service/GroupService.java +++ b/src/main/java/server/inuappcenter/kr/service/GroupService.java @@ -8,7 +8,9 @@ import server.inuappcenter.kr.data.domain.Member; import server.inuappcenter.kr.data.domain.Role; import server.inuappcenter.kr.data.dto.request.GroupRequestDto; +import server.inuappcenter.kr.data.dto.response.GroupPartListResponseDto; import server.inuappcenter.kr.data.dto.response.GroupResponseDto; +import server.inuappcenter.kr.data.dto.response.GroupYearListResponseDto; import server.inuappcenter.kr.data.repository.GroupRepository; import server.inuappcenter.kr.data.repository.MemberRepository; import server.inuappcenter.kr.data.repository.RoleRepository; @@ -57,21 +59,43 @@ public GroupResponseDto updateGroup(GroupRequestDto groupRequestDto, Long id) { return GroupResponseDto.entityToDto(savedGroup); } - + @Transactional public CommonResponseDto deleteGroup(Long id) { groupRepository.deleteById(id); return new CommonResponseDto("id: " + id + " has been successfully deleted."); } + @Transactional public CommonResponseDto deleteMultipleGroups(List id) { groupRepository.deleteAllByIdInBatch(id); return new CommonResponseDto("id: " + id + " have been successfully deleted."); } + @Transactional(readOnly = true) public List searchByMemberName(String name) { List foundGroups = groupRepository.findAllByMember_Name(name); return foundGroups.stream() .map(data -> data.toGroupResponseDto(data)) .collect(Collectors.toList()); } + + @Transactional(readOnly = true) + public GroupYearListResponseDto findAllYears() { + List foundYears = groupRepository.findAllYears(); + return new GroupYearListResponseDto(foundYears); + } + + @Transactional(readOnly = true) + public List findAllByYearAndPart(Double year, String part) { + List foundGroups = groupRepository.findAllByYearAndPart(year, part); + return foundGroups.stream() + .map(data -> data.toGroupResponseDto(data)) + .collect(Collectors.toList()); + } + + @Transactional(readOnly = true) + public GroupPartListResponseDto findAllParts() { + List foundParts = groupRepository.findAllParts(); + return new GroupPartListResponseDto(foundParts); + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 277b314..cd4b16a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: password: test1234 jpa: hibernate: - ddl-auto: create + ddl-auto: none show-sql: true open-in-view: false properties: From eaf06ec4a5b26aea359eae2c7b36e111fea618db Mon Sep 17 00:00:00 2001 From: Wonjeong Kim Date: Sat, 10 Feb 2024 16:13:02 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[Feat]=20=EC=A0=84=EC=B2=B4=20=ED=8C=8C?= =?UTF-8?q?=ED=8A=B8=20=EB=AA=A9=EB=A1=9D=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20#49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/GroupPartListResponseDto.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java diff --git a/src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java new file mode 100644 index 0000000..0c15889 --- /dev/null +++ b/src/main/java/server/inuappcenter/kr/data/dto/response/GroupPartListResponseDto.java @@ -0,0 +1,14 @@ +package server.inuappcenter.kr.data.dto.response; + +import lombok.Getter; + +import java.util.List; + +@Getter +public class GroupPartListResponseDto { + private final List parts; + + public GroupPartListResponseDto(List parts) { + this.parts = parts; + } +}