Class CourseService

java.lang.Object
com.nicholasalfonso.lato.service.CourseService

@Service public class CourseService extends Object
Service for retrieving and updating user-owned courses.
  • 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 persistence
      assignmentRepository - repository for assignment queries
      courseMapper - mapper for course response DTOs
      assignmentMapper - mapper for assignment response DTOs
      integrationService - service used to resolve manual integrations
  • Method Details

    • getCourses

      public List<CourseResponse> getCourses(User user)
      Returns all courses owned by the given user.
      Parameters:
      user - the owning user
      Returns:
      course response list
    • getCourse

      public Course getCourse(User user, Long courseId)
      Loads a course owned by the given user.
      Parameters:
      user - the owning user
      courseId - the course ID
      Returns:
      the course entity
      Throws:
      org.springframework.web.server.ResponseStatusException - if the course is not found
    • getManualCourse

      public Course getManualCourse(User user)
      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 user
      courseId - the course ID
      request - update details
      Returns:
      updated course response
    • calculateProgress

      public CourseProgressResponse calculateProgress(User user, Long courseId)
      Calculates completion progress for a course.
      Parameters:
      user - the owning user
      courseId - the course ID
      Returns:
      completed and total assignment counts for non-archived assignments
    • getAssignments

      public List<AssignmentResponse> getAssignments(User user, Long courseId)
      Returns non-archived assignments for a course sorted by due date.
      Parameters:
      user - the owning user
      courseId - the course ID
      Returns:
      assignment summary responses for the course