From dea5d5bb3915a6db72cf79b59a3384cdee6de485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cadashkdy9960?= <â€vjftmxmwlwhs@gmail.com> Date: Wed, 24 Jan 2024 12:00:56 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feature:=20=ED=95=98=EC=9D=B4=EB=B8=8C=20?= =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hhive/domain/category/data/SubCategory.java | 4 ++++ .../domain/hive/controller/HiveController.java | 15 ++++++++++++++- .../domain/hive/dto/CreateHiveRequestDTO.java | 9 +++++++++ .../hhive/domain/hive/dto/HiveResponseDTO.java | 12 +++++++++++- .../com/HHive/hhive/domain/hive/entity/Hive.java | 12 ++++++++++++ .../domain/hive/repository/HiveRepository.java | 8 ++++++++ .../hhive/domain/hive/service/HiveService.java | 15 +++++++++++++++ 7 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java b/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java index 3140de7..fe7b359 100644 --- a/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java +++ b/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java @@ -1,5 +1,8 @@ package com.HHive.hhive.domain.category.data; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; + public enum SubCategory { //GAME @@ -11,6 +14,7 @@ public enum SubCategory { SOCCER(MajorCategory.SPORTS, "축구"), BASEBALL(MajorCategory.SPORTS, "야구"); + @Enumerated(EnumType.STRING) private final MajorCategory majorCategory; private final String title; diff --git a/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java b/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java index bf79b43..10c8787 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java +++ b/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java @@ -1,5 +1,7 @@ package com.HHive.hhive.domain.hive.controller; +import com.HHive.hhive.domain.category.data.MajorCategory; +import com.HHive.hhive.domain.category.data.SubCategory; import com.HHive.hhive.domain.hive.dto.CreateHiveRequestDTO; import com.HHive.hhive.domain.hive.dto.HiveResponseDTO; import com.HHive.hhive.domain.hive.dto.UpdateHiveRequestDTO; @@ -70,7 +72,18 @@ public ResponseEntity gethives() { .body(new CommonResponse<>(200, "하이브들이 조회되었습니다.", responses)); } - @PatchMapping("{hive_id}") + @GetMapping("/search") + public ResponseEntity getHivesByCategory( + @RequestParam(required = false) String majorCategory, + @RequestParam(required = false) String subCategory) { + List responses = hiveService.getHivesByCategory( + MajorCategory.valueOf(majorCategory), SubCategory.valueOf(subCategory)); + return ResponseEntity.ok() + .body(new CommonResponse<>(200, "하이브들이 조회되었습니다.", responses)); + } + + + @DeleteMapping("{hive_id}") public ResponseEntity deleteHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id) { diff --git a/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java b/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java index c816c23..5818c5c 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java +++ b/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java @@ -1,8 +1,11 @@ package com.HHive.hhive.domain.hive.dto; +import com.HHive.hhive.domain.category.data.MajorCategory; +import com.HHive.hhive.domain.category.data.SubCategory; import com.HHive.hhive.domain.hive.entity.Hive; import com.HHive.hhive.domain.user.entity.User; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Null; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -17,9 +20,15 @@ public class CreateHiveRequestDTO { @NotBlank private String title; + private MajorCategory majorCategory; + + private SubCategory subCategory; + public Hive toEntity(User createdBy) { return Hive.builder() .title(title) + .majorCategory(majorCategory) + .subCategory(subCategory) .creatorId(createdBy.getId()) .introduction("내용을 넣어주세요") .user(createdBy) diff --git a/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java b/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java index 61b56bc..3fd5a0d 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java +++ b/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java @@ -1,6 +1,7 @@ package com.HHive.hhive.domain.hive.dto; import com.HHive.hhive.domain.hive.entity.Hive; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; import java.util.List; import lombok.AllArgsConstructor; @@ -18,6 +19,10 @@ public class HiveResponseDTO { private String title; + private String majorCategory; + + private String subCategory; + private String introduction; private Long hostId; @@ -26,14 +31,19 @@ public class HiveResponseDTO { private List hivePlayers; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") private LocalDateTime createdAt; - + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") private LocalDateTime modifiedAt; public static HiveResponseDTO of(Hive hive) { return HiveResponseDTO.builder() .id(hive.getId()) .title(hive.getTitle()) +// .majorCategory(String.valueOf(hive.getMajorCategory())) +// .subCategory(String.valueOf(hive.getSubCategory())) + .majorCategory(hive.getMajorCategory().getTitle()) + .subCategory(hive.getSubCategory().getTitle()) .introduction(hive.getIntroduction()) .hostId(hive.getId()) .hostName(hive.getUser().getEmail()) diff --git a/src/main/java/com/HHive/hhive/domain/hive/entity/Hive.java b/src/main/java/com/HHive/hhive/domain/hive/entity/Hive.java index a6f519c..99ccca6 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/entity/Hive.java +++ b/src/main/java/com/HHive/hhive/domain/hive/entity/Hive.java @@ -1,11 +1,15 @@ package com.HHive.hhive.domain.hive.entity; +import com.HHive.hhive.domain.category.data.MajorCategory; +import com.HHive.hhive.domain.category.data.SubCategory; import com.HHive.hhive.domain.hive.dto.UpdateHiveRequestDTO; import com.HHive.hhive.domain.user.entity.User; import com.HHive.hhive.global.auditing.BaseTimeEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @@ -35,6 +39,14 @@ public class Hive extends BaseTimeEntity { @Column(nullable = false, unique = true) private String title; + @Column + @Enumerated(EnumType.STRING) + private MajorCategory majorCategory; + + @Column + @Enumerated(EnumType.STRING) + private SubCategory subCategory; + @Column private String introduction; diff --git a/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java b/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java index 29b3d7a..0231d2a 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java +++ b/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java @@ -1,10 +1,13 @@ package com.HHive.hhive.domain.hive.repository; +import com.HHive.hhive.domain.category.data.MajorCategory; +import com.HHive.hhive.domain.category.data.SubCategory; import com.HHive.hhive.domain.hive.entity.Hive; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository @@ -17,4 +20,9 @@ public interface HiveRepository extends JpaRepository { @Query("SELECT h FROM Hive h WHERE h.isDeleted = false") List findAllHiveNotDeleted(); + @Query("SELECT h FROM Hive h WHERE (:majorCategory is null OR h.majorCategory = :majorCategory) AND (:subCategory is null OR h.subCategory = :subCategory)") + List findAllByMajorCategoryAndSubCategoryContaining( + @Param("majorCategory") MajorCategory majorCategory, + @Param("subCategory")SubCategory subCategory + ); } \ No newline at end of file diff --git a/src/main/java/com/HHive/hhive/domain/hive/service/HiveService.java b/src/main/java/com/HHive/hhive/domain/hive/service/HiveService.java index 21c88fc..92abf56 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/service/HiveService.java +++ b/src/main/java/com/HHive/hhive/domain/hive/service/HiveService.java @@ -1,5 +1,7 @@ package com.HHive.hhive.domain.hive.service; +import com.HHive.hhive.domain.category.data.MajorCategory; +import com.HHive.hhive.domain.category.data.SubCategory; import com.HHive.hhive.domain.hive.dto.CreateHiveRequestDTO; import com.HHive.hhive.domain.hive.dto.HiveResponseDTO; import com.HHive.hhive.domain.hive.dto.UpdateHiveRequestDTO; @@ -65,6 +67,18 @@ public List getHives() { return hives.stream().map(HiveResponseDTO::of).toList(); } + public List getHivesByCategory(MajorCategory majorCategory, + SubCategory subCategory) { + List hives = hiveRepository.findAllByMajorCategoryAndSubCategoryContaining( + majorCategory, subCategory); + + if (hives.isEmpty()) { + throw new NotFoundHiveException(); + } + + return hives.stream().map(HiveResponseDTO::of).toList(); + } + @Transactional public void deleteHive(User user, Long hiveId) { Hive hive = getHiveAndCheckAuth(user, hiveId); @@ -120,4 +134,5 @@ public Hive findHiveById(Long hiveId) { NotFoundHiveException::new); } + } \ No newline at end of file From 65b86dc5177f4ba204c35cf3d1561769488f9032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cadashkdy9960?= <â€vjftmxmwlwhs@gmail.com> Date: Wed, 24 Jan 2024 18:06:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=ED=95=98=EC=9D=B4=EB=B8=8C=20?= =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EB=B3=84=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hhive/domain/category/data/MajorCategory.java | 6 ++++++ .../HHive/hhive/domain/category/data/SubCategory.java | 5 +++++ .../hhive/domain/hive/controller/HiveController.java | 2 +- .../HHive/hhive/domain/hive/dto/HiveResponseDTO.java | 10 ++++++---- .../hhive/domain/hive/repository/HiveRepository.java | 3 ++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/HHive/hhive/domain/category/data/MajorCategory.java b/src/main/java/com/HHive/hhive/domain/category/data/MajorCategory.java index b567a1a..729da29 100644 --- a/src/main/java/com/HHive/hhive/domain/category/data/MajorCategory.java +++ b/src/main/java/com/HHive/hhive/domain/category/data/MajorCategory.java @@ -1,5 +1,7 @@ package com.HHive.hhive.domain.category.data; +import java.util.Arrays; + public enum MajorCategory { GAME("게임"), @@ -14,4 +16,8 @@ public enum MajorCategory { public String getTitle() { return title; } + + public static MajorCategory findByStringName(String categoryName) { + return Arrays.stream(MajorCategory.values()).filter(majorCategory -> majorCategory.name().equals(categoryName)).findFirst().orElse(null); + } } diff --git a/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java b/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java index fe7b359..d53f0e2 100644 --- a/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java +++ b/src/main/java/com/HHive/hhive/domain/category/data/SubCategory.java @@ -2,6 +2,7 @@ import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; +import java.util.Arrays; public enum SubCategory { @@ -30,4 +31,8 @@ public MajorCategory getMajorCategory() { public String getTitle() { return title; } + + public static SubCategory findByStringName(String categoryName) { + return Arrays.stream(SubCategory.values()).filter(subCategory -> subCategory.name().equals(categoryName)).findFirst().orElse(null); + } } diff --git a/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java b/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java index 10c8787..0035b63 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java +++ b/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java @@ -77,7 +77,7 @@ public ResponseEntity getHivesByCategory( @RequestParam(required = false) String majorCategory, @RequestParam(required = false) String subCategory) { List responses = hiveService.getHivesByCategory( - MajorCategory.valueOf(majorCategory), SubCategory.valueOf(subCategory)); + MajorCategory.findByStringName(majorCategory), SubCategory.findByStringName(subCategory)); return ResponseEntity.ok() .body(new CommonResponse<>(200, "하이브들이 조회되었습니다.", responses)); } diff --git a/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java b/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java index 3fd5a0d..4005af2 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java +++ b/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java @@ -37,13 +37,15 @@ public class HiveResponseDTO { private LocalDateTime modifiedAt; public static HiveResponseDTO of(Hive hive) { + String majorName = hive.getMajorCategory() == null? "": hive.getMajorCategory().getTitle(); + + String subName = hive.getSubCategory() == null? "": hive.getSubCategory().getTitle(); + return HiveResponseDTO.builder() .id(hive.getId()) .title(hive.getTitle()) -// .majorCategory(String.valueOf(hive.getMajorCategory())) -// .subCategory(String.valueOf(hive.getSubCategory())) - .majorCategory(hive.getMajorCategory().getTitle()) - .subCategory(hive.getSubCategory().getTitle()) + .majorCategory(majorName) + .subCategory(subName) .introduction(hive.getIntroduction()) .hostId(hive.getId()) .hostName(hive.getUser().getEmail()) diff --git a/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java b/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java index 0231d2a..d746449 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java +++ b/src/main/java/com/HHive/hhive/domain/hive/repository/HiveRepository.java @@ -20,7 +20,8 @@ public interface HiveRepository extends JpaRepository { @Query("SELECT h FROM Hive h WHERE h.isDeleted = false") List findAllHiveNotDeleted(); - @Query("SELECT h FROM Hive h WHERE (:majorCategory is null OR h.majorCategory = :majorCategory) AND (:subCategory is null OR h.subCategory = :subCategory)") + @Query("SELECT h FROM Hive h WHERE (:majorCategory is null OR h.majorCategory = :majorCategory) " + + "AND (:subCategory is null OR h.subCategory = :subCategory) AND (:majorCategory is not null OR :subCategory is not null)") List findAllByMajorCategoryAndSubCategoryContaining( @Param("majorCategory") MajorCategory majorCategory, @Param("subCategory")SubCategory subCategory From 7932ec69dde1bb6935618a039f62a6269294ba1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cadashkdy9960?= <â€vjftmxmwlwhs@gmail.com> Date: Wed, 24 Jan 2024 21:29:08 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=ED=95=98=EC=9D=B4=EB=B8=8C=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=EA=B0=92=20200=EC=9D=84=20HttpStatus.OK.value()=EB=A1=9C=20?= =?UTF-8?q?=EB=B0=98=EC=98=81,=20=EC=BD=94=EB=93=9C=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hive/controller/HiveController.java | 48 ++++++++++--------- .../domain/hive/dto/CreateHiveRequestDTO.java | 1 - .../domain/hive/dto/HiveResponseDTO.java | 5 +- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java b/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java index 0035b63..c496e90 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java +++ b/src/main/java/com/HHive/hhive/domain/hive/controller/HiveController.java @@ -7,7 +7,6 @@ import com.HHive.hhive.domain.hive.dto.UpdateHiveRequestDTO; import com.HHive.hhive.domain.hive.service.HiveService; import com.HHive.hhive.domain.relationship.hiveuser.dto.HiveUserInviteRequestDTO; -import com.HHive.hhive.domain.relationship.hiveuser.service.HiveUserService; import com.HHive.hhive.domain.user.UserDetailsImpl; import com.HHive.hhive.domain.user.dto.UserInfoResponseDTO; import com.HHive.hhive.global.common.CommonResponse; @@ -15,6 +14,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.DeleteMapping; @@ -34,103 +34,105 @@ public class HiveController { private final HiveService hiveService; - private final HiveUserService hiveUserService; @PostMapping - public ResponseEntity createHive( + public ResponseEntity> createHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody @Valid CreateHiveRequestDTO createHiveRequestDTO) { HiveResponseDTO response = hiveService.createHive(userDetails.getUser(), createHiveRequestDTO); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브가 작성되었습니다.", response)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브가 작성되었습니다.", response)); } @PatchMapping("{hive_id}/update") - public ResponseEntity updateHive( + public ResponseEntity> updateHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id, @RequestBody @Valid UpdateHiveRequestDTO updateRequest) { HiveResponseDTO response = hiveService.updateHive(userDetails.getUser(), hive_id, updateRequest); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브가 수정되었습니다.", response)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브가 수정되었습니다.", response)); } @GetMapping("/{hive_id}") - public ResponseEntity getHive( + public ResponseEntity> getHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id) { HiveResponseDTO response = hiveService.getHive(userDetails.getUser(), hive_id); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브가 조회되었습니다.", response)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브가 조회되었습니다.", response)); } @GetMapping("") - public ResponseEntity gethives() { + public ResponseEntity>> gethives() { List responses = hiveService.getHives(); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브들이 조회되었습니다.", responses)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브들이 조회되었습니다.", responses)); } @GetMapping("/search") - public ResponseEntity getHivesByCategory( + public ResponseEntity>> getHivesByCategory( @RequestParam(required = false) String majorCategory, @RequestParam(required = false) String subCategory) { List responses = hiveService.getHivesByCategory( - MajorCategory.findByStringName(majorCategory), SubCategory.findByStringName(subCategory)); + MajorCategory.findByStringName(majorCategory), + SubCategory.findByStringName(subCategory)); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브들이 조회되었습니다.", responses)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브들이 조회되었습니다.", responses)); } @DeleteMapping("{hive_id}") - public ResponseEntity deleteHive( + public ResponseEntity> deleteHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id) { hiveService.deleteHive(userDetails.getUser(), hive_id); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브가 삭제되었습니다.", null)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브가 삭제되었습니다.", null)); } @PostMapping("/{hive_id}") - public ResponseEntity inviteNewUser( + public ResponseEntity> inviteNewUser( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id, @RequestBody @Valid HiveUserInviteRequestDTO requestDTO) { hiveService.inviteNewUser(userDetails.getUser(), hive_id, requestDTO); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브에 참여하였습니다.", null)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브에 참여하였습니다.", null)); } @GetMapping("/{hive_id}/hiveUsers") - public ResponseEntity getHiveUsersInHive( + public ResponseEntity>> getHiveUsersInHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id) { List hiveUserResponses = hiveService.searchUsersInHive( userDetails.getUser(), hive_id); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브 유저들이 조회되었습니다.", hiveUserResponses)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브 유저들이 조회되었습니다.", + hiveUserResponses)); } @GetMapping("/{hive_id}/hiveUsers/search") - public ResponseEntity getHiveUserInHive( + public ResponseEntity> getHiveUserInHive( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id, @RequestParam String username) { UserInfoResponseDTO hiveUserResponse = hiveService.searchUserInHive(userDetails.getUser(), hive_id, username); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브 유저가 조회되었습니다.", hiveUserResponse)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브 유저가 조회되었습니다.", + hiveUserResponse)); } @DeleteMapping("{hive_id}/hiveUsers") - public ResponseEntity deleteHiveUser( + public ResponseEntity> deleteHiveUser( @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long hive_id, @RequestParam String username) { hiveService.deleteHiveUser(userDetails.getUser(), hive_id, username); return ResponseEntity.ok() - .body(new CommonResponse<>(200, "하이브 유저가 탈퇴되었습니다.", null)); + .body(CommonResponse.of(HttpStatus.OK.value(), "하이브 유저가 탈퇴되었습니다.", null)); } } \ No newline at end of file diff --git a/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java b/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java index 5818c5c..4f6480e 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java +++ b/src/main/java/com/HHive/hhive/domain/hive/dto/CreateHiveRequestDTO.java @@ -5,7 +5,6 @@ import com.HHive.hhive.domain.hive.entity.Hive; import com.HHive.hhive.domain.user.entity.User; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Null; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java b/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java index 4005af2..8efde3f 100644 --- a/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java +++ b/src/main/java/com/HHive/hhive/domain/hive/dto/HiveResponseDTO.java @@ -37,9 +37,10 @@ public class HiveResponseDTO { private LocalDateTime modifiedAt; public static HiveResponseDTO of(Hive hive) { - String majorName = hive.getMajorCategory() == null? "": hive.getMajorCategory().getTitle(); + String majorName = + hive.getMajorCategory() == null ? "" : hive.getMajorCategory().getTitle(); - String subName = hive.getSubCategory() == null? "": hive.getSubCategory().getTitle(); + String subName = hive.getSubCategory() == null ? "" : hive.getSubCategory().getTitle(); return HiveResponseDTO.builder() .id(hive.getId())