Merge remote-tracking branch 'origin/fix-bug-202303' into fix-bug-202303
This commit is contained in:
+7
-9
@@ -8,10 +8,7 @@ import org.springframework.beans.propertyeditors.CustomDateEditor;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -45,8 +42,7 @@ public class IndexController {
|
|||||||
@RequestMapping("/chartInfo")
|
@RequestMapping("/chartInfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
|
public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
|
||||||
ReturnT<Map<String, Object>> chartInfo = xxlJobService.chartInfo(startDate, endDate);
|
return xxlJobService.chartInfo(startDate, endDate);
|
||||||
return chartInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/toLogin")
|
@RequestMapping("/toLogin")
|
||||||
@@ -58,15 +54,17 @@ public class IndexController {
|
|||||||
return "login";
|
return "login";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value="login", method=RequestMethod.POST)
|
// @RequestMapping(value="login", method=RequestMethod.POST)
|
||||||
|
@PostMapping("login")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PermissionLimit(limit=false)
|
@PermissionLimit(limit=false)
|
||||||
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
|
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
|
||||||
boolean ifRem = (ifRemember!=null && ifRemember.trim().length()>0 && "on".equals(ifRemember))?true:false;
|
boolean ifRem = ifRemember!=null && ifRemember.trim().length()>0 && "on".equals(ifRemember);
|
||||||
return loginService.login(request, response, userName, password, ifRem);
|
return loginService.login(request, response, userName, password, ifRem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value="logout", method=RequestMethod.POST)
|
// @RequestMapping(value="logout", method=RequestMethod.POST)
|
||||||
|
@PostMapping("logout")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PermissionLimit(limit=false)
|
@PermissionLimit(limit=false)
|
||||||
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response){
|
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response){
|
||||||
|
|||||||
+4
-4
@@ -42,15 +42,15 @@ public class JobApiController {
|
|||||||
|
|
||||||
// valid
|
// valid
|
||||||
if (!"POST".equalsIgnoreCase(request.getMethod())) {
|
if (!"POST".equalsIgnoreCase(request.getMethod())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support.");
|
return new ReturnT<>(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support.");
|
||||||
}
|
}
|
||||||
if (uri==null || uri.trim().length()==0) {
|
if (uri==null || uri.trim().length()==0) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty.");
|
return new ReturnT<>(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty.");
|
||||||
}
|
}
|
||||||
if (XxlJobAdminConfig.getAdminConfig().getAccessToken()!=null
|
if (XxlJobAdminConfig.getAdminConfig().getAccessToken()!=null
|
||||||
&& XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
|
&& XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
|
||||||
&& !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) {
|
&& !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "The access token is wrong.");
|
return new ReturnT<>(ReturnT.FAIL_CODE, "The access token is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// services mapping
|
// services mapping
|
||||||
@@ -64,7 +64,7 @@ public class JobApiController {
|
|||||||
RegistryParam registryParam = GsonTool.fromJson(data, RegistryParam.class);
|
RegistryParam registryParam = GsonTool.fromJson(data, RegistryParam.class);
|
||||||
return adminBiz.registryRemove(registryParam);
|
return adminBiz.registryRemove(registryParam);
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found.");
|
return new ReturnT<>(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -58,28 +58,28 @@ public class JobCodeController {
|
|||||||
public ReturnT<String> save(Model model, int id, String glueSource, String glueRemark) {
|
public ReturnT<String> save(Model model, int id, String glueSource, String glueRemark) {
|
||||||
// valid
|
// valid
|
||||||
if (glueRemark==null) {
|
if (glueRemark==null) {
|
||||||
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")) );
|
return new ReturnT<>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")) );
|
||||||
}
|
}
|
||||||
if (glueRemark.length()<4 || glueRemark.length()>100) {
|
if (glueRemark.length()<4 || glueRemark.length()>100) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_remark_limit"));
|
return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_remark_limit"));
|
||||||
}
|
}
|
||||||
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(id);
|
XxlJobInfo existsJobInfo = xxlJobInfoDao.loadById(id);
|
||||||
if (exists_jobInfo == null) {
|
if (existsJobInfo == null) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update new code
|
// update new code
|
||||||
exists_jobInfo.setGlueSource(glueSource);
|
existsJobInfo.setGlueSource(glueSource);
|
||||||
exists_jobInfo.setGlueRemark(glueRemark);
|
existsJobInfo.setGlueRemark(glueRemark);
|
||||||
exists_jobInfo.setGlueUpdatetime(new Date());
|
existsJobInfo.setGlueUpdatetime(new Date());
|
||||||
|
|
||||||
exists_jobInfo.setUpdateTime(new Date());
|
existsJobInfo.setUpdateTime(new Date());
|
||||||
xxlJobInfoDao.update(exists_jobInfo);
|
xxlJobInfoDao.update(existsJobInfo);
|
||||||
|
|
||||||
// log old code
|
// log old code
|
||||||
XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue();
|
XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue();
|
||||||
xxlJobLogGlue.setJobId(exists_jobInfo.getId());
|
xxlJobLogGlue.setJobId(existsJobInfo.getId());
|
||||||
xxlJobLogGlue.setGlueType(exists_jobInfo.getGlueType());
|
xxlJobLogGlue.setGlueType(existsJobInfo.getGlueType());
|
||||||
xxlJobLogGlue.setGlueSource(glueSource);
|
xxlJobLogGlue.setGlueSource(glueSource);
|
||||||
xxlJobLogGlue.setGlueRemark(glueRemark);
|
xxlJobLogGlue.setGlueRemark(glueRemark);
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public class JobCodeController {
|
|||||||
xxlJobLogGlueDao.save(xxlJobLogGlue);
|
xxlJobLogGlueDao.save(xxlJobLogGlue);
|
||||||
|
|
||||||
// remove code backup more than 30
|
// remove code backup more than 30
|
||||||
xxlJobLogGlueDao.removeOld(exists_jobInfo.getId(), 30);
|
xxlJobLogGlueDao.removeOld(existsJobInfo.getId(), 30);
|
||||||
|
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-24
@@ -33,6 +33,8 @@ public class JobGroupController {
|
|||||||
@Resource
|
@Resource
|
||||||
private XxlJobRegistryDao xxlJobRegistryDao;
|
private XxlJobRegistryDao xxlJobRegistryDao;
|
||||||
|
|
||||||
|
private String systemPleaseInput= "system_please_input";
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public String index(Model model) {
|
public String index(Model model) {
|
||||||
return "jobgroup/jobgroup.index";
|
return "jobgroup/jobgroup.index";
|
||||||
@@ -47,12 +49,12 @@ public class JobGroupController {
|
|||||||
|
|
||||||
// page query
|
// page query
|
||||||
List<XxlJobGroup> list = xxlJobGroupDao.pageList(start, length, appname, title);
|
List<XxlJobGroup> list = xxlJobGroupDao.pageList(start, length, appname, title);
|
||||||
int list_count = xxlJobGroupDao.pageListCount(start, length, appname, title);
|
int listCount = xxlJobGroupDao.pageListCount(start, length, appname, title);
|
||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<>();
|
||||||
maps.put("recordsTotal", list_count); // 总记录数
|
maps.put("recordsTotal", listCount); // 总记录数
|
||||||
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", listCount); // 过滤后的总记录数
|
||||||
maps.put("data", list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
@@ -63,22 +65,22 @@ public class JobGroupController {
|
|||||||
|
|
||||||
// valid
|
// valid
|
||||||
if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) {
|
if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) {
|
||||||
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input")+"AppName") );
|
return new ReturnT<>(500, (I18nUtil.getString(systemPleaseInput)+"AppName") );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) {
|
if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appname_length") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_appname_length") );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) {
|
if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) {
|
||||||
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")) );
|
return new ReturnT<>(500, (I18nUtil.getString(systemPleaseInput) + I18nUtil.getString("jobgroup_field_title")) );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getAddressType()!=0) {
|
if (xxlJobGroup.getAddressType()!=0) {
|
||||||
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
||||||
}
|
}
|
||||||
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
||||||
for (String item: addresss) {
|
for (String item: addresss) {
|
||||||
if (item==null || item.trim().length()==0) {
|
if (item==null || item.trim().length()==0) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,36 +94,36 @@ public class JobGroupController {
|
|||||||
public ReturnT<String> update(XxlJobGroup xxlJobGroup){
|
public ReturnT<String> update(XxlJobGroup xxlJobGroup){
|
||||||
// valid
|
// valid
|
||||||
if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) {
|
if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) {
|
||||||
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input")+"AppName") );
|
return new ReturnT<>(500, (I18nUtil.getString(systemPleaseInput)+"AppName") );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) {
|
if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appname_length") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_appname_length") );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) {
|
if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) {
|
||||||
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")) );
|
return new ReturnT<>(500, (I18nUtil.getString(systemPleaseInput) + I18nUtil.getString("jobgroup_field_title")) );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getAddressType() == 0) {
|
if (xxlJobGroup.getAddressType() == 0) {
|
||||||
// 0=自动注册
|
// 0=自动注册
|
||||||
List<String> registryList = findRegistryByAppName(xxlJobGroup.getAppname());
|
List<String> registryList = findRegistryByAppName(xxlJobGroup.getAppname());
|
||||||
String addressListStr = null;
|
StringBuilder addressListStr = new StringBuilder();
|
||||||
if (registryList!=null && !registryList.isEmpty()) {
|
if (registryList!=null && !registryList.isEmpty()) {
|
||||||
Collections.sort(registryList);
|
Collections.sort(registryList);
|
||||||
addressListStr = "";
|
addressListStr = new StringBuilder();
|
||||||
for (String item:registryList) {
|
for (String item:registryList) {
|
||||||
addressListStr += item + ",";
|
addressListStr.append(item).append(",");
|
||||||
}
|
}
|
||||||
addressListStr = addressListStr.substring(0, addressListStr.length()-1);
|
addressListStr = new StringBuilder(addressListStr.substring(0, addressListStr.length() - 1));
|
||||||
}
|
}
|
||||||
xxlJobGroup.setAddressList(addressListStr);
|
xxlJobGroup.setAddressList(addressListStr.toString());
|
||||||
} else {
|
} else {
|
||||||
// 1=手动录入
|
// 1=手动录入
|
||||||
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
||||||
}
|
}
|
||||||
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
||||||
for (String item: addresss) {
|
for (String item: addresss) {
|
||||||
if (item==null || item.trim().length()==0) {
|
if (item==null || item.trim().length()==0) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +133,7 @@ public class JobGroupController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<String> findRegistryByAppName(String appnameParam){
|
private List<String> findRegistryByAppName(String appnameParam){
|
||||||
HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> appAddressMap = new HashMap<>();
|
||||||
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
|
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
for (XxlJobRegistry item: list) {
|
for (XxlJobRegistry item: list) {
|
||||||
@@ -139,7 +141,7 @@ public class JobGroupController {
|
|||||||
String appname = item.getRegistryKey();
|
String appname = item.getRegistryKey();
|
||||||
List<String> registryList = appAddressMap.get(appname);
|
List<String> registryList = appAddressMap.get(appname);
|
||||||
if (registryList == null) {
|
if (registryList == null) {
|
||||||
registryList = new ArrayList<String>();
|
registryList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registryList.contains(item.getRegistryValue())) {
|
if (!registryList.contains(item.getRegistryValue())) {
|
||||||
@@ -159,12 +161,12 @@ public class JobGroupController {
|
|||||||
// valid
|
// valid
|
||||||
int count = xxlJobInfoDao.pageListCount(0, 10, id, -1, null, null, null);
|
int count = xxlJobInfoDao.pageListCount(0, 10, id, -1, null, null, null);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_0") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_del_limit_0") );
|
||||||
}
|
}
|
||||||
|
|
||||||
List<XxlJobGroup> allList = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> allList = xxlJobGroupDao.findAll();
|
||||||
if (allList.size() == 1) {
|
if (allList.size() == 1) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_1") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_del_limit_1") );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = xxlJobGroupDao.remove(id);
|
int ret = xxlJobGroupDao.remove(id);
|
||||||
@@ -175,7 +177,7 @@ public class JobGroupController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<XxlJobGroup> loadById(int id){
|
public ReturnT<XxlJobGroup> loadById(int id){
|
||||||
XxlJobGroup jobGroup = xxlJobGroupDao.load(id);
|
XxlJobGroup jobGroup = xxlJobGroupDao.load(id);
|
||||||
return jobGroup!=null?new ReturnT<XxlJobGroup>(jobGroup):new ReturnT<XxlJobGroup>(ReturnT.FAIL_CODE, null);
|
return jobGroup!=null?new ReturnT<>(jobGroup):new ReturnT<>(ReturnT.FAIL_CODE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -49,11 +49,11 @@ public class JobInfoController {
|
|||||||
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
||||||
|
|
||||||
// 执行器列表
|
// 执行器列表
|
||||||
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> jobGroupListAll = xxlJobGroupDao.findAll();
|
||||||
|
|
||||||
// filter group
|
// filter group
|
||||||
List<XxlJobGroup> jobGroupList = filterJobGroupByRole(request, jobGroupList_all);
|
List<XxlJobGroup> jobGroupList = filterJobGroupByRole(request, jobGroupListAll);
|
||||||
if (jobGroupList==null || jobGroupList.size()==0) {
|
if (!jobGroupList.isEmpty()) {
|
||||||
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,18 +63,18 @@ public class JobInfoController {
|
|||||||
return "jobinfo/jobinfo.index";
|
return "jobinfo/jobinfo.index";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<XxlJobGroup> filterJobGroupByRole(HttpServletRequest request, List<XxlJobGroup> jobGroupList_all){
|
public static List<XxlJobGroup> filterJobGroupByRole(HttpServletRequest request, List<XxlJobGroup> jobGroupListAll){
|
||||||
List<XxlJobGroup> jobGroupList = new ArrayList<>();
|
List<XxlJobGroup> jobGroupList = new ArrayList<>();
|
||||||
if (jobGroupList_all!=null && jobGroupList_all.size()>0) {
|
if (jobGroupListAll!=null && !jobGroupListAll.isEmpty()) {
|
||||||
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
||||||
if (loginUser.getRole() == 1) {
|
if (loginUser.getRole() == 1) {
|
||||||
jobGroupList = jobGroupList_all;
|
jobGroupList = jobGroupListAll;
|
||||||
} else {
|
} else {
|
||||||
List<String> groupIdStrs = new ArrayList<>();
|
List<String> groupIdStrs = new ArrayList<>();
|
||||||
if (loginUser.getPermission()!=null && loginUser.getPermission().trim().length()>0) {
|
if (loginUser.getPermission()!=null && loginUser.getPermission().trim().length()>0) {
|
||||||
groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(","));
|
groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(","));
|
||||||
}
|
}
|
||||||
for (XxlJobGroup groupItem:jobGroupList_all) {
|
for (XxlJobGroup groupItem:jobGroupListAll) {
|
||||||
if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) {
|
if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) {
|
||||||
jobGroupList.add(groupItem);
|
jobGroupList.add(groupItem);
|
||||||
}
|
}
|
||||||
@@ -158,9 +158,9 @@ public class JobInfoController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
return new ReturnT<List<String>>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid"));
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid"));
|
||||||
}
|
}
|
||||||
return new ReturnT<List<String>>(result);
|
return new ReturnT<>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -50,11 +50,11 @@ public class JobLogController {
|
|||||||
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) {
|
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) {
|
||||||
|
|
||||||
// 执行器列表
|
// 执行器列表
|
||||||
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> jobGroupListAll = xxlJobGroupDao.findAll();
|
||||||
|
|
||||||
// filter group
|
// filter group
|
||||||
List<XxlJobGroup> jobGroupList = JobInfoController.filterJobGroupByRole(request, jobGroupList_all);
|
List<XxlJobGroup> jobGroupList = JobInfoController.filterJobGroupByRole(request, jobGroupListAll);
|
||||||
if (jobGroupList==null || jobGroupList.size()==0) {
|
if (jobGroupList==null || jobGroupList.isEmpty()) {
|
||||||
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class JobLogController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<List<XxlJobInfo>> getJobsByGroup(int jobGroup){
|
public ReturnT<List<XxlJobInfo>> getJobsByGroup(int jobGroup){
|
||||||
List<XxlJobInfo> list = xxlJobInfoDao.getJobsByGroup(jobGroup);
|
List<XxlJobInfo> list = xxlJobInfoDao.getJobsByGroup(jobGroup);
|
||||||
return new ReturnT<List<XxlJobInfo>>(list);
|
return new ReturnT<>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/pageList")
|
@RequestMapping("/pageList")
|
||||||
@@ -106,12 +106,12 @@ public class JobLogController {
|
|||||||
|
|
||||||
// page query
|
// page query
|
||||||
List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
||||||
int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
int listCount = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<>();
|
||||||
maps.put("recordsTotal", list_count); // 总记录数
|
maps.put("recordsTotal", listCount); // 总记录数
|
||||||
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", listCount); // 过滤后的总记录数
|
||||||
maps.put("data", list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class JobLogController {
|
|||||||
public String logDetailPage(int id, Model model){
|
public String logDetailPage(int id, Model model){
|
||||||
|
|
||||||
// base check
|
// base check
|
||||||
ReturnT<String> logStatue = ReturnT.SUCCESS;
|
// ReturnT<String> logStatue = ReturnT.SUCCESS;
|
||||||
XxlJobLog jobLog = xxlJobLogDao.load(id);
|
XxlJobLog jobLog = xxlJobLogDao.load(id);
|
||||||
if (jobLog == null) {
|
if (jobLog == null) {
|
||||||
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
||||||
@@ -152,7 +152,7 @@ public class JobLogController {
|
|||||||
return logResult;
|
return logResult;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage());
|
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,10 +163,10 @@ public class JobLogController {
|
|||||||
XxlJobLog log = xxlJobLogDao.load(id);
|
XxlJobLog log = xxlJobLogDao.load(id);
|
||||||
XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId());
|
XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId());
|
||||||
if (jobInfo==null) {
|
if (jobInfo==null) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
||||||
}
|
}
|
||||||
if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) {
|
if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("joblog_kill_log_limit"));
|
return new ReturnT<>(500, I18nUtil.getString("joblog_kill_log_limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// request of kill
|
// request of kill
|
||||||
@@ -176,7 +176,7 @@ public class JobLogController {
|
|||||||
runResult = executorBiz.kill(new KillParam(jobInfo.getId()));
|
runResult = executorBiz.kill(new KillParam(jobInfo.getId()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
runResult = new ReturnT<String>(500, e.getMessage());
|
runResult = new ReturnT<>(500, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
|
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
|
||||||
@@ -184,9 +184,9 @@ public class JobLogController {
|
|||||||
log.setHandleMsg( I18nUtil.getString("joblog_kill_log_byman")+":" + (runResult.getMsg()!=null?runResult.getMsg():""));
|
log.setHandleMsg( I18nUtil.getString("joblog_kill_log_byman")+":" + (runResult.getMsg()!=null?runResult.getMsg():""));
|
||||||
log.setHandleTime(new Date());
|
log.setHandleTime(new Date());
|
||||||
xxlJobLogDao.updateHandleInfo(log);
|
xxlJobLogDao.updateHandleInfo(log);
|
||||||
return new ReturnT<String>(runResult.getMsg());
|
return new ReturnT<>(runResult.getMsg());
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(500, runResult.getMsg());
|
return new ReturnT<>(500, runResult.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,16 +215,16 @@ public class JobLogController {
|
|||||||
} else if (type == 9) {
|
} else if (type == 9) {
|
||||||
clearBeforeNum = 0; // 清理所有日志数据
|
clearBeforeNum = 0; // 清理所有日志数据
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid"));
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> logIds = null;
|
List<Long> logIds = null;
|
||||||
do {
|
do {
|
||||||
logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000);
|
logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000);
|
||||||
if (logIds!=null && logIds.size()>0) {
|
if (logIds!=null && !logIds.isEmpty()) {
|
||||||
xxlJobLogDao.clearLog(logIds);
|
xxlJobLogDao.clearLog(logIds);
|
||||||
}
|
}
|
||||||
} while (logIds!=null && logIds.size()>0);
|
} while (logIds!=null && !logIds.isEmpty());
|
||||||
|
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-14
@@ -33,6 +33,8 @@ public class UserController {
|
|||||||
private XxlJobUserDao xxlJobUserDao;
|
private XxlJobUserDao xxlJobUserDao;
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobGroupDao xxlJobGroupDao;
|
private XxlJobGroupDao xxlJobGroupDao;
|
||||||
|
private String systemLenghLimit ="system_lengh_limit";
|
||||||
|
private String fourTwenty ="[4-20]";
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
@PermissionLimit(adminuser = true)
|
@PermissionLimit(adminuser = true)
|
||||||
@@ -54,12 +56,12 @@ public class UserController {
|
|||||||
|
|
||||||
// page list
|
// page list
|
||||||
List<XxlJobUser> list = xxlJobUserDao.pageList(start, length, username, role);
|
List<XxlJobUser> list = xxlJobUserDao.pageList(start, length, username, role);
|
||||||
int list_count = xxlJobUserDao.pageListCount(start, length, username, role);
|
int listCount = xxlJobUserDao.pageListCount(start, length, username, role);
|
||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<>();
|
||||||
maps.put("recordsTotal", list_count); // 总记录数
|
maps.put("recordsTotal", listCount); // 总记录数
|
||||||
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", listCount); // 过滤后的总记录数
|
||||||
maps.put("data", list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
@@ -71,19 +73,19 @@ public class UserController {
|
|||||||
|
|
||||||
// valid username
|
// valid username
|
||||||
if (!StringUtils.hasText(xxlJobUser.getUsername())) {
|
if (!StringUtils.hasText(xxlJobUser.getUsername())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_username") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_username") );
|
||||||
}
|
}
|
||||||
xxlJobUser.setUsername(xxlJobUser.getUsername().trim());
|
xxlJobUser.setUsername(xxlJobUser.getUsername().trim());
|
||||||
if (!(xxlJobUser.getUsername().length()>=4 && xxlJobUser.getUsername().length()<=20)) {
|
if (!(xxlJobUser.getUsername().length()>=4 && xxlJobUser.getUsername().length()<=20)) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(systemLenghLimit)+fourTwenty );
|
||||||
}
|
}
|
||||||
// valid password
|
// valid password
|
||||||
if (!StringUtils.hasText(xxlJobUser.getPassword())) {
|
if (!StringUtils.hasText(xxlJobUser.getPassword())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_password") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_password") );
|
||||||
}
|
}
|
||||||
xxlJobUser.setPassword(xxlJobUser.getPassword().trim());
|
xxlJobUser.setPassword(xxlJobUser.getPassword().trim());
|
||||||
if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) {
|
if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(systemLenghLimit)+fourTwenty );
|
||||||
}
|
}
|
||||||
// md5 password
|
// md5 password
|
||||||
xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes()));
|
xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes()));
|
||||||
@@ -91,7 +93,7 @@ public class UserController {
|
|||||||
// check repeat
|
// check repeat
|
||||||
XxlJobUser existUser = xxlJobUserDao.loadByUserName(xxlJobUser.getUsername());
|
XxlJobUser existUser = xxlJobUserDao.loadByUserName(xxlJobUser.getUsername());
|
||||||
if (existUser != null) {
|
if (existUser != null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat") );
|
||||||
}
|
}
|
||||||
|
|
||||||
// write
|
// write
|
||||||
@@ -107,14 +109,14 @@ public class UserController {
|
|||||||
// avoid opt login seft
|
// avoid opt login seft
|
||||||
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
||||||
if (loginUser.getUsername().equals(xxlJobUser.getUsername())) {
|
if (loginUser.getUsername().equals(xxlJobUser.getUsername())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL.getCode(), I18nUtil.getString("user_update_loginuser_limit"));
|
return new ReturnT<>(ReturnT.FAIL.getCode(), I18nUtil.getString("user_update_loginuser_limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid password
|
// valid password
|
||||||
if (StringUtils.hasText(xxlJobUser.getPassword())) {
|
if (StringUtils.hasText(xxlJobUser.getPassword())) {
|
||||||
xxlJobUser.setPassword(xxlJobUser.getPassword().trim());
|
xxlJobUser.setPassword(xxlJobUser.getPassword().trim());
|
||||||
if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) {
|
if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(systemLenghLimit)+fourTwenty );
|
||||||
}
|
}
|
||||||
// md5 password
|
// md5 password
|
||||||
xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes()));
|
xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes()));
|
||||||
@@ -135,7 +137,7 @@ public class UserController {
|
|||||||
// avoid opt login seft
|
// avoid opt login seft
|
||||||
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
||||||
if (loginUser.getId() == id) {
|
if (loginUser.getId() == id) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL.getCode(), I18nUtil.getString("user_update_loginuser_limit"));
|
return new ReturnT<>(ReturnT.FAIL.getCode(), I18nUtil.getString("user_update_loginuser_limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
xxlJobUserDao.delete(id);
|
xxlJobUserDao.delete(id);
|
||||||
@@ -148,11 +150,11 @@ public class UserController {
|
|||||||
|
|
||||||
// valid password
|
// valid password
|
||||||
if (password==null || password.trim().length()==0){
|
if (password==null || password.trim().length()==0){
|
||||||
return new ReturnT<String>(ReturnT.FAIL.getCode(), "密码不可为空");
|
return new ReturnT<>(ReturnT.FAIL.getCode(), "密码不可为空");
|
||||||
}
|
}
|
||||||
password = password.trim();
|
password = password.trim();
|
||||||
if (!(password.length()>=4 && password.length()<=20)) {
|
if (!(password.length()>=4 && password.length()<=20)) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(systemLenghLimit)+fourTwenty );
|
||||||
}
|
}
|
||||||
|
|
||||||
// md5 password
|
// md5 password
|
||||||
|
|||||||
+4
-5
@@ -48,7 +48,7 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// email info
|
// email info
|
||||||
XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(Integer.valueOf(info.getJobGroup()));
|
XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(info.getJobGroup());
|
||||||
String personal = I18nUtil.getString("admin_name_full");
|
String personal = I18nUtil.getString("admin_name_full");
|
||||||
String title = I18nUtil.getString("jobconf_monitor");
|
String title = I18nUtil.getString("jobconf_monitor");
|
||||||
String content = MessageFormat.format(loadEmailJobAlarmTemplate(),
|
String content = MessageFormat.format(loadEmailJobAlarmTemplate(),
|
||||||
@@ -57,7 +57,7 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
info.getJobDesc(),
|
info.getJobDesc(),
|
||||||
alarmContent);
|
alarmContent);
|
||||||
|
|
||||||
Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(",")));
|
Set<String> emailSet = new HashSet<>(Arrays.asList(info.getAlarmEmail().split(",")));
|
||||||
for (String email: emailSet) {
|
for (String email: emailSet) {
|
||||||
|
|
||||||
// make mail
|
// make mail
|
||||||
@@ -89,7 +89,8 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static final String loadEmailJobAlarmTemplate(){
|
private static final String loadEmailJobAlarmTemplate(){
|
||||||
String mailBodyTemplate = "<h5>" + I18nUtil.getString("jobconf_monitor_detail") + ":</span>" +
|
|
||||||
|
return "<h5>" + I18nUtil.getString("jobconf_monitor_detail") + ":</span>" +
|
||||||
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
|
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
|
||||||
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
|
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
|
||||||
" <tr>\n" +
|
" <tr>\n" +
|
||||||
@@ -110,8 +111,6 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
" </tr>\n" +
|
" </tr>\n" +
|
||||||
" </tbody>\n" +
|
" </tbody>\n" +
|
||||||
"</table>";
|
"</table>";
|
||||||
|
|
||||||
return mailBodyTemplate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user