1 package fr.tiogars.chat.domains.task.services;
2
3 import java.util.List;
4
5 import org.springframework.stereotype.Service;
6
7 import fr.tiogars.chat.domains.task.entities.TaskEntity;
8 import fr.tiogars.chat.domains.task.models.Task;
9 import fr.tiogars.chat.domains.task.repositories.TaskRepository;
10
11
12 @Service
13 @org.springframework.transaction.annotation.Transactional(readOnly = true)
14 public class TaskFindAllService {
15
16 private final TaskRepository repository;
17
18 public TaskFindAllService(TaskRepository repository) {
19 this.repository = repository;
20 }
21
22
23
24
25
26
27 public List<Task> findAll() {
28 return repository.findAllByOrderByCodeAsc().stream()
29 .map(TaskFindAllService::toRecord)
30 .toList();
31 }
32
33 static Task toRecord(TaskEntity entity) {
34 return new Task(
35 entity.getId(),
36 entity.getCode(),
37 entity.getLabel(),
38 entity.getDescription(),
39 entity.getCreatedDate(),
40 entity.getLastModifiedDate(),
41 entity.getCreatedBy(),
42 entity.getLastModifiedBy(),
43 entity.getStatus(), entity.getPriority(), entity.getDueDate(), entity.getAssignedTo(),
44 entity.getTagIds(), entity.getNomenclatureId());
45 }
46 }