分组配置管理GroupName改为可手动输入

This commit is contained in:
zhangwenqing
2019-06-14 17:12:41 +08:00
parent 3aebe7d905
commit d245ef7dc4
33 changed files with 2384 additions and 357 deletions

View File

@@ -69,6 +69,7 @@ public class CommonGroupManageService extends BaseService{
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdate(CommonGroupInfo entity) throws MaatConvertException{
entity.setIsValid(1);
entity.setGroupName(entity.getGroupName().toUpperCase());
if(entity.getGroupId()==null){ // 新增
Date createTime=new Date();
entity.setCreatorId(UserUtils.getUser().getId());
@@ -84,7 +85,7 @@ public class CommonGroupManageService extends BaseService{
}
entity.setServiceGroupId(serviceGroupId);
commonGroupManageDao.insert(entity);
this.updatePolicyGroupDict(entity.getGroupType()+"");
//this.updatePolicyGroupDict(entity.getGroupType()+"");
}else{ // 修改
Date editTime=new Date();
entity.setEditorId(UserUtils.getUser().getId());
@@ -139,21 +140,23 @@ public class CommonGroupManageService extends BaseService{
boolean update=false;
Integer udFlag = 0;
Integer size = 0;
if(groupType == 5) { // IP
if(groupType == Constants.IP_OBJ_GROUP_TYPE) { // IP
size = ipCommGroupCfgDao.getCfgInfoByGroupIds(info.getServiceGroupId().toString());
}else if(groupType == 7) { // URL
}else if(groupType == Constants.URL_OBJ_GROUP_TYPE) { // URL
size = urlCommGroupDao.getCfgInfoByGroupIds(info.getServiceGroupId().toString());
}else if(groupType == 8) { // Domain
}else if(groupType == Constants.DOMAIN_OBJ_GROUP_TYPE) { // Domain
size = domainCommGroupDao.getCfgInfoByGroupIds(info.getServiceGroupId().toString());
}else if(groupType == 9) { // ScriberId
}else if(groupType == Constants.SUBID_OBJ_GROUP_TYPE) { // ScriberId
size = scriberIdCommGroupDao.getCfgInfoByGroupIds(info.getServiceGroupId().toString());
}
if(size > 0 && info.getUdFlag().equals(0)) {
update=true;
udFlag = 1;
info.setUdFlag(udFlag);
}else if(size == 0 /*&& !info.getUdFlag().equals(2)*/){
update=true;
info.setUdFlag(udFlag);
}
if(update){
commonGroupManageDao.updateGroupStatus(info.getServiceGroupId().toString(), udFlag, groupType);
@@ -171,7 +174,7 @@ public class CommonGroupManageService extends BaseService{
* 更新字典缓存
* @return
*/
private void updatePolicyGroupDict(String groupTypes) {
/*private void updatePolicyGroupDict(String groupTypes) {
String dictKey = Constants.CACHE_IPGROUP_DICT;
if(groupTypes.contains(",")) {
String[] split = groupTypes.split(",");
@@ -204,7 +207,7 @@ public class CommonGroupManageService extends BaseService{
}
}
}*/
/**
* 校验执行删除操作后分组下域配置是否为空
@@ -237,13 +240,13 @@ public class CommonGroupManageService extends BaseService{
cfgIds += "," + cfgId;
}
Integer size = 0;
if(groupType == 5) { // IP
if(groupType == Constants.IP_OBJ_GROUP_TYPE) { // IP
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), IpCommCfg.getIndexTable());
}else if(groupType == 7) { // URL
}else if(groupType == Constants.URL_OBJ_GROUP_TYPE) { // URL
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), UrlCommCfg.getTablename());
}else if(groupType == 8) { // Domain
}else if(groupType == Constants.DOMAIN_OBJ_GROUP_TYPE) { // Domain
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), DomainCommCfg.getTablename());
}else if(groupType == 9) { // ScriberId
}else if(groupType == Constants.SUBID_OBJ_GROUP_TYPE) { // ScriberId
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), ScriberIdCommCfg.getTablename());
}
@@ -256,5 +259,38 @@ public class CommonGroupManageService extends BaseService{
}
return resultList;
}
/**
* 分组域配置新增或修改时调用获取service group id
* @param cfg
* @return
*/
public Integer getServiceGroupId(String groupName, Integer groupType) {
CommonGroupInfo entity = new CommonGroupInfo();
int serviceGroupId = 0;
entity.setGroupType(groupType);
entity.setGroupName(groupName);
CommonGroupInfo groupInfo = commonGroupManageDao.getGroupInfo(entity);
if(groupInfo == null) {
// 获取GroupId
List<Integer> groupIds= ConfigServiceUtil.getId(2,1);
if(groupIds.size()>0) {
serviceGroupId =groupIds.get(0).intValue();
}else {
throw new MaatConvertException("Get group id failed");
}
entity.setServiceGroupId(serviceGroupId);
Date createTime=new Date();
entity.setIsValid(1);
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
commonGroupManageDao.insert(entity);
}else {
serviceGroupId = groupInfo.getServiceGroupId();
}
return serviceGroupId;
}
}