Merge branch 'develop' of http://10.0.6.99/gwall/gwall.git into develop
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -19,8 +20,13 @@ import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
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.web.controller.BaseController;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.dao.configuration.StringCfgDao;
|
||||
|
||||
/**
|
||||
* 白名单
|
||||
@@ -165,7 +171,19 @@ public class WhiteListController extends BaseController{
|
||||
// @RequiresPermissions("whitelist:aduit")
|
||||
public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
ipCfgService.auditWhiteIp(ids, cfg);
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
List<BaseIpCfg> beans=ipCfgService.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());
|
||||
ipCfgService.auditWhiteIp(bean);
|
||||
}
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
@@ -177,7 +195,16 @@ public class WhiteListController extends BaseController{
|
||||
// @RequiresPermissions("whitelist:aduit")
|
||||
public String auditDomain(String ids,HttpUrlCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
stringCfgService.auditWhiteDomain(ids, cfg);
|
||||
List<BaseStringCfg> beans=stringCfgService.getListByCfgId(HttpUrlCfg.getTablename(),ids);
|
||||
Date date=new Date();
|
||||
for(BaseStringCfg bean:beans){
|
||||
bean.setTableName(IpPortCfg.getTablename());
|
||||
bean.setAuditorId(bean.getCurrentUser().getId());
|
||||
bean.setAuditTime(date);
|
||||
bean.setIsAudit(cfg.getIsAudit());
|
||||
bean.setIsValid(cfg.getIsValid());
|
||||
stringCfgService.auditWhiteDomain(cfg);
|
||||
}
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
|
||||
@@ -90,10 +90,42 @@ 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);
|
||||
public void auditWhiteIp(BaseIpCfg cfg) throws Exception{
|
||||
List<BaseIpCfg> beans=new ArrayList<>();
|
||||
beans.add(cfg);
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//待调整
|
||||
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void auditWhiteIp(String ids,IpPortCfg cfg) throws Exception{
|
||||
|
||||
List<BaseIpCfg> beans=this.getListByCfgId(IpPortCfg.getTablename(),ids);
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg bean:beans){
|
||||
@@ -105,6 +137,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//待调整
|
||||
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单下发配置参数:"+json);
|
||||
|
||||
@@ -89,6 +89,38 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
}
|
||||
return stringCfgDao.update(baseStringCfg);
|
||||
}
|
||||
public void auditWhiteDomain(BaseStringCfg cfg) throws Exception{
|
||||
List<BaseStringCfg> beans=new ArrayList<>();
|
||||
beans.add(cfg);
|
||||
this.auditBatch(beans, StringCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("文件样例下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void auditWhiteDomain(String ids,HttpUrlCfg cfg) throws Exception{
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
@@ -241,4 +273,18 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
// TODO Auto-generated method stub
|
||||
return stringCfgDao.getListByCompileId(tableName,ids);
|
||||
}
|
||||
/**
|
||||
* getListByCfgId(这里用一句话描述这个方法的作用)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param tablename
|
||||
* @param ids
|
||||
* @return
|
||||
*List<BaseStringCfg>
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public List<BaseStringCfg> getListByCfgId(String tableName, String ids) {
|
||||
// TODO Auto-generated method stub
|
||||
return stringCfgDao.getListByCfgId(tableName, ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user