카테고리 없음
[SpringBoot] 커피관리 프로젝트 클론 코딩(1)
킹왕짱지지
2024. 4. 8. 15:14
Product entity 만들기
1) 고유식별자 UUID productID, productname, category, price, description, localdateTime, createdAt, updateAT 선언
2) 전체 constructor
3) 전체 getter
4) final이 아닌 변경되는 값에 대한 setter 설정
package com.example.gccoffee.model;
import java.time.LocalDateTime;
import java.util.UUID;
public class Product {
private final UUID productId;
private String productName;
private Category category;
private long price;
private String description;
private final LocalDateTime createdAt;
private LocalDateTime updatedAt;
public Product(UUID productId, String productName, Category category, long price){
this.productId = productId;
this.productName = productName;
this.category = category;
this.price = price;
this.createdAt = LocalDateTime.now();
this.updatedAt = LocalDateTime.now();
}
public Product(UUID productId, String productName, Category category, long price, String description, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.productId = productId;
this.productName = productName;
this.category = category;
this.price = price;
this.description = description;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
}
public UUID getProductId() {
return productId;
}
public String getProductName() {
return productName;
}
public Category getCategory() {
return category;
}
public long getPrice() {
return price;
}
public String getDescription() {
return description;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setCategory(Category category) {
this.category = category;
}
public void setDescription(String description) {
this.description = description;
this.updatedAt=LocalDateTime.now();
}
public void setPrice(long price) {
this.price = price;
this.updatedAt=LocalDateTime.now();
}
public void setProductName(String productName) {
this.productName = productName;
this.updatedAt=LocalDateTime.now();
}
}
Categroy entity 만들기
1) enum으로 coffee bean package 설정
package com.example.gccoffee.model;
public enum Category {
COFFEE_BEAN_PACKAGE
}
