feat(backend): add received-documents endpoint for persons

Add findByReceiversId to DocumentRepository, getDocumentsByReceiver
to DocumentService, and GET /api/persons/{id}/received-documents
to PersonController. Tests added for both service and controller layers.

Closes #1
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-03-20 09:39:18 +01:00
parent 4ccc8d69d0
commit 557b62ac5c
5 changed files with 74 additions and 0 deletions

View File

@@ -38,6 +38,11 @@ public class PersonController {
return documentService.getDocumentsBySender(id);
}
@GetMapping("/{id}/received-documents")
public List<Document> getPersonReceivedDocuments(@PathVariable UUID id) {
return documentService.getDocumentsByReceiver(id);
}
@PostMapping
public ResponseEntity<Person> createPerson(@RequestBody Map<String, String> body) {
String firstName = body.get("firstName");

View File

@@ -30,6 +30,8 @@ public interface DocumentRepository extends JpaRepository<Document, UUID>, JpaSp
List<Document> findBySenderId(UUID senderId);
List<Document> findByReceiversId(UUID receiverId);
List<Document> findByTags_Id(UUID tagId);
@Query("SELECT DISTINCT d FROM Document d " +

View File

@@ -254,6 +254,10 @@ public class DocumentService {
return documentRepository.findBySenderId(senderId);
}
public List<Document> getDocumentsByReceiver(UUID receiverId) {
return documentRepository.findByReceiversId(receiverId);
}
public List<Document> getConversationFiltered(UUID senderId, UUID receiverId, LocalDate from, LocalDate to, Sort sort) {
LocalDate dateFrom = (from != null) ? from : LocalDate.parse("0000-01-01");
LocalDate dateTo = (to != null) ? to : LocalDate.now();