|
|
@ -43,11 +43,11 @@ public class JobGroupController { |
|
|
|
public Map<String, Object> pageList(HttpServletRequest request, |
|
|
|
public Map<String, Object> pageList(HttpServletRequest request, |
|
|
|
@RequestParam(required = false, defaultValue = "0") int start, |
|
|
|
@RequestParam(required = false, defaultValue = "0") int start, |
|
|
|
@RequestParam(required = false, defaultValue = "10") int length, |
|
|
|
@RequestParam(required = false, defaultValue = "10") int length, |
|
|
|
String appName, String title) { |
|
|
|
String appname, String title) { |
|
|
|
|
|
|
|
|
|
|
|
// 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 list_count = xxlJobGroupDao.pageListCount(start, length, appname, title); |
|
|
|
|
|
|
|
|
|
|
|
// package result
|
|
|
|
// package result
|
|
|
|
Map<String, Object> maps = new HashMap<String, Object>(); |
|
|
|
Map<String, Object> maps = new HashMap<String, Object>(); |
|
|
@ -62,10 +62,10 @@ public class JobGroupController { |
|
|
|
public ReturnT<String> save(XxlJobGroup xxlJobGroup){ |
|
|
|
public ReturnT<String> save(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<String>(500, (I18nUtil.getString("system_please_input")+"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<String>(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) { |
|
|
@ -91,10 +91,10 @@ public class JobGroupController { |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
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<String>(500, (I18nUtil.getString("system_please_input")+"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<String>(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) { |
|
|
@ -102,7 +102,7 @@ public class JobGroupController { |
|
|
|
} |
|
|
|
} |
|
|
|
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; |
|
|
|
String addressListStr = null; |
|
|
|
if (registryList!=null && !registryList.isEmpty()) { |
|
|
|
if (registryList!=null && !registryList.isEmpty()) { |
|
|
|
Collections.sort(registryList); |
|
|
|
Collections.sort(registryList); |
|
|
@ -130,14 +130,14 @@ public class JobGroupController { |
|
|
|
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; |
|
|
|
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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<String, List<String>>(); |
|
|
|
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) { |
|
|
|
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) { |
|
|
|
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) { |
|
|
|
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<String>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -145,11 +145,11 @@ public class JobGroupController { |
|
|
|
if (!registryList.contains(item.getRegistryValue())) { |
|
|
|
if (!registryList.contains(item.getRegistryValue())) { |
|
|
|
registryList.add(item.getRegistryValue()); |
|
|
|
registryList.add(item.getRegistryValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
appAddressMap.put(appName, registryList); |
|
|
|
appAddressMap.put(appname, registryList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return appAddressMap.get(appNameParam); |
|
|
|
return appAddressMap.get(appnameParam); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/remove") |
|
|
|
@RequestMapping("/remove") |
|
|
|