|
@@ -0,0 +1,28 @@
|
|
|
+package com.qmth.demo.api.controller;
|
|
|
+
|
|
|
+import com.qmth.boot.api.annotation.Aac;
|
|
|
+import com.qmth.boot.api.annotation.BOOL;
|
|
|
+import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.demo.api.entity.DemoTask;
|
|
|
+import org.springframework.scheduling.TaskScheduler;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/task")
|
|
|
+@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
|
|
|
+public class TaskController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TaskScheduler taskScheduler;
|
|
|
+
|
|
|
+ @RequestMapping("/submit")
|
|
|
+ public boolean submit(@RequestParam(required = false, defaultValue = "0") Long delay) {
|
|
|
+ taskScheduler.schedule(new DemoTask(), new Date(new Date().getTime() + delay));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|