api sample
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import com.kamco.cd.kamcoback.zoo.dto.AnimalDto;
|
||||
import com.kamco.cd.kamcoback.zoo.dto.AnimalDto.Category;
|
||||
import com.kamco.cd.kamcoback.zoo.dto.AnimalDto.Species;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.UUID;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
// 기본구조 관련
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Table(name = "tb_animal")
|
||||
public class AnimalEntity extends CommonDateEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long uid;
|
||||
|
||||
@Column(unique = true)
|
||||
private UUID uuid;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Category category;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Species species;
|
||||
|
||||
private String name;
|
||||
private Boolean isDeleted;
|
||||
|
||||
// Construct
|
||||
public AnimalEntity(Category category, Species species, String name) {
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.category = category;
|
||||
this.species = species;
|
||||
this.name = name;
|
||||
this.isDeleted = false;
|
||||
}
|
||||
|
||||
public AnimalDto.Basic toDto() {
|
||||
return new AnimalDto.Basic(
|
||||
this.uid,
|
||||
this.uuid.toString(),
|
||||
this.name,
|
||||
this.category,
|
||||
this.species,
|
||||
super.getCreatedDate(),
|
||||
super.getModifiedDate());
|
||||
}
|
||||
|
||||
public void deleted() {
|
||||
this.isDeleted = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user