From 434986be972de730826ecb2e550134adb20e3b0b Mon Sep 17 00:00:00 2001 From: jisu <98259433+jisu-jeong0@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:10:44 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20clubPost=20=EC=9D=91=EB=8B=B5=20id?= =?UTF-8?q?=EA=B0=92=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club_post/application/ClubPostService.java | 10 ++++++---- .../club_post/dto/{ => request}/ClubPostReq.java | 6 +++--- .../dto/{ => request}/UpdateClubPostReq.java | 5 +---- .../dto/{ => response}/ClubPostDetailRes.java | 7 +++++-- .../club_post/dto/{ => response}/ClubPostRes.java | 10 ++++++---- .../club_post/presentation/ClubPostController.java | 10 +++++----- .../ideac/domain/home/application/HomeService.java | 12 +++++++++--- .../domain/home/presentation/HomeController.java | 4 ++-- 8 files changed, 37 insertions(+), 27 deletions(-) rename ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/{ => request}/ClubPostReq.java (86%) rename ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/{ => request}/UpdateClubPostReq.java (85%) rename ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/{ => response}/ClubPostDetailRes.java (78%) rename ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/{ => response}/ClubPostRes.java (67%) diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java index 8768498..5bff447 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java @@ -2,12 +2,12 @@ import depth.main.ideac.domain.club_post.ClubPost; import depth.main.ideac.domain.club_post.ClubPostImage; -import depth.main.ideac.domain.club_post.dto.ClubPostReq; -import depth.main.ideac.domain.club_post.dto.ClubPostRes; +import depth.main.ideac.domain.club_post.dto.request.ClubPostReq; +import depth.main.ideac.domain.club_post.dto.response.ClubPostRes; import depth.main.ideac.domain.club_post.repository.ClubPostImageRepository; import depth.main.ideac.domain.club_post.repository.ClubPostRepository; -import depth.main.ideac.domain.club_post.dto.ClubPostDetailRes; -import depth.main.ideac.domain.club_post.dto.UpdateClubPostReq; +import depth.main.ideac.domain.club_post.dto.response.ClubPostDetailRes; +import depth.main.ideac.domain.club_post.dto.request.UpdateClubPostReq; import depth.main.ideac.domain.user.domain.Role; import depth.main.ideac.domain.user.domain.User; import depth.main.ideac.global.error.DefaultException; @@ -42,6 +42,7 @@ public Page getAllClubPosts(Pageable pageable) { List clubPostResList = posts.getContent().stream() .map(clubPost -> ClubPostRes.builder() + .id(clubPost.getId()) .title(clubPost.getTitle()) .description(clubPost.getDetailedDescription()) .createdAt(clubPost.getCreatedAt()) @@ -72,6 +73,7 @@ public ClubPostDetailRes getDetailClubPosts(Long clubId) { .toList(); return ClubPostDetailRes.builder() + .id(clubPost.getId()) .title(clubPost.getTitle()) .description(clubPost.getDetailedDescription()) .url1(clubPost.getUrl1()) diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostReq.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/ClubPostReq.java similarity index 86% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostReq.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/ClubPostReq.java index 38bfea6..3105dd1 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostReq.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/ClubPostReq.java @@ -1,12 +1,13 @@ -package depth.main.ideac.domain.club_post.dto; +package depth.main.ideac.domain.club_post.dto.request; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.Getter; import lombok.NoArgsConstructor; -@Data +@Getter @NoArgsConstructor @AllArgsConstructor public class ClubPostReq { @@ -22,5 +23,4 @@ public class ClubPostReq { private String url2; - // 이미지 path는 추후 추가 } diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/UpdateClubPostReq.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/UpdateClubPostReq.java similarity index 85% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/UpdateClubPostReq.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/UpdateClubPostReq.java index 6d4f190..4912445 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/UpdateClubPostReq.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/UpdateClubPostReq.java @@ -1,4 +1,4 @@ -package depth.main.ideac.domain.club_post.dto; +package depth.main.ideac.domain.club_post.dto.request; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; @@ -8,7 +8,6 @@ import lombok.NoArgsConstructor; -@Data @NoArgsConstructor @AllArgsConstructor @Getter @@ -25,6 +24,4 @@ public class UpdateClubPostReq { private String url2; - // private List clubPostImages; - } diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostDetailRes.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostDetailRes.java similarity index 78% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostDetailRes.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostDetailRes.java index 919d443..0af6fe2 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostDetailRes.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostDetailRes.java @@ -1,15 +1,18 @@ -package depth.main.ideac.domain.club_post.dto; +package depth.main.ideac.domain.club_post.dto.response; import lombok.Builder; import lombok.Data; +import lombok.Getter; import java.time.LocalDateTime; import java.util.List; -@Data +@Getter @Builder public class ClubPostDetailRes { + private Long id; + private String title; private String description; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostRes.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostRes.java similarity index 67% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostRes.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostRes.java index 2f0af4c..729df3f 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostRes.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostRes.java @@ -1,15 +1,17 @@ -package depth.main.ideac.domain.club_post.dto; +package depth.main.ideac.domain.club_post.dto.response; -import depth.main.ideac.domain.club_post.ClubPost; import lombok.Builder; -import lombok.Data; +import lombok.Getter; + import java.time.LocalDateTime; -@Data +@Getter @Builder public class ClubPostRes { + private Long id; + private String title; private String description; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java index 44035dd..7efa967 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java @@ -1,10 +1,10 @@ package depth.main.ideac.domain.club_post.presentation; import depth.main.ideac.domain.club_post.application.ClubPostService; -import depth.main.ideac.domain.club_post.dto.ClubPostDetailRes; -import depth.main.ideac.domain.club_post.dto.ClubPostReq; -import depth.main.ideac.domain.club_post.dto.ClubPostRes; -import depth.main.ideac.domain.club_post.dto.UpdateClubPostReq; +import depth.main.ideac.domain.club_post.dto.response.ClubPostDetailRes; +import depth.main.ideac.domain.club_post.dto.request.ClubPostReq; +import depth.main.ideac.domain.club_post.dto.response.ClubPostRes; +import depth.main.ideac.domain.club_post.dto.request.UpdateClubPostReq; import depth.main.ideac.global.config.security.token.CurrentUser; import depth.main.ideac.global.config.security.token.UserPrincipal; import depth.main.ideac.global.payload.ApiResponse; @@ -38,7 +38,7 @@ public class ClubPostController { @Operation(summary = "글 전체 조회", description = "동아리/학회 페이지의 글을 전체 조회하는 API입니다.") @GetMapping public ResponseEntity getAllClubPosts(@RequestParam(defaultValue = "0") int page, - @RequestParam(defaultValue = "10") int size) { + @RequestParam(defaultValue = "10") int size) { Pageable pageable = PageRequest.of(page, size, Sort.by("createdAt").descending()); Page posts = clubPostService.getAllClubPosts(pageable); diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java b/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java index 0cf9bf6..bd34a69 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java @@ -2,10 +2,10 @@ import depth.main.ideac.domain.club_post.ClubPost; import depth.main.ideac.domain.club_post.ClubPostImage; -import depth.main.ideac.domain.club_post.dto.ClubPostRes; +import depth.main.ideac.domain.club_post.dto.response.ClubPostRes; import depth.main.ideac.domain.club_post.repository.ClubPostRepository; import depth.main.ideac.domain.idea_post.IdeaPost; -import depth.main.ideac.domain.idea_post.dto.GetAllIdeasRes; +import depth.main.ideac.domain.idea_post.dto.response.GetAllIdeasRes; import depth.main.ideac.domain.idea_post.repository.IdeaPostRepository; import depth.main.ideac.domain.project_post.ProjectPost; import depth.main.ideac.domain.project_post.ProjectPostImage; @@ -27,17 +27,19 @@ public class HomeService { private final IdeaPostRepository ideaPostRepository; private final ProjectPostRepository projectPostRepository; - // 아이디어 public List getIdeas() { List ideaPosts = ideaPostRepository.findTop3ByOrderByCreatedAtDesc(); return ideaPosts.stream() .map(ideaPost -> GetAllIdeasRes.builder() + .id(ideaPost.getId()) .title(ideaPost.getTitle()) .simpleDescription(ideaPost.getSimpleDescription()) .keyword(ideaPost.getKeyword()) + .hits(ideaPost.getHits()) .color(ideaPost.getUser().getColor()) .nickName(ideaPost.getUser().getNickname()) + .createdAt(ideaPost.getCreatedAt()) .build()) .collect(Collectors.toList()); } @@ -54,12 +56,15 @@ public List getProjects() { .map(ProjectPostImage::getImagePath) .orElse(null); return ProjectRes.builder() + .id(projectPost.getId()) .booleanWeb(projectPost.isBooleanWeb()) .booleanApp(projectPost.isBooleanApp()) .booleanAi(projectPost.isBooleanAi()) .team(projectPost.getTeam()) .title(projectPost.getTitle()) .simpleDescription(projectPost.getSimpleDescription()) + .hits(projectPost.getHits()) + .createdAt(projectPost.getCreatedAt()) .thumbnail(thumbnail) .build(); }) @@ -72,6 +77,7 @@ public List getClubs() { return clubPosts.stream() .map(clubPost -> ClubPostRes.builder() + .id(clubPost.getId()) .title(clubPost.getTitle()) .description(clubPost.getDetailedDescription()) .thumbnail(clubPost.getClubPostImages().stream() diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java b/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java index dd27c7e..50e1e89 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java @@ -1,8 +1,8 @@ package depth.main.ideac.domain.home.presentation; -import depth.main.ideac.domain.club_post.dto.ClubPostRes; +import depth.main.ideac.domain.club_post.dto.response.ClubPostRes; import depth.main.ideac.domain.home.application.HomeService; -import depth.main.ideac.domain.idea_post.dto.GetAllIdeasRes; +import depth.main.ideac.domain.idea_post.dto.response.GetAllIdeasRes; import depth.main.ideac.domain.project_post.dto.response.ProjectRes; import depth.main.ideac.global.payload.ApiResponse; import io.swagger.v3.oas.annotations.Operation;