[EDIT] AllocationRepositoryにコース一覧に表示するデータを取得する@Queryを追加しました

This commit is contained in:
kkazuya
2026-09-17 14:20:34 +09:00
parent cf31d03415
commit f86d47c17a

View File

@@ -3,10 +3,28 @@ package com.example.demo.app.infra.repository;
import java.util.List; import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository; 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; import com.example.demo.app.infra.entity.AllocationEntity;
public interface AllocationRepository extends JpaRepository<AllocationEntity, Long>{ public interface AllocationRepository extends JpaRepository<AllocationEntity, Long>{
List<AllocationEntity> findByCourseId(Long courseId); 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();
} }