1、网站HTTP配置新增、修改功能提交;2、样例配置审核修改文件URL

This commit is contained in:
zhangwei
2018-05-25 13:25:21 +08:00
parent 5cab431e16
commit 5c839d31f6
19 changed files with 25252 additions and 21877 deletions

View File

@@ -12,13 +12,13 @@ public class AvFileSampleCfg extends BaseCfg<AvFileSampleCfg> {
@SerializedName("srcFile")
private String srcUrl;
@Expose
@SerializedName("sampleFile")
@SerializedName("dstFile")
private String sampleUrl;
@Expose
@SerializedName("srcFileMd5")
private String srcMd5;
@Expose
@SerializedName("sampleFileMd5")
@SerializedName("dstFileMd5")
private String sampleMd5;
@Expose
private Integer level;

View File

@@ -29,6 +29,18 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
private List<AvVoipIpCfg> voipIps; //Add表单使用
private AvVoipAccountCfg voipAccount;//Search使用
private AvVoipIpCfg voipIp;//Search使用
private IpPortCfg ipPort;
private HttpUrlCfg httpUrl;
private HttpReqHeadCfg httpReqHdr;
private HttpResHeadCfg httpResHdr;
private HttpBodyCfg httpReqBody;
private HttpBodyCfg httpResBody;
private List<IpPortCfg> ipPortList;
private List<HttpUrlCfg> httpUrlList;
private List<HttpReqHeadCfg> httpReqHdrList;
private List<HttpResHeadCfg> httpResHdrList;
private List<HttpBodyCfg> httpReqBodyList;
private List<HttpBodyCfg> httpResBodyList;
public AvVoipAccountCfg getVoipAccount() {
@@ -55,5 +67,77 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
public List<AvVoipIpCfg> getVoipIps() {
return voipIps;
}
public IpPortCfg getIpPort() {
return ipPort;
}
public void setIpPort(IpPortCfg ipPort) {
this.ipPort = ipPort;
}
public HttpUrlCfg getHttpUrl() {
return httpUrl;
}
public void setHttpUrl(HttpUrlCfg httpUrl) {
this.httpUrl = httpUrl;
}
public HttpReqHeadCfg getHttpReqHdr() {
return httpReqHdr;
}
public void setHttpReqHdr(HttpReqHeadCfg httpReqHdr) {
this.httpReqHdr = httpReqHdr;
}
public HttpResHeadCfg getHttpResHdr() {
return httpResHdr;
}
public void setHttpResHdr(HttpResHeadCfg httpResHdr) {
this.httpResHdr = httpResHdr;
}
public HttpBodyCfg getHttpReqBody() {
return httpReqBody;
}
public void setHttpReqBody(HttpBodyCfg httpReqBody) {
this.httpReqBody = httpReqBody;
}
public HttpBodyCfg getHttpResBody() {
return httpResBody;
}
public void setHttpResBody(HttpBodyCfg httpResBody) {
this.httpResBody = httpResBody;
}
public List<IpPortCfg> getIpPortList() {
return ipPortList;
}
public void setIpPortList(List<IpPortCfg> ipPortList) {
this.ipPortList = ipPortList;
}
public List<HttpUrlCfg> getHttpUrlList() {
return httpUrlList;
}
public void setHttpUrlList(List<HttpUrlCfg> httpUrlList) {
this.httpUrlList = httpUrlList;
}
public List<HttpReqHeadCfg> getHttpReqHdrList() {
return httpReqHdrList;
}
public void setHttpReqHdrList(List<HttpReqHeadCfg> httpReqHdrList) {
this.httpReqHdrList = httpReqHdrList;
}
public List<HttpResHeadCfg> getHttpResHdrList() {
return httpResHdrList;
}
public void setHttpResHdrList(List<HttpResHeadCfg> httpResHdrList) {
this.httpResHdrList = httpResHdrList;
}
public List<HttpBodyCfg> getHttpReqBodyList() {
return httpReqBodyList;
}
public void setHttpReqBodyList(List<HttpBodyCfg> httpReqBodyList) {
this.httpReqBodyList = httpReqBodyList;
}
public List<HttpBodyCfg> getHttpResBodyList() {
return httpResBodyList;
}
public void setHttpResBodyList(List<HttpBodyCfg> httpResBodyList) {
this.httpResBodyList = httpResBodyList;
}
}

View File

@@ -32,7 +32,7 @@ public class IpPortCfg extends BaseIpCfg {
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.protocolId = 0;
// this.protocolId = 0;
}
public void initDefaultValueImpl(){
initDefaultValue();
@@ -40,12 +40,12 @@ public class IpPortCfg extends BaseIpCfg {
/**
* 此表固定写0
*/
@Override
/*@Override
public void setProtocolId(Integer protocolId) {
// TODO Auto-generated method stub
super.setProtocolId(0);
}
/**
*//**
* tablename
* @return tablename
*/

View File

@@ -61,6 +61,7 @@ import com.nis.web.service.configuration.SslCfgService;
import com.nis.web.service.configuration.StringCfgService;
import com.nis.web.service.configuration.TunnelCfgService;
import com.nis.web.service.configuration.WebCfgService;
import com.nis.web.service.configuration.WebsiteCfgService;
import com.nis.web.service.specific.SpecificServiceCfgService;
import com.nis.web.service.specific.SpecificServiceHostCfgService;
import com.nis.web.service.systemService.ServiceConfigInfoService;
@@ -149,6 +150,8 @@ public class BaseController {
protected AvCfgService avCfgService;
@Autowired
protected AvContentCfgService avContentCfgService;
@Autowired
protected WebsiteCfgService websiteCfgService;
/**
* 管理基础路径
*/

View File

@@ -0,0 +1,91 @@
package com.nis.web.controller.configuration.ntc;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.nis.domain.Page;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.util.Constants;
import com.nis.web.controller.BaseController;
/**
* 白名单
* @author dell
*
*/
@Controller
@RequestMapping("${adminPath}/ntc/website/")
public class WebsiteController extends BaseController{
@RequestMapping(value = {"httpList"})
@RequiresPermissions(value={"website:http:config"})
public String httpList(Model model,@ModelAttribute("cfg")CfgIndexInfo cfg,HttpServletRequest request,HttpServletResponse response) {
Page<CfgIndexInfo> searchPage=new Page<CfgIndexInfo>(request,response,"a");
Page<CfgIndexInfo> page = websiteCfgService.getHttpList(searchPage, cfg);
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/website/httpList";
}
@RequestMapping(value = {"dnsList"})
@RequiresPermissions(value={"website:dns:config"})
public String dnsList(Model model,@ModelAttribute("cfg")CfgIndexInfo cfg,HttpServletRequest request,HttpServletResponse response) {
Page<CfgIndexInfo> searchPage=new Page<CfgIndexInfo>(request,response,"a");
Page<CfgIndexInfo> page = websiteCfgService.findPage(searchPage, cfg);
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/website/dnsList";
}
@RequestMapping(value = {"httpForm"})
@RequiresPermissions(value={"website:http:config"})
public String httpForm(Model model,String ids,CfgIndexInfo entity) {
if(StringUtils.isNotBlank(ids)){
entity = websiteCfgService.getHttpCfg(Long.parseLong(ids));
}else{
List<IpPortCfg> ipList=new ArrayList<IpPortCfg>();
ipList.add(new IpPortCfg());
entity.setIpPortList(ipList);
List<HttpUrlCfg> urlList=new ArrayList<HttpUrlCfg>();
urlList.add(new HttpUrlCfg());
entity.setHttpUrlList(urlList);
List<HttpReqHeadCfg> reqHdrList=new ArrayList<HttpReqHeadCfg>();
reqHdrList.add(new HttpReqHeadCfg());
entity.setHttpReqHdrList(reqHdrList);
List<HttpResHeadCfg> resHdrList=new ArrayList<HttpResHeadCfg>();
resHdrList.add(new HttpResHeadCfg());
entity.setHttpResHdrList(resHdrList);
List<HttpBodyCfg> reqBodyList=new ArrayList<HttpBodyCfg>();
reqBodyList.add(new HttpBodyCfg());
entity.setHttpReqBodyList(reqBodyList);
List<HttpBodyCfg> resBodyList=new ArrayList<HttpBodyCfg>();
resBodyList.add(new HttpBodyCfg());
entity.setHttpResBodyList(resBodyList);
}
initFormCondition(model,entity);
model.addAttribute("_cfg", entity);
return "/cfg/website/httpForm";
}
@RequestMapping(value = {"saveHttpCfg"})
@RequiresPermissions(value={"website:http:config"})
public String saveHttpCfg(Model model,HttpServletRequest request,HttpServletResponse response,String ids,CfgIndexInfo entity) {
websiteCfgService.saveHttpCfg(entity);
return "redirect:" + adminPath +"/ntc/website/httpList?functionId="+entity.getFunctionId();
}
}

View File

@@ -486,7 +486,13 @@
audit_time = #{auditTime,jdbcType=TIMESTAMP}
<if test="isValid != null" >
,is_valid = #{isValid,jdbcType=INTEGER}
</if>
</if>
<if test="srcUrl != null and srcUrl!=''" >
,src_url = #{srcUrl,jdbcType=VARCHAR}
</if>
<if test="sampleUrl != null and sampleUrl!=''" >
,sample_url = #{sampleUrl,jdbcType=VARCHAR}
</if>
where cfg_id = #{cfgId,jdbcType=BIGINT}
</update>

View File

@@ -0,0 +1,49 @@
package com.nis.web.dao.configuration;
import java.util.List;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
/**
* WEB相关配置数据处理类
* @author dell
*
*/
@MyBatisDao
public interface WebsiteCfgDao extends CrudDao<CfgIndexInfo>{
public CfgIndexInfo getCfgIndexInfo(Long id);
public List<CfgIndexInfo> getHttpList(CfgIndexInfo entity);
public List<IpPortCfg> getIpPortList(CfgIndexInfo entity);
public List<HttpUrlCfg> getHttpUrlList(CfgIndexInfo entity);
public List<HttpResHeadCfg> getHttpResHdrList(CfgIndexInfo entity);
public List<HttpBodyCfg> getHttpResBodyList(CfgIndexInfo entity);
public List<HttpReqHeadCfg> getHttpReqHdrList(CfgIndexInfo entity);
public List<HttpBodyCfg> getHttpReqBodyList(CfgIndexInfo entity);
public void saveCfgIndex(CfgIndexInfo entity);
public void saveHttpIpCfg(IpPortCfg entity);
public void saveHttpUrlCfg(HttpUrlCfg entity);
public void saveHttpReqHdrCfg(HttpReqHeadCfg entity);
public void saveHttpResHdrCfg(HttpResHeadCfg entity);
public void saveHttpBodyCfg(HttpBodyCfg entity);
public void deleteHttpIpCfg(CfgIndexInfo entity);
public void deleteHttpUrlCfg(CfgIndexInfo entity);
public void deleteHttpReqHdrCfg(CfgIndexInfo entity);
public void deleteHttpResHdrCfg(CfgIndexInfo entity);
public void deleteHttpBodyCfg(CfgIndexInfo entity);
public void updateCfgIndex(CfgIndexInfo entity);
public void updateHttpIpCfg(IpPortCfg entity);
public void updateHttpUrlCfg(HttpUrlCfg entity);
public void updateHttpReqHdrCfg(HttpReqHeadCfg entity);
public void updateHttpResHdrCfg(HttpResHeadCfg entity);
public void updateHttpBodyCfg(HttpBodyCfg entity);
}

View File

@@ -0,0 +1,772 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nis.web.dao.configuration.WebsiteCfgDao" >
<resultMap id="CfgIndexInfoMap" type="com.nis.domain.configuration.CfgIndexInfo" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="ipPortMap" type="com.nis.domain.configuration.IpPortCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="ip_pattern" property="ipPattern" jdbcType="INTEGER" />
<result column="dest_ip_address" property="destIpAddress" jdbcType="VARCHAR" />
<result column="src_ip_address" property="srcIpAddress" jdbcType="VARCHAR" />
<result column="dest_port" property="destPort" jdbcType="VARCHAR" />
<result column="src_port" property="srcPort" jdbcType="VARCHAR" />
<result column="port_pattern" property="portPattern" jdbcType="INTEGER" />
<result column="direction" property="direction" jdbcType="INTEGER" />
<result column="protocol" property="protocol" jdbcType="INTEGER" />
<result column="protocol_id" property="protocolId" jdbcType="INTEGER" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="stringCfgMap" type="com.nis.domain.configuration.BaseStringCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type " property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="complexCfgMap" type="com.nis.domain.configuration.ComplexkeywordCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="district" property="district" jdbcType="VARCHAR" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type " property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<sql id="ConfigIndex_Column" >
a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id
</sql>
<sql id="IpCfg_Column" >
a.cfg_id,a.cfg_desc,a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port
,a.protocol,a.protocol_id,a.direction,a.cfg_type,a.action,a.dest_port,a.dest_ip_address
,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id
,a.edit_time,a.auditor_id,a.audit_time,a.service_id,a.request_id,
a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable
,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<sql id="StrCfg_Column" >
a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,
a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id,
a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<sql id="ComplexCfg_Column" >
a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,a.district,
a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id,
a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<select id="getHttpList" resultMap="CfgIndexInfoMap" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
SELECT
<include refid="ConfigIndex_Column" />
<trim prefix="," prefixOverrides=",">
, s.name as creator_name,e.name as editor_name,u.name as auditor_name
,ri.request_title as requestName
</trim>
FROM cfg_index_info a
left join sys_user s on a.creator_id=s.id
left join sys_user e on a.editor_id=e.id
left join sys_user u on a.auditor_id=u.id
left join request_info ri on a.request_id=ri.id
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="cfgId != null">
AND a.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null and cfgDesc != ''">
AND a.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="action != null">
AND a.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null">
AND a.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND a.IS_VALID != -1
</if>
<if test="isAudit != null">
AND a.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName != ''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editorName != null and editorName != ''">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditorName != null and auditorName != ''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="serviceId != null">
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null">
AND a.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="compileId != null">
AND a.COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null">
AND a.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify != ''">
AND a.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute != ''">
AND a.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable != ''">
AND a.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''">
AND a.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
<if test="functionId != null">
AND a.function_id=#{functionId,jdbcType=INTEGER}
</if>
<if test="ipPort!=null">
AND a.compile_id in (select t.compile_id from ip_port_cfg t
<where>
and t.protocol_id=4
<if test="ipPort.srcIpAddress != null and ipPort.srcIpAddress != ''">
and t.src_ip_address =#{(ipPort.srcIpAddress,jdbcType=VARCHAR}
</if>
<if test="ipPort.srcPort != null and ipPort.srcPort != ''">
and t.src_port =#{ipPort.srcPort,jdbcType=VARCHAR}
</if>
<if test="ipPort.destIpAddress != null and ipPort.destIpAddress != ''">
and t.dest_ip_address =#{(ipPort.destIpAddress,jdbcType=VARCHAR}
</if>
<if test="ipPort.destPort != null and ipPort.destPort != ''">
and t.dest_port =#{ipPort.destPort,jdbcType=VARCHAR}
</if>
</where>
)
</if>
<if test="httpUrl!=null">
AND a.compile_id in (select f.compile_id from http_url_cfg f
<where>
<if test="httpUrl.cfgKeywords != null and httpUrl.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{httpUrl.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<if test="httpReqBody!=null">
AND a.compile_id in (select f.compile_id from http_body_cfg f
<where>
and cfg_type='http_req_body'
<if test="httpReqBody.cfgKeywords != null and httpReqBody.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{httpReqBody.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<if test="httpResBody!=null">
AND a.compile_id in (select f.compile_id from http_body_cfg f
<where>
and cfg_type='http_res_body'
<if test="httpResBody.cfgKeywords != null and httpResBody.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{httpResBody.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<if test="httpReqHdr!=null">
AND a.compile_id in (select f.compile_id from http_req_head_cfg f
<where>
<if test="httpReqHdr.cfgKeywords != null and httpReqHdr.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{httpReqHdr.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
<if test="httpReqHdr.district != null and httpReqHdr.district != ''">
and f.district like concat(concat('%',#{httpReqHdr.district,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<if test="httpResHdr!=null">
AND a.compile_id in (select f.compile_id from http_res_head_cfg f
<where>
<if test="httpResHdr.cfgKeywords != null and httpResHdr.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{httpResHdr.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
<if test="httpResHdr.district != null and httpResHdr.district != ''">
and f.district like concat(concat('%',#{httpResHdr.district,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.CFG_ID desc
</otherwise>
</choose>
</select>
<select id="getCfgIndexInfo" resultMap="CfgIndexInfoMap" parameterType="java.lang.Long">
SELECT
<include refid="ConfigIndex_Column" />
FROM cfg_index_info a where cfg_id=#{cfgId}
</select>
<select id="getIpPortList" resultMap="ipPortMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="IpCfg_Column" />
FROM ip_port_cfg a where compile_id=#{compileId} and is_valid=#{isValid} and is_audit=#{isAudit}
</select>
<select id="getHttpUrlList" resultMap="stringCfgMap">
SELECT
<include refid="StrCfg_Column" />
FROM http_url_cfg a where compile_id=#{compileId} and is_valid=#{isValid} and is_audit=#{isAudit}
</select>
<select id="getHttpReqBodyList" resultMap="stringCfgMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="StrCfg_Column" />
FROM http_body_cfg a where compile_id=#{compileId} and cfg_type='http_req_body' and is_valid=#{isValid} and is_audit=#{isAudit}
</select>
<select id="getHttpResBodyList" resultMap="stringCfgMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="StrCfg_Column" />
FROM http_body_cfg a where compile_id=#{compileId} and cfg_type='http_res_body' and is_valid=#{isValid} and is_audit=#{isAudit}
</select>
<select id="getHttpReqHdrList" resultMap="complexCfgMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="ComplexCfg_Column" />
FROM http_req_head_cfg a where compile_id=#{compileId} and is_valid=#{isValid} and is_audit=#{isAudit}
</select>
<select id="getHttpResHdrList" resultMap="complexCfgMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="ComplexCfg_Column" />
FROM http_res_head_cfg a where compile_id=#{compileId} and is_valid=#{isValid} and is_audit=#{isAudit}
</select>
<!-- insert cfgIndexInfox -->
<insert id="saveCfgIndex" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into cfg_index_info(
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER}
)
</insert>
<!-- insert ip_port_cfg表信息 -->
<insert id="saveHttpIpCfg" parameterType="com.nis.domain.configuration.IpPortCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into ip_port_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
ip_type,
src_ip_address,
ip_pattern,
port_pattern,
src_port,
protocol,
protocol_id,
direction,
dest_port,
dest_ip_address,
cfg_type,
cfg_region_code
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{ipType,jdbcType=INTEGER},
#{srcIpAddress,jdbcType=VARCHAR},
#{ipPattern,jdbcType=INTEGER},
#{portPattern,jdbcType=INTEGER},
#{srcPort,jdbcType=VARCHAR},
#{protocol,jdbcType=INTEGER},
#{protocolId,jdbcType=INTEGER},
#{direction,jdbcType=INTEGER},
#{destPort,jdbcType=VARCHAR},
#{destIpAddress,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER}
)
</insert>
<!-- insert http_req_hdr_cfg表信息 -->
<insert id="saveHttpReqHdrCfg" parameterType="com.nis.domain.configuration.HttpReqHeadCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into http_req_head_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
district,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{district,jdbcType=VARCHAR},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER}
)
</insert>
<!-- insert http_res_hdr_cfg表信息 -->
<insert id="saveHttpResHdrCfg" parameterType="com.nis.domain.configuration.HttpResHeadCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into http_res_head_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
district,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{district,jdbcType=VARCHAR},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER}
)
</insert>
<!-- insert http_body_cfg表信息 -->
<insert id="saveHttpBodyCfg" parameterType="com.nis.domain.configuration.HttpBodyCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into http_body_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER}
)
</insert>
<!-- insert http_url_cfg表信息 -->
<insert id="saveHttpUrlCfg" parameterType="com.nis.domain.configuration.HttpUrlCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into http_url_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER}
)
</insert>
<update id="updateCfgIndex" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
update cfg_index_info
<set >
<trim suffixOverrides=",">
<if test="cfgDesc != null and cfgDesc != ''" >
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
</if>
<if test="action != null" >
action = #{action,jdbcType=INTEGER},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="creatorId != null" >
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="createTime != null and createTime != ''" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
edit_time = #{editTime,jdbcType=TIMESTAMP},
<if test="serviceId != null" >
service_id = #{serviceId,jdbcType=INTEGER},
</if>
<if test="requestId != null" >
request_id = #{requestId,jdbcType=INTEGER},
</if>
<if test="isAreaEffective != null" >
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
</if>
<if test="classify != null and classify != ''" >
classify = #{classify,jdbcType=VARCHAR},
</if>
<if test="attribute != null and attribute != ''" >
attribute = #{attribute,jdbcType=VARCHAR},
</if>
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if>
<if test="functionId != null" >
function_id = #{functionId,jdbcType=INTEGER},
</if>
</trim>
</set>
where cfg_id = #{cfgId,jdbcType=BIGINT}
</update>
<!-- 删除http子配置 -->
<delete id="deleteHttpIpCfg" >
delete from ip_port_cfg where compile_id=#{compileId} and protocol_id=4 and function_id=#{functionId}
</delete>
<delete id="deleteHttpUrlCfg">
delete from http_url_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<delete id="deleteHttpReqHdrCfg">
delete from http_req_head_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<delete id="deleteHttpResHdrCfg">
delete from http_res_head_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<delete id="deleteHttpBodyCfg">
delete from http_body_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
</mapper>

View File

@@ -186,7 +186,7 @@ public class AvCfgService extends BaseService{
sampleMap.put("key",FileUtils.getPrefix(sampleFile.getName(), false));
sampleMap.put("fileName", sampleFile.getName());
sampleMap.put("checksum", entity.getSampleMd5());
ToMaatResult result2 = ConfigServiceUtil.postFileCfg(null, srcFile, JSONObject.fromObject(sampleMap));
ToMaatResult result2 = ConfigServiceUtil.postFileCfg(null, sampleFile, JSONObject.fromObject(sampleMap));
logger.info("音视频样例文件上传响应信息:"+result2);
//获取文件上传响应信息(新的文件访问路径)

View File

@@ -0,0 +1,209 @@
package com.nis.web.service.configuration;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import com.nis.domain.Page;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.web.dao.configuration.IpCfgDao;
import com.nis.web.dao.configuration.WebsiteCfgDao;
import com.nis.web.service.BaseService;
import com.nis.web.service.CrudService;
/**
* 网站相关配置事务类
* @author dell
*
*/
@Service
public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
@Autowired
protected WebsiteCfgDao websiteCfgDao;
public CfgIndexInfo getHttpCfg(Long cfgId){
CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId);
List<IpPortCfg> ipPortList = websiteCfgDao.getIpPortList(entity);
List<HttpUrlCfg> httpUrlList = websiteCfgDao.getHttpUrlList(entity);
List<HttpReqHeadCfg> httpReqHdrList = websiteCfgDao.getHttpReqHdrList(entity);
List<HttpResHeadCfg> httpResHdrList = websiteCfgDao.getHttpResHdrList(entity);
List<HttpBodyCfg> httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity);
List<HttpBodyCfg> httpResBodyList = websiteCfgDao.getHttpResBodyList(entity);
if(ipPortList.size()==0){
ipPortList.add(new IpPortCfg());
}
if(httpUrlList.size()==0){
httpUrlList.add(new HttpUrlCfg());
}
if(httpReqHdrList.size()==0){
httpReqHdrList.add(new HttpReqHeadCfg());
}
if(httpResHdrList.size()==0){
httpResHdrList.add(new HttpResHeadCfg());
}
if(httpReqBodyList.size()==0){
httpReqBodyList.add(new HttpBodyCfg());
}
if(httpResBodyList.size()==0){
httpResBodyList.add(new HttpBodyCfg());
}
entity.setIpPortList(ipPortList);
entity.setHttpReqBodyList(httpReqBodyList);
entity.setHttpReqHdrList(httpReqHdrList);
entity.setHttpResBodyList(httpResBodyList);
entity.setHttpResHdrList(httpResHdrList);
entity.setHttpUrlList(httpUrlList);
return entity;
}
public Page<CfgIndexInfo> getHttpList(Page<CfgIndexInfo> page, CfgIndexInfo entity){
// 生成数据权限过滤条件dsf为dataScopeFilter的简写在xml中使用 ${sqlMap.dsf}调用权限SQL
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
entity.setPage(page);
List<CfgIndexInfo> list = websiteCfgDao.getHttpList(entity);
page.setList(list);
return page;
}
public List<IpPortCfg> getHttpIpList(IpPortCfg entity){
return null;
}
public List<HttpUrlCfg> getHttpUrlList(HttpUrlCfg entity){
return null;
}
public List<HttpResHeadCfg> getHttpResHdrList(HttpResHeadCfg entity){
return null;
}
public List<HttpBodyCfg> getHttpResBodyList(HttpBodyCfg entity){
return null;
}
public List<HttpReqHeadCfg> getHttpReqHdrList(HttpReqHeadCfg entity){
return null;
}
public List<HttpBodyCfg> getHttpReqBodyList(HttpBodyCfg entity){
return null;
}
public void saveHttpCfg(CfgIndexInfo entity){
if(entity.getCfgId()==null){
Integer compileId = 0;
try {
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
if(idList!=null && idList.size()>0){
compileId = idList.get(0);
}
entity.setCompileId(compileId);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
websiteCfgDao.saveCfgIndex(entity);
if(entity.getIpPortList()!=null){
for(IpPortCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpIpCfg(cfg);
}
}
if(entity.getHttpUrlList()!=null){
for(HttpUrlCfg cfg:entity.getHttpUrlList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpUrlCfg(cfg);
}
}
if(entity.getHttpReqHdrList()!=null){
for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpReqHdrCfg(cfg);
}
}
if(entity.getHttpResHdrList()!=null){
for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpResHdrCfg(cfg);
}
}
if(entity.getHttpReqBodyList()!=null){
for(HttpBodyCfg cfg:entity.getHttpReqBodyList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpBodyCfg(cfg);
}
}
if(entity.getHttpResBodyList()!=null){
for(HttpBodyCfg cfg:entity.getHttpResBodyList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpBodyCfg(cfg);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
}else{
websiteCfgDao.updateCfgIndex(entity);
// entity = websiteCfgDao.getCfgIndexInfo(entity.getCfgId());
//无效子配置后,再新增子配置
websiteCfgDao.deleteHttpIpCfg(entity);
websiteCfgDao.deleteHttpUrlCfg(entity);
websiteCfgDao.deleteHttpReqHdrCfg(entity);
websiteCfgDao.deleteHttpResHdrCfg(entity);
websiteCfgDao.deleteHttpBodyCfg(entity);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
if(entity.getIpPortList()!=null){
for(IpPortCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpIpCfg(cfg);
}
}
if(entity.getHttpUrlList()!=null){
for(HttpUrlCfg cfg:entity.getHttpUrlList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpUrlCfg(cfg);
}
}
if(entity.getHttpReqHdrList()!=null){
for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpReqHdrCfg(cfg);
}
}
if(entity.getHttpResHdrList()!=null){
for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpResHdrCfg(cfg);
}
}
if(entity.getHttpReqBodyList()!=null){
for(HttpBodyCfg cfg:entity.getHttpReqBodyList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpBodyCfg(cfg);
}
}
if(entity.getHttpResBodyList()!=null){
for(HttpBodyCfg cfg:entity.getHttpResBodyList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveHttpBodyCfg(cfg);
}
}
}
}
}