|
@@ -0,0 +1,42 @@
|
|
|
+package com.xt.dsp.controller;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import com.xt.dsp.model.TaskBean;
|
|
|
+import com.xt.dsp.service.TaskService;
|
|
|
+import com.xt.dsp.service.TaskSqlService;
|
|
|
+import com.yuanxd.tools.io.http.JsonResult;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("task")
|
|
|
+public class TaskCtl {
|
|
|
+ @Autowired
|
|
|
+ private TaskService taskService;
|
|
|
+ @Autowired
|
|
|
+ private TaskSqlService taskSqlService;
|
|
|
+
|
|
|
+ @RequestMapping("run/{code}")
|
|
|
+ @ResponseBody
|
|
|
+ public JsonResult runTask(@PathVariable String code, String condition) {
|
|
|
+ TaskBean task = taskService.selectByCode(code);
|
|
|
+ JsonResult result = new JsonResult();
|
|
|
+ if (task == null) {
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage("任务不存在:" + code);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TaskBean.TYPE_SQL.equals(task.getType())) {
|
|
|
+ int res = taskSqlService.runTask(task, condition);
|
|
|
+ if (res == 0) {
|
|
|
+ result.setSuccess(true);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.setSuccess(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|