-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathArticle.java
More file actions
109 lines (100 loc) · 2.25 KB
/
Article.java
File metadata and controls
109 lines (100 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.newzet.api.article.domain;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
@Getter
@Builder(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class Article {
private final UUID id;
private final UUID toUserId;
private final String fromName;
private final String fromDomain;
private final String mailingList;
private final String title;
private final String imageUrl;
private final String contentUrl;
private final boolean isRead;
private final boolean isLike;
private final boolean isShare;
private final LocalDateTime createdAt;
private final LocalDateTime deletedAt;
public static Article create(
UUID id,
UUID toUserId,
String fromName,
String fromDomain,
String mailingList,
String title,
String imageUrl,
String contentUrl,
boolean isRead,
boolean isLike,
boolean isShare,
LocalDateTime createdAt,
LocalDateTime deletedAt) {
return Article.builder()
.id(id)
.toUserId(toUserId)
.fromName(fromName)
.fromDomain(fromDomain)
.mailingList(mailingList)
.title(title)
.imageUrl(imageUrl)
.contentUrl(contentUrl)
.isRead(isRead)
.isLike(isLike)
.isShare(isShare)
.createdAt(createdAt != null ? createdAt : LocalDateTime.now())
.deletedAt(deletedAt)
.build();
}
public static Article createNewArticle(
UUID toUserId,
String fromName,
String fromDomain,
String mailingList,
String imageUrl,
String title,
String contentUrl) {
return Article.builder()
.toUserId(toUserId)
.fromName(fromName)
.fromDomain(fromDomain)
.mailingList(mailingList)
.imageUrl(imageUrl)
.title(title)
.contentUrl(contentUrl)
.isRead(false)
.isLike(false)
.isShare(false)
.createdAt(LocalDateTime.now())
.build();
}
public boolean checkIsUnRead() {
return !isRead;
}
public Article share() {
return new Article(
this.id,
this.toUserId,
this.fromName,
this.fromDomain,
this.mailingList,
this.title,
this.contentUrl,
this.imageUrl,
this.isRead,
this.isLike,
true,
this.createdAt,
this.deletedAt
);
}
public boolean isSaveInStorage() {
return contentUrl.endsWith(".html");
}
}