|
|
|
@ -1,22 +1,30 @@ |
|
|
|
|
package com.xxl.job.admin.controller; |
|
|
|
|
|
|
|
|
|
import com.xxl.job.admin.core.exception.XxlJobException; |
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobGroup; |
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobInfo; |
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobUser; |
|
|
|
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum; |
|
|
|
|
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper; |
|
|
|
|
import com.xxl.job.admin.core.trigger.TriggerTypeEnum; |
|
|
|
|
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; |
|
|
|
|
import com.xxl.job.core.glue.GlueTypeEnum; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@ -34,15 +42,38 @@ public class JobInfoController { |
|
|
|
|
private XxlJobService xxlJobService; |
|
|
|
|
|
|
|
|
|
@RequestMapping |
|
|
|
|
public String index(Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) { |
|
|
|
|
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) { |
|
|
|
|
|
|
|
|
|
// 枚举-字典
|
|
|
|
|
model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表
|
|
|
|
|
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典
|
|
|
|
|
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
|
|
|
|
|
|
|
|
|
// 任务组
|
|
|
|
|
List<XxlJobGroup> jobGroupList = xxlJobGroupDao.findAll(); |
|
|
|
|
// 执行器列表
|
|
|
|
|
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll(); |
|
|
|
|
|
|
|
|
|
// filter group
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (jobGroupList==null || jobGroupList.size()==0) { |
|
|
|
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
model.addAttribute("JobGroupList", jobGroupList); |
|
|
|
|
model.addAttribute("jobGroup", jobGroup); |
|
|
|
|
|
|
|
|
|