Package com.nicholasalfonso.lato.service
Class AssignmentService
java.lang.Object
com.nicholasalfonso.lato.service.AssignmentService
Service for retrieving and mutating user-owned assignments.
-
Constructor Summary
ConstructorsConstructorDescriptionAssignmentService(AssignmentRepository assignmentRepository, NoteRepository noteRepository, AssignmentMapper assignmentMapper, CourseService courseService) Creates the assignment service with required repositories and mappers. -
Method Summary
Modifier and TypeMethodDescriptionarchiveAssignment(User user, Long assignmentId, boolean archived) Archives or unarchives an assignment.createAssignment(User user, CreateAssignmentRequest request) Creates a new manually entered assignment for the user.deleteAssignment(User user, Long assignmentId) Permanently deletes an archived assignment.getArchivedAssignments(User user) Returns all archived assignments for the given user.getAssignment(User user, Long assignmentId) Loads an assignment owned by the given user.getDetailedAssignment(User user, Long assignmentId) Returns detailed assignment information including note content.getDisplayDescription(Assignment assignment) Returns the resolved display description for an assignment.getDisplayDueDate(Assignment assignment) Returns the resolved display due date for an assignment.getDisplayDueTime(Assignment assignment) Returns the resolved display due time for an assignment.getDisplayTitle(Assignment assignment) Returns the resolved display title for an assignment.markCompleted(User user, Long assignmentId, boolean completed) Marks an assignment complete or incomplete.updateAssignment(User user, Long assignmentId, UpdateAssignmentRequest request) Updates editable assignment fields and optional note content.
-
Constructor Details
-
AssignmentService
public AssignmentService(AssignmentRepository assignmentRepository, NoteRepository noteRepository, AssignmentMapper assignmentMapper, CourseService courseService) Creates the assignment service with required repositories and mappers.- Parameters:
assignmentRepository- repository for assignment persistencenoteRepository- repository for note persistenceassignmentMapper- mapper for assignment response DTOscourseService- service used to resolve owning courses
-
-
Method Details
-
getAssignment
Loads an assignment owned by the given user.- Parameters:
user- the owning userassignmentId- the assignment ID- Returns:
- the assignment entity
- Throws:
org.springframework.web.server.ResponseStatusException- if the assignment is not found
-
getDetailedAssignment
Returns detailed assignment information including note content.- Parameters:
user- the owning userassignmentId- the assignment ID- Returns:
- detailed assignment response
-
getArchivedAssignments
Returns all archived assignments for the given user.- Parameters:
user- the owning user- Returns:
- archived assignment detail responses
-
createAssignment
@Transactional public AssignmentResponse createAssignment(User user, CreateAssignmentRequest request) Creates a new manually entered assignment for the user.- Parameters:
user- the owning userrequest- assignment creation details- Returns:
- summary response for the created assignment
-
updateAssignment
@Transactional public AssignmentDetailResponse updateAssignment(User user, Long assignmentId, UpdateAssignmentRequest request) Updates editable assignment fields and optional note content.- Parameters:
user- the owning userassignmentId- the assignment IDrequest- update details- Returns:
- updated detailed assignment response
-
getDisplayTitle
Returns the resolved display title for an assignment.- Parameters:
assignment- the assignment entity- Returns:
- custom title when present, otherwise synced title
-
getDisplayDescription
Returns the resolved display description for an assignment.- Parameters:
assignment- the assignment entity- Returns:
- custom description when present, otherwise synced description
-
getDisplayDueDate
Returns the resolved display due date for an assignment.- Parameters:
assignment- the assignment entity- Returns:
- custom due date when present, otherwise synced due date
-
getDisplayDueTime
Returns the resolved display due time for an assignment.- Parameters:
assignment- the assignment entity- Returns:
- custom due time when present, otherwise synced due time
-
markCompleted
@Transactional public AssignmentResponse markCompleted(User user, Long assignmentId, boolean completed) Marks an assignment complete or incomplete.- Parameters:
user- the owning userassignmentId- the assignment IDcompleted- desired completion state- Returns:
- updated summary assignment response
- Throws:
org.springframework.web.server.ResponseStatusException- if the assignment is already in the requested state
-
archiveAssignment
@Transactional public AssignmentResponse archiveAssignment(User user, Long assignmentId, boolean archived) Archives or unarchives an assignment.- Parameters:
user- the owning userassignmentId- the assignment IDarchived- desired archival state- Returns:
- updated summary assignment response
- Throws:
org.springframework.web.server.ResponseStatusException- if the assignment is already in the requested state
-
deleteAssignment
Permanently deletes an archived assignment.- Parameters:
user- the owning userassignmentId- the assignment ID- Returns:
- confirmation message
- Throws:
org.springframework.web.server.ResponseStatusException- if the assignment is not archived
-