From 6b91c91c191825648b889d36d1188e929053de2c Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 14:29:59 +0900 Subject: [PATCH] =?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()); + } + +}