Add an "assignmentId" field in the "Assignment"-class.
This commit is contained in:
parent
87044574b5
commit
6729f51b03
|
@ -35,8 +35,9 @@ public class UrlController {
|
|||
List<Task> tasks = new ArrayList<>();
|
||||
|
||||
// TODO - Create the Assignment from the id-urls stored in the database up to the tasks-limit.
|
||||
int assignmentId = 0;
|
||||
|
||||
Assignment assignment = new Assignment(tasks, workerId, new Date());
|
||||
Assignment assignment = new Assignment(assignmentId, tasks, workerId, new Date());
|
||||
|
||||
// TODO - Write the Assignment details to the database and then send it to the worker.
|
||||
|
||||
|
@ -44,6 +45,8 @@ public class UrlController {
|
|||
}
|
||||
|
||||
|
||||
private static int assignmentId = -1; // Just for the "getTestUrls"-endpoint.
|
||||
|
||||
@GetMapping("test")
|
||||
public ResponseEntity<?> getTestUrls(@RequestParam String workerId, @RequestParam int tasksLimit) {
|
||||
|
||||
|
@ -84,7 +87,7 @@ public class UrlController {
|
|||
|
||||
}// end loading-while-loop
|
||||
|
||||
Assignment assignment = new Assignment(tasks, workerId, new Date());
|
||||
Assignment assignment = new Assignment((++assignmentId), tasks, workerId, new Date());
|
||||
|
||||
return ResponseEntity.status(200).header("Content-Type", "application/json").body(new AssignmentResponse(assignment));
|
||||
}
|
||||
|
|
|
@ -10,12 +10,16 @@ import java.util.List;
|
|||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"assignmentId",
|
||||
"tasks",
|
||||
"workerId",
|
||||
"date"
|
||||
})
|
||||
public class Assignment {
|
||||
|
||||
@JsonProperty("assignmentId")
|
||||
private int assignmentId;
|
||||
|
||||
@JsonProperty("tasks")
|
||||
private List<Task> tasks;
|
||||
|
||||
|
@ -25,12 +29,21 @@ public class Assignment {
|
|||
@JsonProperty("date")
|
||||
private Date date;
|
||||
|
||||
public Assignment(List<Task> tasks, String workerId, Date date) {
|
||||
public Assignment(int assignmentId, List<Task> tasks, String workerId, Date date) {
|
||||
this.assignmentId = assignmentId;
|
||||
this.tasks = tasks;
|
||||
this.workerId = workerId;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public int getAssignmentId() {
|
||||
return assignmentId;
|
||||
}
|
||||
|
||||
public void setAssignmentId(int assignmentId) {
|
||||
this.assignmentId = assignmentId;
|
||||
}
|
||||
|
||||
public List<Task> getTasks() {
|
||||
return tasks;
|
||||
}
|
||||
|
@ -58,7 +71,8 @@ public class Assignment {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "Assignment{" +
|
||||
"tasks=" + tasks +
|
||||
"assignmentId=" + assignmentId +
|
||||
", tasks=" + tasks +
|
||||
", workerId='" + workerId + '\'' +
|
||||
", date=" + date +
|
||||
'}';
|
||||
|
|
Loading…
Reference in New Issue