[EDIT] Course, AllocationEntityのテーブル名を修正
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -9,12 +11,14 @@ import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import com.example.demo.app.domain.model.AllocationModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "allocation")
|
||||
@Table(name = "allocation_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@@ -32,5 +36,16 @@ public class AllocationEntity {
|
||||
|
||||
@Column(name = "allocation_ratio", nullable = false)
|
||||
private Integer allocationRatio;
|
||||
|
||||
|
||||
public static List<AllocationModel> createAllocationModelList(List<AllocationEntity> allocationEntityList) {
|
||||
|
||||
return allocationEntityList
|
||||
.stream()
|
||||
.map(allocationEntity -> new AllocationModel(
|
||||
allocationEntity.getCategoryEntity().getCategoryId(),
|
||||
allocationEntity.getCourseEntity().getCourseId(),
|
||||
allocationEntity.getAllocationRatio()
|
||||
)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@ import jakarta.persistence.Table;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "course")
|
||||
@Table(name = "course_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@@ -41,4 +43,16 @@ public class CourseEntity {
|
||||
@OneToOne(mappedBy = "courseEntity")
|
||||
private List<AllocationEntity> allocationEntity;
|
||||
|
||||
|
||||
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
|
||||
|
||||
return courseEntityList
|
||||
.stream()
|
||||
.map(courseEntity -> new CourseModel(
|
||||
courseEntity.getCourseId(),
|
||||
courseEntity.getCourseName(),
|
||||
courseEntity.getDescription()
|
||||
)).toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user