permitindo cadastrar tarefa sem projeto

This commit is contained in:
Gabriel Santana de Menezes 2026-05-03 19:01:03 -04:00
parent 495984e1a4
commit 25770cf58f
3 changed files with 7 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import net.beetechgroup.beetask.frameworks.persistence.entities.ProjectEntity;
public class ProjectEntityMapper {
public static ProjectEntity toEntity(Project project) {
if (project == null) return null;
ProjectEntity entity = new ProjectEntity();
entity.setId(project.getId());
entity.setName(project.getName());

View file

@ -10,7 +10,7 @@ public class CreateTaskMapper {
task.getTitle(),
task.getDescription(),
task.getStatus(),
task.getProject().getName(),
task.getProject() != null ? task.getProject().getName() : null,
task.getHistory().stream().map(CreateTaskMapper::toTaskHistoryItemOutput).toList());
}

View file

@ -16,8 +16,11 @@ public class CreateTaskUseCase {
task.setTitle(input.title());
task.setDescription(input.description());
task.setStatus(input.status());
task.setProject(new Project());
task.getProject().setId(input.projectId());
if (input.projectId() != null) {
Project project = new Project();
project.setId(input.projectId());
task.setProject(project);
}
return CreateTaskMapper.toCreateTaskOutput(taskRepository.saveTask(task));
}
}