-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubtaskservice.java
More file actions
48 lines (29 loc) · 1.29 KB
/
Copy pathsubtaskservice.java
File metadata and controls
48 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package openin.assignment.service;
import com.example.taskmanager.exception.ResourceNotFoundException;
import com.example.taskmanager.model.SubTask;
import com.example.taskmanager.repository.SubTaskRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class subtaskservice {
@Autowired
private SubTaskRepository subTaskRepository;
public SubTask createSubTask(SubTask subTask) {
return subTaskRepository.save(subTask);
}
public List<SubTask> getSubTasksByTaskId(Long taskId) {
return subTaskRepository.findByTaskId(taskId);
}
public SubTask updateSubTaskStatus(Long subTaskId, int status) {
SubTask subTask = subTaskRepository.findById(subTaskId)
.orElseThrow(() -> new ResourceNotFoundException("SubTask not found with id: " + subTaskId));
subTask.setStatus(status);
return subTaskRepository.save(subTask);
}
public void deleteSubTask(Long subTaskId) {
SubTask subTask = subTaskRepository.findById(subTaskId)
.orElseThrow(() -> new ResourceNotFoundException("SubTask not found with id: " + subTaskId));
subTaskRepository.delete(subTask);
}
}