我将Task实体表示为:
@Entity
@Getter
@NoArgsConstructor
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@NotBlank
private String name;
@Enumerated(EnumType.STRING)
private Category category;
@OneToOne
private Employee assignee;
@OneToMany
private List<Task> precedingTasks;
private String details;
private int estimatedTimeInMinutes;
private LocalDateTime deadline;
private LocalDateTime creationTime;
private LocalDateTime startTime;
private LocalDateTime endTime;
public Task(String name, Category category, Employee assignee, List<Task> precedingTasks, String details,
int estimatedTimeInMinutes, LocalDateTime deadline) {
this.name = name;
this.category = category;
this.assignee = assignee;
this.precedingTasks = precedingTasks;
this.details = details;
this.estimatedTimeInMinutes = estimatedTimeInMinutes;
this.deadline = deadline;
this.creationTime = LocalDateTime.now();
this.startTime = null;
this.endTime = null;
}
我注意到没有precedingTasks正确添加任务,但没有正确添加。
例如:添加三个任务后,precedingTasks我没有POST在 Postman 中发送,如下所示:
{
"name": "Wyslac przesyłke nr 87",
"category": "TODO",
"assigneeId": 1,
"precedingTasksId": [1, 2, 3],
"details": "Dodac zakladke",
"estimatedTimeInMinutes": 78,
"deadline": "2013-12-18T14:30:40.100000000"
}
但我得到的任务没有preceding tasks:
{
"id": 4,
"name": "Wyslac przesyłke nr 87",
"category": "TODO",
"assignee": {
"id": 1,
"firstName": "Wojciech",
"lastName": "Wasilewski",
"email": "wojtek@wasilewski.pl",
"role": "ADMIN",
"password": "h*n$GvFE",
"manager": true,
"password_LENGTH": 8,
"passwordValid": false
},
慕斯王
慕工程0101907
相关分类