(1)getList方法改名,原先版本的是根据编译ID获取配置列表,这里改成两个方法,getListByCfgId和getListByCompileId
(2)调整后台返回给界面的提示信息 (3)修复几处functionId没有传递的bug (4)nis.properties调整url (5)白名单的审核提交 (6)注释掉CrudService的sendTomaat的方法实现,在后续代码没有用到该方法时删除该方法
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.configuration.AreaIpCfgDao;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
@@ -41,7 +47,25 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
if(areaIpCfgs!=null&&areaIpCfgs.size()>0){
|
||||
this.saveIpBatch(areaIpCfgs);
|
||||
}
|
||||
return ipCfgDao.insert(baseIpCfg);
|
||||
//调用服务接口获取compileId
|
||||
Integer compileId = 0;
|
||||
try {
|
||||
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
if(!StringUtil.isEmpty(compileIds)){
|
||||
compileId = compileIds.get(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
if(compileId!=0){
|
||||
baseIpCfg.setCompileId(compileId);
|
||||
return ipCfgDao.insert(baseIpCfg);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -66,6 +90,48 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
return ipCfgDao.update(baseIpCfg);
|
||||
}
|
||||
public void auditWhiteIp(String ids,IpPortCfg cfg) throws Exception{
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
List<BaseIpCfg> beans=this.getListByCfgId(IpPortCfg.getTablename(),ids);
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg bean:beans){
|
||||
bean.setTableName(IpPortCfg.getTablename());
|
||||
bean.setAuditorId(bean.getCurrentUser().getId());
|
||||
bean.setAuditTime(date);
|
||||
bean.setIsAudit(cfg.getIsAudit());
|
||||
bean.setIsValid(cfg.getIsValid());
|
||||
}
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
||||
logger.info("IP白名单配置下发响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单配置下发失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}else if(cfg.getIsAudit()==3){
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("IP白名单取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单取消配置失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditIpCfg(审核IP类配置)
|
||||
@@ -78,16 +144,16 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditIpCfg(int isAduit,List<BaseIpCfg> auditCfg,List<BaseIpCfg> areaCfg,List<BaseIpCfg> sendCfg) throws Exception{
|
||||
List<List<BaseCfg>> sendCfgs=new ArrayList<List<BaseCfg>>();
|
||||
for(BaseIpCfg c:sendCfg){
|
||||
List<BaseCfg> cArr=new ArrayList<>();
|
||||
cArr.add(c);
|
||||
sendCfgs.add(cArr);
|
||||
public void auditIpCfg(int isAduit,List<BaseIpCfg> auditCfg) throws Exception{
|
||||
List<BaseIpCfg> areaCfg=new ArrayList<>();
|
||||
for(BaseIpCfg c:auditCfg){
|
||||
if(c.getAreaCfg()!=null){
|
||||
areaCfg.addAll(c.getAreaCfg());
|
||||
}
|
||||
}
|
||||
if(Constants.AUDIT_NOT_YES==isAduit||
|
||||
Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
|
||||
if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
|
||||
if(sendToMaatConvertorBatch(isAduit,auditCfg)){
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
@@ -100,6 +166,25 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
this.auditBatch(auditCfg, IpCfgDao.class);
|
||||
}
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void deleteWhiteIp(String ids){
|
||||
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String idStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(idStr)){
|
||||
BaseIpCfg cfg=new BaseIpCfg();
|
||||
cfg.setCfgId(Long.parseLong(idStr));
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(date);
|
||||
cfg.setIsValid(Constants.VALID_DEL);
|
||||
ipCfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.deleteBatch(ipCfgs, IpCfgDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -155,7 +240,10 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
public List<AreaIpCfg> getAreaCfgByCompileId(int compileId){
|
||||
return areaIpCfgDao.getByCompileId(compileId);
|
||||
}
|
||||
public List<BaseIpCfg> getList(String tableName,String ids){
|
||||
return ipCfgDao.getList(tableName,ids);
|
||||
public List<BaseIpCfg> getListByComileId(String tableName,String ids){
|
||||
return ipCfgDao.getListByComileId(tableName,ids);
|
||||
}
|
||||
public List<BaseIpCfg> getListByCfgId(String tableName,String ids){
|
||||
return ipCfgDao.getListByCfgId(tableName,ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user