관리 메뉴

moozi

Entity, DTO 본문

Spring Boot JPA

Entity, DTO

moozi 2022. 5. 30. 10:27
/* Entity */
package com.mycompany.memo.entity;

import lombok.*;

import javax.persistence.*;

@Entity
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Memo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long mno;

    @Column(length=100, nullable=false)
    private String title;

    @Column(length = 500,nullable = false)
    private String content;

    //title수정
    public void changeTitle(String title){
        this.title=title;
    }
    //content수정
    public void changeContent(String content){
        this.content=content;
    }
}

/* DTO */
package com.mycompany.memo.dto;

import lombok.*;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class MemoDTO {
    private Long mno;
    private String title;
    private String content;
}

 

'Spring Boot JPA' 카테고리의 다른 글

Controller  (0) 2022.05.30
ServiceImpl  (0) 2022.05.30
Service  (0) 2022.05.30
Repository  (0) 2022.05.30
Memo 프로젝트 생성  (0) 2022.05.30
Comments