|
|
@ -1,6 +1,7 @@
|
|
|
|
package ru.ulstu.students.service;
|
|
|
|
package ru.ulstu.students.service;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
@ -29,15 +30,15 @@ public class TaskService {
|
|
|
|
private final DeadlineService deadlineService;
|
|
|
|
private final DeadlineService deadlineService;
|
|
|
|
private final TagService tagService;
|
|
|
|
private final TagService tagService;
|
|
|
|
|
|
|
|
|
|
|
|
public TaskService(TaskRepository grantRepository,
|
|
|
|
public TaskService(TaskRepository taskRepository,
|
|
|
|
DeadlineService deadlineService, TagService tagService) {
|
|
|
|
DeadlineService deadlineService, TagService tagService) {
|
|
|
|
this.taskRepository = grantRepository;
|
|
|
|
this.taskRepository = taskRepository;
|
|
|
|
this.deadlineService = deadlineService;
|
|
|
|
this.deadlineService = deadlineService;
|
|
|
|
this.tagService = tagService;
|
|
|
|
this.tagService = tagService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Task> findAll() {
|
|
|
|
public List<Task> findAll() {
|
|
|
|
return taskRepository.findAll();
|
|
|
|
return taskRepository.findAll(new Sort(Sort.Direction.DESC, "createDate"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<TaskDto> findAllDto() {
|
|
|
|
public List<TaskDto> findAllDto() {
|
|
|
@ -51,9 +52,15 @@ public class TaskService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<TaskDto> filter(TaskFilterDto filterDto) {
|
|
|
|
public List<TaskDto> filter(TaskFilterDto filterDto) {
|
|
|
|
return convert(taskRepository.filter(
|
|
|
|
if (filterDto.getOrder().compareTo("new") == 0) {
|
|
|
|
filterDto.getStatus(),
|
|
|
|
return convert(taskRepository.filterNew(
|
|
|
|
filterDto.getTag() == null ? null : tagService.findById(filterDto.getTag())), TaskDto::new);
|
|
|
|
filterDto.getStatus(),
|
|
|
|
|
|
|
|
filterDto.getTag() == null ? null : tagService.findById(filterDto.getTag())), TaskDto::new);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return convert(taskRepository.filterOld(
|
|
|
|
|
|
|
|
filterDto.getStatus(),
|
|
|
|
|
|
|
|
filterDto.getTag() == null ? null : tagService.findById(filterDto.getTag())), TaskDto::new);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|