Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<CourseModel> convertFrom(List<CourseEntity> courseEntityList) {
|
||||
return courseEntityList.stream().map(CourseModel::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -33,4 +37,15 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "category")
|
||||
@Table(name = "category_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -6,18 +6,19 @@ 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;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "course")
|
||||
@Table(name = "course_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@@ -39,6 +40,18 @@ public class CourseEntity {
|
||||
private List<UserEntity> userEntity;
|
||||
|
||||
@OneToOne(mappedBy = "courseEntity")
|
||||
private List<AllocationEntity> allocationEntity;
|
||||
private AllocationEntity allocationEntity;
|
||||
|
||||
|
||||
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
|
||||
|
||||
return courseEntityList
|
||||
.stream()
|
||||
.map(courseEntity -> new CourseModel(
|
||||
courseEntity.getCourseId(),
|
||||
courseEntity.getCourseName(),
|
||||
courseEntity.getDescription()
|
||||
)).toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "goal")
|
||||
@Table(name = "goal_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -15,7 +15,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "question")
|
||||
@Table(name = "question_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@@ -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> userEntity;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "transaction")
|
||||
@Table(name = "transaction_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -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<AllocationEntity, Long>{
|
||||
|
||||
List<AllocationEntity> 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<CourseInfoModel> findAllJoinedAllocation();
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class TransactionController {
|
||||
|
||||
model.addAttribute("transactionFormMap", transactionFormMap);
|
||||
|
||||
return "transactionList";
|
||||
return "transaction_list";
|
||||
}
|
||||
|
||||
// 詳細画面
|
||||
|
||||
Reference in New Issue
Block a user