-
Notifications
You must be signed in to change notification settings - Fork 0
/
Article.java
54 lines (44 loc) · 1.06 KB
/
Article.java
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
package sonegy.sample.model;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.util.Date;
/**
* @author: sonegy@sk.com
*/
@Entity
@Getter
@Setter(AccessLevel.PACKAGE)
@ToString
public class Article {
@Id
@GeneratedValue
private Long id;
@ManyToOne(optional = false)
private Board board;
private String title;
private String content;
@ManyToOne(fetch = FetchType.LAZY)
private Member createdBy;
private Date createdDate;
@ManyToOne(fetch = FetchType.LAZY)
private Member modifiedBy;
private Date modifiedDate;
Article() {
createdDate = new Date();
}
public Article(Board board, Member createdBy) {
this();
setCreatedBy(createdBy);
setBoard(board);
}
public Article modify(String title, String content, Member modifiedBy) {
this.title = title;
this.content = content;
this.modifiedDate = new Date();
this.modifiedBy = modifiedBy;
return this;
}
}