feat: add persistent async task mock
This commit is contained in:
1 parent
7949f29f1a
commit
cbc7317aa8
6 files changed
+186
-3
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package com.moyi.controlplane.task;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1")
|
||||
public class TaskController {
|
||||
private final AsyncTaskService tasks;
|
||||
|
||||
public TaskController(AsyncTaskService tasks) {
|
||||
this.tasks = tasks;
|
||||
}
|
||||
|
||||
@PostMapping("/3d/tasks")
|
||||
public ResponseEntity<Map<String, Object>> create3d(
|
||||
@RequestHeader(value = "Authorization", required = false) String authorization,
|
||||
@RequestBody Map<String, Object> input
|
||||
) {
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(Map.of("task", tasks.create(authorization, "3d", input)));
|
||||
}
|
||||
|
||||
@PostMapping("/video/tasks")
|
||||
public ResponseEntity<Map<String, Object>> createVideo(
|
||||
@RequestHeader(value = "Authorization", required = false) String authorization,
|
||||
@RequestBody Map<String, Object> input
|
||||
) {
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(Map.of("task", tasks.create(authorization, "video", input)));
|
||||
}
|
||||
|
||||
@GetMapping("/tasks/{id}")
|
||||
public Map<String, Object> get(
|
||||
@RequestHeader(value = "Authorization", required = false) String authorization,
|
||||
@PathVariable String id
|
||||
) {
|
||||
return Map.of("task", tasks.get(authorization, id));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user