Package com.nicholasalfonso.lato.service
Class CourseService
java.lang.Object
com.nicholasalfonso.lato.service.CourseService
Service for retrieving and updating user-owned courses.
-
Constructor Summary
ConstructorsConstructorDescriptionCourseService(CourseRepository courseRepository, AssignmentRepository assignmentRepository, CourseMapper courseMapper, AssignmentMapper assignmentMapper, IntegrationService integrationService) Creates the course service with required repositories and mappers. -
Method Summary
Modifier and TypeMethodDescriptioncalculateProgress(User user, Long courseId) Calculates completion progress for a course.getAssignments(User user, Long courseId) Returns non-archived assignments for a course sorted by due date.Loads a course owned by the given user.getCourses(User user) Returns all courses owned by the given user.getManualCourse(User user) Returns the default manual assignments course for the user, creating it if needed.updateCourse(User user, Long courseId, UpdateCourseRequest request) Updates editable course metadata fields.
-
Constructor Details
-
CourseService
public CourseService(CourseRepository courseRepository, AssignmentRepository assignmentRepository, CourseMapper courseMapper, AssignmentMapper assignmentMapper, IntegrationService integrationService) Creates the course service with required repositories and mappers.- Parameters:
courseRepository- repository for course persistenceassignmentRepository- repository for assignment queriescourseMapper- mapper for course response DTOsassignmentMapper- mapper for assignment response DTOsintegrationService- service used to resolve manual integrations
-
-
Method Details
-
getCourses
Returns all courses owned by the given user.- Parameters:
user- the owning user- Returns:
- course response list
-
getCourse
Loads a course owned by the given user.- Parameters:
user- the owning usercourseId- the course ID- Returns:
- the course entity
- Throws:
org.springframework.web.server.ResponseStatusException- if the course is not found
-
getManualCourse
Returns the default manual assignments course for the user, creating it if needed.- Parameters:
user- the owning user- Returns:
- the manual assignments course entity
-
updateCourse
@Transactional public CourseResponse updateCourse(User user, Long courseId, UpdateCourseRequest request) Updates editable course metadata fields.- Parameters:
user- the owning usercourseId- the course IDrequest- update details- Returns:
- updated course response
-
calculateProgress
Calculates completion progress for a course.- Parameters:
user- the owning usercourseId- the course ID- Returns:
- completed and total assignment counts for non-archived assignments
-
getAssignments
Returns non-archived assignments for a course sorted by due date.- Parameters:
user- the owning usercourseId- the course ID- Returns:
- assignment summary responses for the course
-