-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#94 | Implement the process of getting Assignment by ID (#156)
- Loading branch information
1 parent
729a674
commit e157d7d
Showing
10 changed files
with
345 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/ays/assignment/service/AssignmentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ays.assignment.service; | ||
|
||
|
||
import com.ays.assignment.model.Assignment; | ||
|
||
/** | ||
* Assignment Save Service to perform assignment related business operations. | ||
*/ | ||
public interface AssignmentService { | ||
|
||
/** | ||
* Get Assignment by Assignment ID | ||
* | ||
* @param id the given Assignment ID | ||
* @return Assignment | ||
*/ | ||
Assignment getAssignmentById(String id); | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/ays/assignment/service/impl/AssignmentServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.ays.assignment.service.impl; | ||
|
||
import com.ays.assignment.model.Assignment; | ||
import com.ays.assignment.model.entity.AssignmentEntity; | ||
import com.ays.assignment.model.mapper.AssignmentEntityToAssignmentMapper; | ||
import com.ays.assignment.repository.AssignmentRepository; | ||
import com.ays.assignment.service.AssignmentService; | ||
import com.ays.assignment.util.exception.AysAssignmentNotExistByIdException; | ||
import com.ays.auth.model.AysIdentity; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
class AssignmentServiceImpl implements AssignmentService { | ||
|
||
private final AssignmentRepository assignmentRepository; | ||
|
||
private final AysIdentity identity; | ||
|
||
private static final AssignmentEntityToAssignmentMapper assignmentEntityToAssignmentMapper = AssignmentEntityToAssignmentMapper.initialize(); | ||
|
||
/** | ||
* Retrieves an assignment by their ID. | ||
* | ||
* @param id the ID of the assignment to retrieve | ||
* @return the Assignment object representing the retrieved user | ||
* @throws AysAssignmentNotExistByIdException if the assignment with the specified ID does not exist | ||
*/ | ||
@Override | ||
public Assignment getAssignmentById(String id) { | ||
|
||
final AssignmentEntity assignmentEntity = assignmentRepository.findByIdAndInstitutionId(id, identity.getInstitutionId()) | ||
.orElseThrow(() -> new AysAssignmentNotExistByIdException(id)); | ||
|
||
return assignmentEntityToAssignmentMapper.map(assignmentEntity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.