본문 바로가기
카테고리 없음

SpringBoot와 JPA를 연동한 Notice 구현하기

by 수바니 2024. 8. 27.
@Entity
@Table(name = "p_notice")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Notice {

    @Id
    @GeneratedValue
    @Column(name = "notice_id", updatable = false, nullable = false)
    private UUID id;

    @Column(nullable = false)
    private String noticeTitle;

    private String noticeContent;
    private Timestamp createdAt;
    private String createdBy;
    private Timestamp updatedAt;
    private String updatedBy;
    private Timestamp deletedAt;
    private String deletedBy;

}

notice의 Entity

 

 

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class NoticeListResponseDto {

    // 목록조회
    private UUID id;
    private String noticeTitle;
    private Timestamp createAt;
    private String createBy;
}

notice의 목록조회를 위한 Dto

 

@Data
@NoArgsConstructor
@AllArgsConstructor
public class NoticeRequestDto {

    // 공지사항 등록 수정
    private UUID id;
    private String noticeTitle; 
    private String noticeContent;
    private String createdBy; // 작성자
    private String updateBy; // 수정자
    private String deleteBy; // 삭제자
//    private Timestamp createdAt;
//    private Timestamp updatedAt;
//    private Timestamp deletedAt;

}

notice의 등록 수정을 위한 Dto

 

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class NoticeResponseDto {

    private UUID id;
    private String noticeTitle;
    private String noticeContent;
    private Timestamp createdAt;
    private String createdBy;
    private Timestamp updatedAt;
    private String updatedBy;
    private Timestamp deletedAt;
    private String deletedBy;

}

notice의 상세조회를 위한 Dto