From 7f7871b4094a65c7aa544bf9a175e17a1e1ee2f2 Mon Sep 17 00:00:00 2001 From: jonghun Date: Sat, 28 Oct 2023 22:54:03 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=86=B5=EA=B3=84=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/CountType.java | 5 +++ .../post/DateType.java | 5 +++ .../post/dto/request/CreatePostRequest.java | 31 +++++++++++++++++++ .../post/dto/request/StaticsRequest.java | 25 +++++++++++++++ .../post/dto/response/StaticsResponse.java | 27 ++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 src/main/java/com/snsIntegrationFeedService/post/CountType.java create mode 100644 src/main/java/com/snsIntegrationFeedService/post/DateType.java create mode 100644 src/main/java/com/snsIntegrationFeedService/post/dto/request/CreatePostRequest.java create mode 100644 src/main/java/com/snsIntegrationFeedService/post/dto/request/StaticsRequest.java create mode 100644 src/main/java/com/snsIntegrationFeedService/post/dto/response/StaticsResponse.java diff --git a/src/main/java/com/snsIntegrationFeedService/post/CountType.java b/src/main/java/com/snsIntegrationFeedService/post/CountType.java new file mode 100644 index 0000000..ff03b7e --- /dev/null +++ b/src/main/java/com/snsIntegrationFeedService/post/CountType.java @@ -0,0 +1,5 @@ +package com.snsIntegrationFeedService.post; + +public enum CountType { + count, view_count, like_count, share_count +} diff --git a/src/main/java/com/snsIntegrationFeedService/post/DateType.java b/src/main/java/com/snsIntegrationFeedService/post/DateType.java new file mode 100644 index 0000000..67b6cd3 --- /dev/null +++ b/src/main/java/com/snsIntegrationFeedService/post/DateType.java @@ -0,0 +1,5 @@ +package com.snsIntegrationFeedService.post; + +public enum DateType { + date, hour +} diff --git a/src/main/java/com/snsIntegrationFeedService/post/dto/request/CreatePostRequest.java b/src/main/java/com/snsIntegrationFeedService/post/dto/request/CreatePostRequest.java new file mode 100644 index 0000000..0eff181 --- /dev/null +++ b/src/main/java/com/snsIntegrationFeedService/post/dto/request/CreatePostRequest.java @@ -0,0 +1,31 @@ +package com.snsIntegrationFeedService.post.dto.request; + +import com.snsIntegrationFeedService.post.entity.Post; +import com.snsIntegrationFeedService.post.entity.PostTypeEnum; +import com.snsIntegrationFeedService.user.entity.User; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public class CreatePostRequest { + + private PostTypeEnum type; + + private String title; + + private String content; + + private String hashtag; + + + public Post toEntity(User user, CreatePostRequest request) { + return Post.builder() + .user(user) + .type(request.type) + .title(request.title) + .content(request.content) + .build(); + } + +} diff --git a/src/main/java/com/snsIntegrationFeedService/post/dto/request/StaticsRequest.java b/src/main/java/com/snsIntegrationFeedService/post/dto/request/StaticsRequest.java new file mode 100644 index 0000000..248d6ba --- /dev/null +++ b/src/main/java/com/snsIntegrationFeedService/post/dto/request/StaticsRequest.java @@ -0,0 +1,25 @@ +package com.snsIntegrationFeedService.post.dto.request; + +import com.snsIntegrationFeedService.post.CountType; +import com.snsIntegrationFeedService.post.DateType; +import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +@Data +public class StaticsRequest { + private CountType value; + private DateType type; + private String hashtag; + private Date start; + private Date end; + + public StaticsRequest(CountType value, DateType type, String hashtag, Date start, Date end) { + this.value = (value != null) ? value : CountType.count; + this.type = type; + this.hashtag = (hashtag != null) ? hashtag : "본인계정"; + this.start = start; + this.end = end; + } +} diff --git a/src/main/java/com/snsIntegrationFeedService/post/dto/response/StaticsResponse.java b/src/main/java/com/snsIntegrationFeedService/post/dto/response/StaticsResponse.java new file mode 100644 index 0000000..370e232 --- /dev/null +++ b/src/main/java/com/snsIntegrationFeedService/post/dto/response/StaticsResponse.java @@ -0,0 +1,27 @@ +package com.snsIntegrationFeedService.post.dto.response; + +import com.snsIntegrationFeedService.post.entity.Post; +import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +//@NoArgsConstructor +@Getter +@Builder +public class StaticsResponse { + + private Date date; + + private long num; + + public static StaticsResponse from(Date date, int num) { + return StaticsResponse.builder() + .date(date) + .num(num) + .build(); + } + +}