Klasse RecommendationAssignmentService
java.lang.Object
com.spaghetticodegang.trylater.recommendation.assignment.RecommendationAssignmentService
Service layer for handling recommendation assignment business logic.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
createRecommendationAssignment
(Recommendation recommendation, User receiver) Creates and saves a newRecommendationAssignment
entity, indicating that the recommendation was sent to a receiver.void
deleteRecommendationAssignmentByRecommendationId
(Long userId, Long recommendationId) Deletes a recommendation assignment by its user ID and recommendation ID.boolean
existsRecommendationInRecommendationAssignment
(Long recommendationId) Checks if there is an assignment for a given recommendation ID.getAllRecommendationsByUserAndAssignmentStatus
(User me, RecommendationAssignmentStatus recommendationAssignmentStatus) Delegates the get request from the recommendation service to the assignment repository for a given user and assignment status.getRecommendationAssignmentById
(Long recommendationAssignmentId) Finds a recommendation by its unique IDgetRecommendationAssignmentByUserIdAndRecommendationId
(Long userId, Long recommendationId) Returns aRecommendationAssignment
entity for a given user ID and recommendation ID.void
updateRecommendationAssignmentStatus
(User me, Long recommendationId, RecommendationAssignmentStatusRequestDto recommendationAssignmentStatusRequestDto) Performs validation and updates the recommendation assignment's status, including setting the acceptance date if applicable.
-
Konstruktordetails
-
RecommendationAssignmentService
public RecommendationAssignmentService()
-
-
Methodendetails
-
createRecommendationAssignment
Creates and saves a newRecommendationAssignment
entity, indicating that the recommendation was sent to a receiver.- Parameter:
recommendation
- the recommendation that was sentreceiver
- the user who receives the recommendation
-
updateRecommendationAssignmentStatus
public void updateRecommendationAssignmentStatus(User me, Long recommendationId, RecommendationAssignmentStatusRequestDto recommendationAssignmentStatusRequestDto) Performs validation and updates the recommendation assignment's status, including setting the acceptance date if applicable.- Parameter:
me
- the currently authenticated userrecommendationId
- the ID of the recommendation whose assignment status is to be updatedrecommendationAssignmentStatusRequestDto
- the DTO containing the new recommendation assignment status- Löst aus:
ValidationException
- if the status change is invalid
-
getRecommendationAssignmentById
Finds a recommendation by its unique ID- Parameter:
recommendationAssignmentId
- the ID of the recommendation assignment- Gibt zurück:
- the recommendation assignment entity
- Löst aus:
RecommendationAssignmentNotFoundException
- if the recommendation assignment is not found
-
getAllRecommendationsByUserAndAssignmentStatus
public List<Recommendation> getAllRecommendationsByUserAndAssignmentStatus(User me, RecommendationAssignmentStatus recommendationAssignmentStatus) Delegates the get request from the recommendation service to the assignment repository for a given user and assignment status.- Parameter:
me
- the currently authenticated userrecommendationAssignmentStatus
- the given status for the assigned recommendations- Gibt zurück:
- a list with recommendation entities or an empty list
-
deleteRecommendationAssignmentByRecommendationId
Deletes a recommendation assignment by its user ID and recommendation ID.- Parameter:
userId
- the user IDrecommendationId
- the recommendation ID- Löst aus:
RecommendationAssignmentNotFoundException
- if there is no assignment for the given user and recommendation.
-
getRecommendationAssignmentByUserIdAndRecommendationId
public RecommendationAssignment getRecommendationAssignmentByUserIdAndRecommendationId(Long userId, Long recommendationId) Returns aRecommendationAssignment
entity for a given user ID and recommendation ID.- Parameter:
userId
- the user IDrecommendationId
- the recommendation ID- Gibt zurück:
- A
RecommendationAssignment
entity
-
existsRecommendationInRecommendationAssignment
Checks if there is an assignment for a given recommendation ID.- Parameter:
recommendationId
- the recommendation ID- Gibt zurück:
- TRUE or FALSE
-