Skip to content

Commit

Permalink
feat : 통계 관련 dto 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
rivkode committed Oct 28, 2023
1 parent a415971 commit 7f7871b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.snsIntegrationFeedService.post;

public enum CountType {
count, view_count, like_count, share_count
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.snsIntegrationFeedService.post;

public enum DateType {
date, hour
}
Original file line number Diff line number Diff line change
@@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit 7f7871b

Please sign in to comment.