// lombok의 어노테이션
@Getter // 클래스 내 모든 필드의 Getter 메소드를 자동생성
@NoArgsConstructor // 파라메터 없는 기본 생성자 자동추가, entity는 기본생성자가 꼭 있어야 한다
// 테이블과 링크 될 클래스임을 알린다
@Entity
public class Posts extends BaseTimeEntity {
@Id // pk필드
@GeneratedValue(strategy = GenerationType.IDENTITY) // pk생성규칙, auto_increment
private Long id;
@Column(length = 500, nullable = false)
private String title;
@Column(columnDefinition = "TEXT", nullable = false)
private String content;
private String author;
// 해당 클래스의 빌더 패턴 클래스를 생성
@Builder
public Posts(String title, String content, String author) {
this.title = title;
this.content = content;
this.author = author;
}
public void update(String title, String content) {
this.title = title;
this.content = content;
}
}