|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.xxl.job.admin.controller;
|
|
|
|
|
|
|
|
|
|
import com.xxl.job.admin.controller.interceptor.PermissionInterceptor;
|
|
|
|
|
import com.xxl.job.admin.core.exception.XxlJobException;
|
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobGroup;
|
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
|
|
|
@ -10,7 +11,6 @@ import com.xxl.job.admin.core.scheduler.ScheduleTypeEnum;
|
|
|
|
|
import com.xxl.job.admin.core.thread.JobScheduleHelper;
|
|
|
|
|
import com.xxl.job.admin.core.util.I18nUtil;
|
|
|
|
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
|
|
|
|
import com.xxl.job.admin.service.LoginService;
|
|
|
|
|
import com.xxl.job.admin.service.XxlJobService;
|
|
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
|
|
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
|
|
|
@ -56,7 +56,7 @@ public class JobInfoController {
|
|
|
|
|
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
|
|
|
|
|
|
|
|
|
|
// filter group
|
|
|
|
|
List<XxlJobGroup> jobGroupList = filterJobGroupByRole(request, jobGroupList_all);
|
|
|
|
|
List<XxlJobGroup> jobGroupList = PermissionInterceptor.filterJobGroupByRole(request, jobGroupList_all);
|
|
|
|
|
if (jobGroupList==null || jobGroupList.size()==0) {
|
|
|
|
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
|
|
|
|
}
|
|
|
|
@ -67,33 +67,6 @@ public class JobInfoController {
|
|
|
|
|
return "jobinfo/jobinfo.index";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<XxlJobGroup> filterJobGroupByRole(HttpServletRequest request, List<XxlJobGroup> jobGroupList_all){
|
|
|
|
|
List<XxlJobGroup> jobGroupList = new ArrayList<>();
|
|
|
|
|
if (jobGroupList_all!=null && jobGroupList_all.size()>0) {
|
|
|
|
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
|
|
|
|
if (loginUser.getRole() == 1) {
|
|
|
|
|
jobGroupList = jobGroupList_all;
|
|
|
|
|
} else {
|
|
|
|
|
List<String> groupIdStrs = new ArrayList<>();
|
|
|
|
|
if (loginUser.getPermission()!=null && loginUser.getPermission().trim().length()>0) {
|
|
|
|
|
groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(","));
|
|
|
|
|
}
|
|
|
|
|
for (XxlJobGroup groupItem:jobGroupList_all) {
|
|
|
|
|
if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) {
|
|
|
|
|
jobGroupList.add(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return jobGroupList;
|
|
|
|
|
}
|
|
|
|
|
public static void validPermission(HttpServletRequest request, int jobGroup) {
|
|
|
|
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
|
|
|
|
if (!loginUser.validPermission(jobGroup)) {
|
|
|
|
|
throw new RuntimeException(I18nUtil.getString("system_permission_limit") + "[username="+ loginUser.getUsername() +"]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/pageList")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,
|
|
|
|
@ -105,14 +78,16 @@ public class JobInfoController {
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/add")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ReturnT<String> add(XxlJobInfo jobInfo) {
|
|
|
|
|
return xxlJobService.add(jobInfo);
|
|
|
|
|
public ReturnT<String> add(HttpServletRequest request, XxlJobInfo jobInfo) {
|
|
|
|
|
XxlJobUser loginUser = PermissionInterceptor.getLoginUser(request);
|
|
|
|
|
return xxlJobService.add(jobInfo, loginUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
|
|
|
|
return xxlJobService.update(jobInfo);
|
|
|
|
|
public ReturnT<String> update(HttpServletRequest request, XxlJobInfo jobInfo) {
|
|
|
|
|
XxlJobUser loginUser = PermissionInterceptor.getLoginUser(request);
|
|
|
|
|
return xxlJobService.update(jobInfo, loginUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/remove")
|
|
|
|
@ -137,7 +112,7 @@ public class JobInfoController {
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ReturnT<String> triggerJob(HttpServletRequest request, int id, String executorParam, String addressList) {
|
|
|
|
|
// login user
|
|
|
|
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
|
|
|
|
XxlJobUser loginUser = PermissionInterceptor.getLoginUser(request);
|
|
|
|
|
// trigger
|
|
|
|
|
return xxlJobService.trigger(loginUser, id, executorParam, addressList);
|
|
|
|
|
}
|
|
|
|
|