Job服务方法调整,为提供API服务做准备

pull/6/head
xuxueli 7 years ago
parent 18991c3f5b
commit 37e9a00139

@ -41,11 +41,11 @@ public class IndexController {
return "index"; return "index";
} }
@RequestMapping("/triggerChartDate") @RequestMapping("/chartInfo")
@ResponseBody @ResponseBody
public ReturnT<Map<String, Object>> triggerChartDate(Date startDate, Date endDate) { public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
ReturnT<Map<String, Object>> triggerChartDate = xxlJobService.triggerChartDate(startDate, endDate); ReturnT<Map<String, Object>> chartInfo = xxlJobService.chartInfo(startDate, endDate);
return triggerChartDate; return chartInfo;
} }
@RequestMapping("/toLogin") @RequestMapping("/toLogin")

@ -64,10 +64,10 @@ public class JobInfoController {
return xxlJobService.add(jobInfo); return xxlJobService.add(jobInfo);
} }
@RequestMapping("/reschedule") @RequestMapping("/update")
@ResponseBody @ResponseBody
public ReturnT<String> reschedule(XxlJobInfo jobInfo) { public ReturnT<String> update(XxlJobInfo jobInfo) {
return xxlJobService.reschedule(jobInfo); return xxlJobService.update(jobInfo);
} }
@RequestMapping("/remove") @RequestMapping("/remove")

@ -14,22 +14,81 @@ import java.util.Map;
*/ */
public interface XxlJobService { public interface XxlJobService {
/**
* page list
*
* @param start
* @param length
* @param jobGroup
* @param jobDesc
* @param executorHandler
* @param filterTime
* @return
*/
public Map<String, Object> pageList(int start, int length, int jobGroup, String jobDesc, String executorHandler, String filterTime); public Map<String, Object> pageList(int start, int length, int jobGroup, String jobDesc, String executorHandler, String filterTime);
/**
* add job
*
* @param jobInfo
* @return
*/
public ReturnT<String> add(XxlJobInfo jobInfo); public ReturnT<String> add(XxlJobInfo jobInfo);
public ReturnT<String> reschedule(XxlJobInfo jobInfo); /**
* update job
*
* @param jobInfo
* @return
*/
public ReturnT<String> update(XxlJobInfo jobInfo);
/**
* remove job
*
* @param id
* @return
*/
public ReturnT<String> remove(int id); public ReturnT<String> remove(int id);
/**
* pause job
*
* @param id
* @return
*/
public ReturnT<String> pause(int id); public ReturnT<String> pause(int id);
/**
* resume job
*
* @param id
* @return
*/
public ReturnT<String> resume(int id); public ReturnT<String> resume(int id);
/**
* trigger job
*
* @param id
* @return
*/
public ReturnT<String> triggerJob(int id); public ReturnT<String> triggerJob(int id);
/**
* dashboard info
*
* @return
*/
public Map<String,Object> dashboardInfo(); public Map<String,Object> dashboardInfo();
public ReturnT<Map<String,Object>> triggerChartDate(Date startDate, Date endDate); /**
* chart info
*
* @param startDate
* @param endDate
* @return
*/
public ReturnT<Map<String,Object>> chartInfo(Date startDate, Date endDate);
} }

@ -149,7 +149,7 @@ public class XxlJobServiceImpl implements XxlJobService {
} }
@Override @Override
public ReturnT<String> reschedule(XxlJobInfo jobInfo) { public ReturnT<String> update(XxlJobInfo jobInfo) {
// valid // valid
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) { if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
@ -323,12 +323,12 @@ public class XxlJobServiceImpl implements XxlJobService {
private static final String TRIGGER_CHART_DATA_CACHE = "trigger_chart_data_cache"; private static final String TRIGGER_CHART_DATA_CACHE = "trigger_chart_data_cache";
@Override @Override
public ReturnT<Map<String, Object>> triggerChartDate(Date startDate, Date endDate) { public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
// get cache // get cache
String cacheKey = TRIGGER_CHART_DATA_CACHE + "_" + startDate.getTime() + "_" + endDate.getTime(); String cacheKey = TRIGGER_CHART_DATA_CACHE + "_" + startDate.getTime() + "_" + endDate.getTime();
Map<String, Object> triggerChartDateCache = (Map<String, Object>) LocalCacheUtil.get(cacheKey); Map<String, Object> chartInfo = (Map<String, Object>) LocalCacheUtil.get(cacheKey);
if (triggerChartDateCache != null) { if (chartInfo != null) {
return new ReturnT<Map<String, Object>>(triggerChartDateCache); return new ReturnT<Map<String, Object>>(chartInfo);
} }
// process // process

@ -49,7 +49,7 @@ $(function () {
function freshChartDate(startDate, endDate) { function freshChartDate(startDate, endDate) {
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : base_url + '/triggerChartDate', url : base_url + '/chartInfo',
data : { data : {
'startDate':startDate.format('YYYY-MM-DD HH:mm:ss'), 'startDate':startDate.format('YYYY-MM-DD HH:mm:ss'),
'endDate':endDate.format('YYYY-MM-DD HH:mm:ss') 'endDate':endDate.format('YYYY-MM-DD HH:mm:ss')

@ -415,7 +415,7 @@ $(function() {
}, },
submitHandler : function(form) { submitHandler : function(form) {
// post // post
$.post(base_url + "/jobinfo/reschedule", $("#updateModal .form").serialize(), function(data, status) { $.post(base_url + "/jobinfo/update", $("#updateModal .form").serialize(), function(data, status) {
if (data.code == "200") { if (data.code == "200") {
$('#updateModal').modal('hide'); $('#updateModal').modal('hide');
layer.open({ layer.open({

Loading…
Cancel
Save