[EDIT] 名前をもとに情報を取得する機能を追加しました。
This commit is contained in:
@@ -10,4 +10,5 @@ public interface CourseService {
|
|||||||
|
|
||||||
public CourseModel findById(Long courseId);
|
public CourseModel findById(Long courseId);
|
||||||
|
|
||||||
|
public Long findByName(String courName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,4 +25,8 @@ public class CourseServiceImpl implements CourseService {
|
|||||||
public CourseModel findById(Long courseId) {
|
public CourseModel findById(Long courseId) {
|
||||||
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
|
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long findByName(String courseName) {
|
||||||
|
return courseRepository.findByCourseName(courseName).getCourseId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,8 @@ public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
|
|||||||
@Query("SELECT c FROM CourseEntity c WHERE c.courseId = :courseId ")
|
@Query("SELECT c FROM CourseEntity c WHERE c.courseId = :courseId ")
|
||||||
public CourseEntity findByCourseId(Long courseId);
|
public CourseEntity findByCourseId(Long courseId);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM CourseEntity c WHERE c.courseName = :courseName ")
|
||||||
|
public CourseEntity findByCourseName(String courseName);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user