
Web Application을 만들기 위한 요구사항
Controller와 DTO를 작성함으로써,
두 가지를 구현했다.
Service Layer에서는 세 가지 요구사항을 처리
모든 계좌에는 잔액이 표시되어야 한다 라는 데이터베이스의 제약이 있다고 가정할 때, 계좌의 잔액을 삭제하는 쿼리를 트랜잭션으로 수행을 했을때, 이는 잔액이 표시되어야한다는 잔액을 위반했기 때문에 Consistency가 깨진다고 할 수 있다.@Transactional 을 클래스나 메소드 앞에 붙여서 사용한다.@Service
class CourseServiceImpl: CourseService {
override fun getAllCourseList(): List<CourseResponse> {
// TODO: DB에서 모든 Course를 가져와서 CourseResponse로 변환 후 반환
TODO("Not yet implemented")
}
override fun getCourseById(courseId: Long): CourseResponse {
// TODO: 만약 courseId에 해당하는 Course가 없다면 throw ModelNotFoundException
// TODO: DB에서 courseId에 해당하는 Course를 가져와서 CourseResponse로 변환 후 반환
TODO("Not yet implemented")
}
@Transactional
override fun createCourse(request: CreateCourseRequest): CourseResponse {
// TODO: request를 Course로 변환 후 DB에 저장
TODO("Not yet implemented")
}
@Transactional
override fun updateCourse(courseId: Long, request: UpdateCourseRequest): CourseResponse {
// TODO: 만약 courseId에 해당하는 Course가 없다면 throw ModelNotFoundException
// TODO: DB에서 courseId에 해당하는 Course를 가져와서 request로 업데이트 후 DB에 저장, 결과를 CourseResponse로 변환 후 반환
TODO("Not yet implemented")
}
@Transactional
override fun deleteCourse(courseId: Long) {
// TODO: 만약 courseId에 해당하는 Course가 없다면 throw ModelNotFoundException
// TODO: DB에서 courseId에 해당하는 Course를 삭제, 연관된 CourseApplication과 Lecture도 모두 삭제
TODO("Not yet implemented")
}
}