[EDIT] categoryテーブルにUser・削除フラグを追加しました
This commit is contained in:
@@ -3,6 +3,7 @@ package com.example.demo.app.domain.model;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -27,4 +28,15 @@ public class CategoryModel {
|
||||
return categoryEntityList.stream().map(CategoryModel::convertFrom).toList();
|
||||
}
|
||||
|
||||
public static CategoryEntity convertTo(CategoryModel categoryModel, UserEntity userEntity) {
|
||||
return new CategoryEntity(
|
||||
categoryModel.getCategoryId(),
|
||||
categoryModel.getCategoryName(),
|
||||
categoryModel.getTransactionType(),
|
||||
userEntity,
|
||||
0,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@@ -32,6 +35,13 @@ public class CategoryEntity {
|
||||
@Column(name = "transaction_type", nullable = false)
|
||||
private Integer transactionType;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "user_id")
|
||||
private UserEntity userEntity;
|
||||
|
||||
@Column(name = "delete_flag")
|
||||
private Integer deleteFlag;
|
||||
|
||||
@OneToMany(mappedBy = "categoryEntity")
|
||||
private List<TransactionEntity> transactionEntity;
|
||||
|
||||
|
||||
@@ -25,4 +25,11 @@ public class CategoryForm {
|
||||
return categoryModelList.stream().map(CategoryForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
public static CategoryModel convertTo(CategoryForm categoryForm) {
|
||||
return new CategoryModel(
|
||||
categoryForm.getCategoryId(),
|
||||
categoryForm.getCategoryName(),
|
||||
categoryForm.getTransactionType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user