From 4fc69cddb328974a747ce04307de5dcd2b294a87 Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 14:04:20 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[EDIT]=20Course,=20AllocationEntity?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E5=90=8D=E3=82=92?= =?UTF-8?q?=E4=BF=AE=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(); + } + } From 7f828657ad892d5c5dff6f1b4043bbae3d0238c0 Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 14:09:06 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[ADD]=20Allocation,=20Course=E3=81=AEModel?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/domain/model/AllocationModel.java | 14 ++++++++++ .../demo/app/domain/model/CourseModel.java | 28 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/com/example/demo/app/domain/model/AllocationModel.java create mode 100644 src/main/java/com/example/demo/app/domain/model/CourseModel.java diff --git a/src/main/java/com/example/demo/app/domain/model/AllocationModel.java b/src/main/java/com/example/demo/app/domain/model/AllocationModel.java new file mode 100644 index 0000000..1f6a9c1 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/model/AllocationModel.java @@ -0,0 +1,14 @@ +package com.example.demo.app.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class AllocationModel { + + private Long categoryId; + private Long courseId; + private Integer allocationRatio; + +} diff --git a/src/main/java/com/example/demo/app/domain/model/CourseModel.java b/src/main/java/com/example/demo/app/domain/model/CourseModel.java new file mode 100644 index 0000000..e9e8014 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/model/CourseModel.java @@ -0,0 +1,28 @@ +package com.example.demo.app.domain.model; + +import java.util.List; + +import com.example.demo.app.infra.entity.CourseEntity; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class CourseModel { + + private Long courseId; + private String courseName; + private String description; + + public static CourseModel convertFrom(CourseEntity courseEntity) { + return new CourseModel( + courseEntity.getCourseId(), + courseEntity.getCourseName(), + courseEntity.getDescription()); + } + + public static List convertFrom(List courseEntityList) { + return courseEntityList.stream().map(CourseModel::convertFrom).toList(); + } +} From 80d83b96f4d49b5e68a6d2eb0c0c7b26be1d5b95 Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 17 Sep 2026 14:15:59 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[FIX]=20import=E5=8F=8A=E3=81=B3=E5=9E=8B?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=82=92=E8=A1=8C=E3=81=84=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/demo/app/infra/entity/CourseEntity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 f1a1d74..3afec50 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 @@ -6,12 +6,11 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import jakarta.persistence.OneToMany; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; -import org.springframework.data.annotation.Id; - import com.example.demo.app.domain.model.CourseModel; import lombok.AllArgsConstructor; @@ -41,7 +40,7 @@ public class CourseEntity { private List userEntity; @OneToOne(mappedBy = "courseEntity") - private List allocationEntity; + private AllocationEntity allocationEntity; public static List createCourseModelList(List courseEntityList) { From cf31d034151cdd60dbd7dae849f07f57cb845846 Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 17 Sep 2026 14:16:19 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[FIX]=20ID=E3=81=AE=E5=9E=8B=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/app/infra/entity/QuestionEntity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java b/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java index 6b94b7f..1eb3503 100644 --- a/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java @@ -24,12 +24,12 @@ public class QuestionEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "secret_question_id") - private Integer secretQuestionId; + private Long secretQuestionId; @Column(name = "question_text", nullable = false) private String questionText; - @OneToMany(mappedBy = "QuestionEntity") + @OneToMany(mappedBy = "questionEntity") private List userEntity; } From f86d47c17a72eda5393dd5de73d172aaab00fcfd Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 14:20:34 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[EDIT]=20AllocationRepository=E3=81=AB?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=82=B9=E4=B8=80=E8=A6=A7=E3=81=AB=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B@Query=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/repository/AllocationRepository.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java b/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java index df6d8f6..8817122 100644 --- a/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java @@ -3,10 +3,28 @@ package com.example.demo.app.infra.repository; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import com.example.demo.app.domain.model.CourseInfoModel; import com.example.demo.app.infra.entity.AllocationEntity; public interface AllocationRepository extends JpaRepository{ List findByCourseId(Long courseId); + + @Query(" SELECT co.course_id, " + + " co.course_name, " + + " ca.category_id, " + + " ca.categpry_name, " + + " a.allocation_ratio " + + " FROM allocation_m a " + + " INNER JOIN course_m co " + + " ON a.course_id = co.course_id " + + " INNER JOIN category_t ca " + + " on a.category_id = ca.category_id " + + " WHERE ca.transaction_type = 0 " + + " ORDER BY a.course_id ASC, " + + " a.category_id ASC ") + List findAllJoinedAllocation(); + } From e2286762d6248dd33089a5f8e451e4311767955d Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 17 Sep 2026 14:27:59 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[ADD]=20Allocation=E3=81=AE=E8=A4=87?= =?UTF-8?q?=E5=90=88=E3=82=AD=E3=83=BC=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/app/infra/entity/AllocationId.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/example/demo/app/infra/entity/AllocationId.java diff --git a/src/main/java/com/example/demo/app/infra/entity/AllocationId.java b/src/main/java/com/example/demo/app/infra/entity/AllocationId.java new file mode 100644 index 0000000..3812864 --- /dev/null +++ b/src/main/java/com/example/demo/app/infra/entity/AllocationId.java @@ -0,0 +1,16 @@ +package com.example.demo.app.infra.entity; + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AllocationId implements Serializable { + private Long categoryEntity; + + private Long courseEntity; +} From 1c5cb6bf7a35377aec2a89343c9e0ab2cf01a34a Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 17 Sep 2026 14:28:44 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[HOTFIX]=20Entity=E3=81=AE=E3=82=AD?= =?UTF-8?q?=E3=83=BC=E3=82=92=E5=86=8D=E5=AE=9A=E7=BE=A9=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/app/infra/entity/AllocationEntity.java | 2 ++ .../demo/app/infra/repository/AllocationRepository.java | 5 +++-- 2 files changed, 5 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 2598748..bd15a2c 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 @@ -6,6 +6,7 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.Id; +import jakarta.persistence.IdClass; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToOne; @@ -18,6 +19,7 @@ import lombok.Data; import lombok.NoArgsConstructor; @Entity +@IdClass(AllocationId.class) @Table(name = "allocation_m") @Data @NoArgsConstructor diff --git a/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java b/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java index 8817122..56913d8 100644 --- a/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java @@ -7,10 +7,11 @@ import org.springframework.data.jpa.repository.Query; import com.example.demo.app.domain.model.CourseInfoModel; import com.example.demo.app.infra.entity.AllocationEntity; +import com.example.demo.app.infra.entity.AllocationId; -public interface AllocationRepository extends JpaRepository{ +public interface AllocationRepository extends JpaRepository{ - List findByCourseId(Long courseId); + List findByCourseEntity_CourseId(Long courseId); @Query(" SELECT co.course_id, " + " co.course_name, " From 6b91c91c191825648b889d36d1188e929053de2c Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 14:29:59 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[ADD]=20Course,=20CourseInfoForm=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/presentation/form/CourseForm.java | 33 ++++++++++++++ .../app/presentation/form/CourseInfoForm.java | 44 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/main/java/com/example/demo/app/presentation/form/CourseForm.java create mode 100644 src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java diff --git a/src/main/java/com/example/demo/app/presentation/form/CourseForm.java b/src/main/java/com/example/demo/app/presentation/form/CourseForm.java new file mode 100644 index 0000000..57ba52e --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/CourseForm.java @@ -0,0 +1,33 @@ +package com.example.demo.app.presentation.form; + +import java.util.List; + +import com.example.demo.app.domain.model.CourseModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CourseForm { + + private Long courseId; + private String courseName; + private String description; + + + public static CourseForm convertFrom(CourseModel courseModel) { + return new CourseForm( + courseModel.getCourseId(), + courseModel.getCourseName(), + courseModel.getDescription() + ); + } + + public static List convertFrom(List courseModelList){ + return courseModelList.stream().map(CourseForm::convertFrom).toList(); + } + +} diff --git a/src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java b/src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java new file mode 100644 index 0000000..addce2f --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java @@ -0,0 +1,44 @@ +package com.example.demo.app.presentation.form; + +import java.util.List; + +import com.example.demo.app.domain.model.CourseInfoModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CourseInfoForm { + + private Long courseId; + + private String courseName; + + private Long categoryId; + + private String categoryName; + + private Integer allocationRatio; + + + public static CourseInfoForm convertFrom(CourseInfoModel courseInfoModel ) { + return new CourseInfoForm(courseInfoModel.getCategoryId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio()); + } + + public static List convertFrom(List courseInfoModelList ) { + return courseInfoModelList.stream().map(CourseInfoForm::convertFrom).toList(); + } + + public static CourseInfoModel convertTo(CourseInfoForm courseInfoForm) { + return new CourseInfoModel( + courseInfoForm.getCourseId(), + courseInfoForm.getCourseName(), + courseInfoForm.getCategoryId(), + courseInfoForm.getCategoryName(), + courseInfoForm.getAllocationRatio()); + } + +}