permitindo cadastrar tarefa sem projeto
This commit is contained in:
parent
495984e1a4
commit
25770cf58f
3 changed files with 7 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ import net.beetechgroup.beetask.frameworks.persistence.entities.ProjectEntity;
|
||||||
public class ProjectEntityMapper {
|
public class ProjectEntityMapper {
|
||||||
|
|
||||||
public static ProjectEntity toEntity(Project project) {
|
public static ProjectEntity toEntity(Project project) {
|
||||||
|
if (project == null) return null;
|
||||||
ProjectEntity entity = new ProjectEntity();
|
ProjectEntity entity = new ProjectEntity();
|
||||||
entity.setId(project.getId());
|
entity.setId(project.getId());
|
||||||
entity.setName(project.getName());
|
entity.setName(project.getName());
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class CreateTaskMapper {
|
||||||
task.getTitle(),
|
task.getTitle(),
|
||||||
task.getDescription(),
|
task.getDescription(),
|
||||||
task.getStatus(),
|
task.getStatus(),
|
||||||
task.getProject().getName(),
|
task.getProject() != null ? task.getProject().getName() : null,
|
||||||
task.getHistory().stream().map(CreateTaskMapper::toTaskHistoryItemOutput).toList());
|
task.getHistory().stream().map(CreateTaskMapper::toTaskHistoryItemOutput).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,11 @@ public class CreateTaskUseCase {
|
||||||
task.setTitle(input.title());
|
task.setTitle(input.title());
|
||||||
task.setDescription(input.description());
|
task.setDescription(input.description());
|
||||||
task.setStatus(input.status());
|
task.setStatus(input.status());
|
||||||
task.setProject(new Project());
|
if (input.projectId() != null) {
|
||||||
task.getProject().setId(input.projectId());
|
Project project = new Project();
|
||||||
|
project.setId(input.projectId());
|
||||||
|
task.setProject(project);
|
||||||
|
}
|
||||||
return CreateTaskMapper.toCreateTaskOutput(taskRepository.saveTask(task));
|
return CreateTaskMapper.toCreateTaskOutput(taskRepository.saveTask(task));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue