From 4fc69cddb328974a747ce04307de5dcd2b294a87 Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 14:04:20 +0900 Subject: [PATCH] =?UTF-8?q?[EDIT]=20Course,=20AllocationEntity=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E5=90=8D=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/app/infra/entity/AllocationEntity.java | 17 ++++++++++++++++- .../demo/app/infra/entity/CourseEntity.java | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java b/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java index 8a6d1a0..2598748 100644 --- a/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java @@ -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 createAllocationModelList(List allocationEntityList) { + return allocationEntityList + .stream() + .map(allocationEntity -> new AllocationModel( + allocationEntity.getCategoryEntity().getCategoryId(), + allocationEntity.getCourseEntity().getCourseId(), + allocationEntity.getAllocationRatio() + )).toList(); + } } diff --git a/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java b/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java index 995ac6b..f1a1d74 100644 --- a/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java @@ -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; + + public static List createCourseModelList(List courseEntityList) { + + return courseEntityList + .stream() + .map(courseEntity -> new CourseModel( + courseEntity.getCourseId(), + courseEntity.getCourseName(), + courseEntity.getDescription() + )).toList(); + } + }