Merge branch 'develop' of http://10.0.6.99/gwall/gwall.git into develop
This commit is contained in:
@@ -65,6 +65,25 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
|
||||
@Expose
|
||||
@SerializedName("protocolId")
|
||||
protected Integer protocolId ;
|
||||
/**
|
||||
* 限速比例
|
||||
*/
|
||||
protected Integer ratelimit ;
|
||||
|
||||
/**
|
||||
* ratelimit
|
||||
* @return ratelimit
|
||||
*/
|
||||
|
||||
public Integer getRatelimit() {
|
||||
return ratelimit;
|
||||
}
|
||||
/**
|
||||
* @param ratelimit the ratelimit to set
|
||||
*/
|
||||
public void setRatelimit(Integer ratelimit) {
|
||||
this.ratelimit = ratelimit;
|
||||
}
|
||||
/**
|
||||
* ipType
|
||||
* @return ipType
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
|
||||
private static final long serialVersionUID = -1133644323636425766L;
|
||||
|
||||
private Integer specServiceId; //spec_service_id 协议ID int N 主键,初始化
|
||||
//private Integer specServiceCode; //协议编码 int N 暂定,以后可扩展 1000:微信 , 1001:QQ
|
||||
private Integer specServiceCode; //协议编码 int N 暂定,以后可扩展 1000:微信 , 1001:QQ
|
||||
private String specServiceName; //spec_service_name 协议名称 varchar(64) N
|
||||
private String specServiceDesc; //spec_service_desc 协议描述 varchar2(64) N
|
||||
private Integer isValid; //is_valid 有效标志 int N 1-有效 0-无效
|
||||
@@ -36,6 +36,12 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
|
||||
public void setSpecServiceId(Integer specServiceId) {
|
||||
this.specServiceId = specServiceId;
|
||||
}
|
||||
public Integer getSpecServiceCode() {
|
||||
return specServiceCode;
|
||||
}
|
||||
public void setSpecServiceCode(Integer specServiceCode) {
|
||||
this.specServiceCode = specServiceCode;
|
||||
}
|
||||
public String getSpecServiceName() {
|
||||
return specServiceName;
|
||||
}
|
||||
|
||||
@@ -26,26 +26,21 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
|
||||
@Expose
|
||||
private Integer ipType; //ip地址类型 ipV4=4 ipV6=6
|
||||
@Expose
|
||||
private String srcIp; //src_ip 源IP地址 varchar(64) N 缺省0.0.0.0值表示任意
|
||||
@Expose
|
||||
private String srcIpMask; //src_ip_mask 源地址掩码 varchar(64) N IPV4:255.255.255.255表示无掩码,即精确IP匹配,0.0.0.0值表示任意;
|
||||
//IPV6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF表示无掩码,::(两个半角冒号)表示任意。非0掩码值必须是2的指数幂,下同。
|
||||
@Expose
|
||||
private String srcPort; //src_port 源端口 varchar(6) N 0表示任意值
|
||||
@Expose
|
||||
private String srcPortMask; //src_port_mask 源端口掩码 varchar(6) N 65535表示无掩码,即精确端口匹配,0表示任意
|
||||
@Expose
|
||||
private String dstIp; //dst_ip 目的IP地址 varchar(64) N 缺省0.0.0.0值表示任意
|
||||
@Expose
|
||||
private String dstIpMask; //dst_ip_mask 目的地址掩码 varchar(64) N 同源ip地址掩码
|
||||
@Expose
|
||||
private String dstPort; //dst_port 目的端口 varchar(6) N 目的端口,0表示任意值
|
||||
@Expose
|
||||
private String dstPortMask; //dst_port_mask 目的端口掩码 varchar(6) N 同源端口掩码
|
||||
@Expose
|
||||
private Integer direction;; //direction 方向 int N 0双向,1单向,默认缺省为双向。
|
||||
@Expose
|
||||
private Integer protocol; //protocol 协议 int N 6表示tcp,17表示udp,0表示任意
|
||||
@Expose
|
||||
private Integer ipPattern; //ip格式
|
||||
@Expose
|
||||
private String srcIpAddress; //源(客户端)IP地址
|
||||
@Expose
|
||||
private String destIpAddress; //目的(服务器)IP地址
|
||||
@Expose
|
||||
private Integer portPattern; //端口格式
|
||||
@Expose
|
||||
private String srcPort; //源(客户端)端口
|
||||
@Expose
|
||||
private String destPort;//目的(服务器)端口
|
||||
|
||||
private Integer isValid; //is_valid 有效标识 int N 0无效,1有效
|
||||
private Integer isAudit; //is_audit 是否审核 int N 0未审核,1审核通过,2审核未通过,3取消审核通过(即删除)
|
||||
@@ -90,19 +85,13 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
|
||||
this.ipType = ipType;
|
||||
}
|
||||
@ExcelField(title="client_ip",align=2,sort=30,fieldType=String.class)
|
||||
public String getSrcIp() {
|
||||
return srcIp;
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
}
|
||||
public void setSrcIp(String srcIp) {
|
||||
this.srcIp = srcIp;
|
||||
}
|
||||
@ExcelField(title="client_address_mask",align=2,sort=40,fieldType=String.class)
|
||||
public String getSrcIpMask() {
|
||||
return srcIpMask;
|
||||
}
|
||||
public void setSrcIpMask(String srcIpMask) {
|
||||
this.srcIpMask = srcIpMask;
|
||||
public void setSrcIpAddress(String srcIpAddress) {
|
||||
this.srcIpAddress = srcIpAddress;
|
||||
}
|
||||
|
||||
@ExcelField(title="client_port",align=2,sort=50,fieldType=String.class)
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
@@ -110,40 +99,34 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
|
||||
public void setSrcPort(String srcPort) {
|
||||
this.srcPort = srcPort;
|
||||
}
|
||||
@ExcelField(title="client_port_mask",align=2,sort=60,fieldType=String.class)
|
||||
public String getSrcPortMask() {
|
||||
return srcPortMask;
|
||||
}
|
||||
public void setSrcPortMask(String srcPortMask) {
|
||||
this.srcPortMask = srcPortMask;
|
||||
}
|
||||
|
||||
@ExcelField(title="server_ip",align=2,sort=70,fieldType=String.class)
|
||||
public String getDstIp() {
|
||||
return dstIp;
|
||||
public String getDestIpAddress() {
|
||||
return destIpAddress;
|
||||
}
|
||||
public void setDstIp(String dstIp) {
|
||||
this.dstIp = dstIp;
|
||||
}
|
||||
@ExcelField(title="server_address_mask",align=2,sort=80,fieldType=String.class)
|
||||
public String getDstIpMask() {
|
||||
return dstIpMask;
|
||||
}
|
||||
public void setDstIpMask(String dstIpMask) {
|
||||
this.dstIpMask = dstIpMask;
|
||||
public void setDestIpAddress(String destIpAddress) {
|
||||
this.destIpAddress = destIpAddress;
|
||||
}
|
||||
@ExcelField(title="server_port",align=2,sort=90,fieldType=String.class)
|
||||
public String getDstPort() {
|
||||
return dstPort;
|
||||
public String getDestPort() {
|
||||
return destPort;
|
||||
}
|
||||
public void setDstPort(String dstPort) {
|
||||
this.dstPort = dstPort;
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
@ExcelField(title="server_port_mask",align=2,sort=100,fieldType=String.class)
|
||||
public String getDstPortMask() {
|
||||
return dstPortMask;
|
||||
@ExcelField(title="ip_pattern",align=2,sort=21,fieldType=Integer.class)
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
}
|
||||
public void setDstPortMask(String dstPortMask) {
|
||||
this.dstPortMask = dstPortMask;
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
}
|
||||
@ExcelField(title="port_pattern",align=2,sort=40,fieldType=Integer.class)
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
}
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
}
|
||||
@ExcelField(title="direction",align=2,sort=110)
|
||||
public Integer getDirection() {
|
||||
@@ -209,9 +192,6 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
|
||||
public void setAuditTime(Date auditTime) {
|
||||
this.auditTime = auditTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Date getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.nis.web.controller.configuration.proxy;
|
||||
|
||||
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 org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
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.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* IP相关配置控制类
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/proxy/intercept")
|
||||
public class InterceptController extends BaseController{
|
||||
@RequestMapping(value = {"/ip/list"})
|
||||
@RequiresPermissions(value={"intercept:ip:config","intercept:ip:audit"},logical=Logical.OR)
|
||||
public String ipList(Model model,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) {
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
Page<BaseIpCfg> searchPage=new Page<BaseIpCfg>(request,response,"r");
|
||||
Page<BaseIpCfg> page = ipCfgService.findPage(searchPage, cfg);
|
||||
model.addAttribute("page", page);
|
||||
initPageCondition(model,cfg);
|
||||
return "/cfg/proxy/ipList";
|
||||
}
|
||||
@RequestMapping(value = {"/ip/form"})
|
||||
@RequiresPermissions(value={"intercept:ip:config"})
|
||||
public String ipForm(Model model,String ids,BaseIpCfg entity) {
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
entity = ipCfgService.getIpCfgById(IpPortCfg.getTablename(),Long.parseLong(ids));
|
||||
}
|
||||
if(entity.getCfgId()!=null){
|
||||
List<BaseIpCfg> areaCfg=ipCfgService.getListByComileId(AreaIpCfg.getTablename(), String.valueOf(entity.getCompileId()));
|
||||
model.addAttribute("areaCfgs", areaCfg);
|
||||
model.addAttribute("_cfg", entity);
|
||||
initUpdateFormCondition(model,entity);
|
||||
}else{
|
||||
IpPortCfg cfg=new IpPortCfg();
|
||||
cfg.initDefaultValueImpl();
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
cfg.setProtocolId(entity.getProtocolId());
|
||||
model.addAttribute("_cfg", cfg);
|
||||
initFormCondition(model,entity);
|
||||
}
|
||||
|
||||
return "/cfg/proxy/ipForm";
|
||||
}
|
||||
@RequestMapping(value = {"/ip/saveOrUpdate"})
|
||||
public String saveOrUpdateIp(RedirectAttributes model, IpPortCfg cfg) {
|
||||
Date date=new Date();
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
logger.info("saveOrUpdateIp loaded");
|
||||
try{
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
if(cfg.getCfgId()==null){//新增
|
||||
cfg.setCreatorId(cfg.getCurrentUser().getId());
|
||||
cfg.setCreateTime(date);
|
||||
ipCfgService.addIpCfg(cfg);
|
||||
}else{//修改
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(new Date());
|
||||
ipCfgService.updateIpCfg(cfg);
|
||||
}
|
||||
addMessage(model,"save_success");
|
||||
}catch(Exception e){
|
||||
logger.error("保存失败",e);
|
||||
addMessage(model,"save_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
@RequestMapping(value = {"/ip/delete"})
|
||||
@RequiresPermissions("iplist:config")
|
||||
public String deleteIp(String ids,String compileIds,Integer functionId,RedirectAttributes model) {
|
||||
try{
|
||||
ipCfgService.deleteIp(ids,compileIds,functionId.intValue());
|
||||
addMessage(model,"delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error("删除失败", e);
|
||||
addMessage(model,"delete_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+functionId;
|
||||
}
|
||||
@RequestMapping(value = {"/ip/audit"})
|
||||
// @RequiresPermissions("intercept:ip:audit")
|
||||
public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
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.audit(bean);
|
||||
}
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(MaatConvertException e){
|
||||
logger.error("审核失败", e);
|
||||
addMessage(redirectAttributes, e.getMessage());
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
addMessage(redirectAttributes, "audit_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
}
|
||||
@@ -147,9 +147,9 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
@RequiresPermissions(value= {"specific:service:add","specific:service:edit"},logical=Logical.OR)
|
||||
@RequestMapping(value="saveOrUpdate")
|
||||
public String saveOrUpdate(SpecificServiceCfg specificServiceCfg, Model model,
|
||||
RedirectAttributes redirectAttributes,Integer oldId) {
|
||||
RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
specificServiceCfgService.saveOrUpdate(specificServiceCfg,oldId);
|
||||
specificServiceCfgService.saveOrUpdate(specificServiceCfg);
|
||||
addMessage(redirectAttributes, "save_success");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -181,14 +181,16 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
|
||||
/**
|
||||
* 父节点选择树形结构
|
||||
* @param extId
|
||||
* @param extId排除节点id
|
||||
* @param isShowHide
|
||||
* @param isLeafShow:叶子节点是否显示
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "treeData")
|
||||
public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide, HttpServletResponse response){
|
||||
public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide,
|
||||
@RequestParam(required=false)boolean isLeafShow,HttpServletResponse response){
|
||||
List<Map<String, Object>> mapList = Lists.newArrayList();
|
||||
Map<String, Object> map2 = Maps.newHashMap();
|
||||
map2.put("id", 0);
|
||||
@@ -200,7 +202,8 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
for (int i=0; i<list.size(); i++){
|
||||
SpecificServiceCfg specificServiceCfg = list.get(i);
|
||||
if(StringUtils.isBlank(extId)||(extId!=null&&!extId.equals(specificServiceCfg.getSpecServiceId().toString()))){
|
||||
if(specificServiceCfg.getIsValid().equals(0)||specificServiceCfg.getIsLeaf().equals(1)){
|
||||
if(specificServiceCfg.getIsValid().equals(0)||
|
||||
(!isLeafShow && specificServiceCfg.getIsLeaf().equals(1))){
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<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="ratelimit" property="ratelimit" jdbcType="INTEGER" />
|
||||
|
||||
|
||||
</resultMap>
|
||||
@@ -48,7 +49,7 @@
|
||||
DIRECTION,PROTOCOL,PROTOCOL_ID,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
|
||||
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,RATELIMIT
|
||||
</sql>
|
||||
<sql id="BaseIpCfg_Column_List_with_id_alias" >
|
||||
<choose>
|
||||
@@ -58,7 +59,7 @@
|
||||
${page.alias}.DIRECTION as direction,${page.alias}.PROTOCOL as protocol,${page.alias}.PROTOCOL_ID as protocolId,${page.alias}.ACTION as action,${page.alias}.IS_VALID as isValid,${page.alias}.IS_AUDIT as isAudit,
|
||||
${page.alias}.CREATOR_ID as creatorId,${page.alias}.CREATE_TIME AS createTime,${page.alias}.EDITOR_ID as editorId,${page.alias}.EDIT_TIME AS editTime,${page.alias}.AUDITOR_ID as auditorId,${page.alias}.AUDIT_TIME AS auditTime,
|
||||
${page.alias}.SERVICE_ID as serviceId,${page.alias}.REQUEST_ID AS requestId,${page.alias}.COMPILE_ID AS compileId,${page.alias}.IS_AREA_EFFECTIVE as isAreaEffective,${page.alias}.classify,
|
||||
${page.alias}.ATTRIBUTE AS attribute,${page.alias}.LABLE AS lable,${page.alias}.AREA_EFFECTIVE_IDS AS areaEffectiveIds,${page.alias}.FUNCTION_ID AS functionId
|
||||
${page.alias}.ATTRIBUTE AS attribute,${page.alias}.LABLE AS lable,${page.alias}.AREA_EFFECTIVE_IDS AS areaEffectiveIds,${page.alias}.FUNCTION_ID AS functionId,${page.alias}.RATELIMIT AS ratelimit
|
||||
</when>
|
||||
<otherwise>
|
||||
r.CFG_ID as cfgId, r.CFG_DESC as cfgDesc,r.CFG_REGION_CODE as cfgRegionCode,r.CFG_TYPE as cfgType, r.IP_TYPE as ipType,
|
||||
@@ -66,7 +67,7 @@
|
||||
r.DIRECTION as direction,r.PROTOCOL as protocol,r.PROTOCOL_ID as protocolId,r.ACTION as action,r.IS_VALID as isValid,r.IS_AUDIT as isAudit,
|
||||
r.CREATOR_ID as creatorId,r.CREATE_TIME AS createTime,r.EDITOR_ID as editorId,r.EDIT_TIME AS editTime,r.AUDITOR_ID as auditorId,r.AUDIT_TIME AS auditTime,
|
||||
r.SERVICE_ID as serviceId,r.REQUEST_ID AS requestId,r.COMPILE_ID AS compileId,r.IS_AREA_EFFECTIVE as isAreaEffective,r.classify,
|
||||
r.ATTRIBUTE AS attribute,r.LABLE AS lable,r.AREA_EFFECTIVE_IDS AS areaEffectiveIds,r.FUNCTION_ID as functionId
|
||||
r.ATTRIBUTE AS attribute,r.LABLE AS lable,r.AREA_EFFECTIVE_IDS AS areaEffectiveIds,r.FUNCTION_ID as functionId,r.RATELIMIT AS ratelimit
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
@@ -80,7 +81,7 @@
|
||||
AUDITOR_ID,AUDIT_TIME,SERVICE_ID,
|
||||
REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,
|
||||
CLASSIFY,ATTRIBUTE,LABLE,
|
||||
AREA_EFFECTIVE_IDS,FUNCTION_ID
|
||||
AREA_EFFECTIVE_IDS,FUNCTION_ID,RATELIMIT
|
||||
</sql>
|
||||
<sql id="BaseIpCfg_Value_List" >
|
||||
#{cfgDesc,jdbcType=VARCHAR},#{cfgRegionCode,jdbcType=INTEGER},#{cfgType,jdbcType=VARCHAR},
|
||||
@@ -92,7 +93,7 @@
|
||||
#{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}
|
||||
#{areaEffectiveIds,jdbcType=VARCHAR}, #{functionId,jdbcType=INTEGER}, #{ratelimit,jdbcType=INTEGER}
|
||||
</sql>
|
||||
<select id="getById" resultMap="BaseIpMap" parameterType="java.lang.Long" >
|
||||
SELECT
|
||||
@@ -259,6 +260,9 @@
|
||||
<if test="functionId != null">
|
||||
AND ${page.alias}.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="ratelimit != null">
|
||||
AND ${page.alias}.RATELIMIT=#{ratelimit,jdbcType=INTEGER}
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="cfgId != null">
|
||||
@@ -360,6 +364,9 @@
|
||||
<if test="functionId != null">
|
||||
AND r.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="ratelimit != null">
|
||||
AND r.RATELIMIT=#{ratelimit,jdbcType=INTEGER}
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<!-- 数据范围过滤 -->
|
||||
@@ -506,6 +513,9 @@
|
||||
<if test="functionId != null">
|
||||
FUNCTION_ID=#{functionId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="ratelimit != null">
|
||||
RATELIMIT=#{ratelimit,jdbcType=INTEGER}
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
<resultMap id="CFGResultMap" type="com.nis.domain.specific.SpecificServiceCfg" >
|
||||
<id column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
||||
<result column="spec_service_code" property="specServiceCode" jdbcType="INTEGER" />
|
||||
<result column="spec_service_name" property="specServiceName" jdbcType="VARCHAR" />
|
||||
<result column="spec_service_desc" property="specServiceDesc" jdbcType="VARCHAR" />
|
||||
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
@@ -18,6 +19,7 @@
|
||||
|
||||
<sql id="specificServiceCfgColumns">
|
||||
s.spec_service_id AS specServiceId,
|
||||
s.spec_service_code AS specServiceCode,
|
||||
s.spec_service_name AS specServiceName,
|
||||
s.spec_service_desc AS specServiceDesc,
|
||||
s.is_valid AS isValid,
|
||||
@@ -62,6 +64,9 @@
|
||||
<if test="specServiceId != null">
|
||||
AND s2.spec_service_id like '%${specServiceId}%'
|
||||
</if>
|
||||
<if test="specServiceCode != null">
|
||||
AND spec_service_code = #{specServiceCode}
|
||||
</if>
|
||||
<if test="specServiceName != null and specServiceName != '' ">
|
||||
AND s2.spec_service_name like '%${specServiceName}%'
|
||||
</if>
|
||||
@@ -93,7 +98,10 @@
|
||||
<select id="findAllSpecificServiceCfg" resultMap="CFGResultMap" >
|
||||
SELECT * from specific_service_cfg where is_valid = 1
|
||||
<if test="specificServiceCfg.specServiceId != null">
|
||||
AND spec_service_id like '%${specificServiceCfg.specServiceId}%'
|
||||
AND spec_service_id =#{specificServiceCfg.specServiceId}
|
||||
</if>
|
||||
<if test="specificServiceCfg.specServiceCode != null">
|
||||
AND spec_service_id =#{specificServiceCfg.specServiceCode}
|
||||
</if>
|
||||
<if test="specificServiceCfg.specServiceName != null and specificServiceCfg.specServiceName != '' ">
|
||||
AND spec_service_name like '%${specificServiceCfg.specServiceName}%'
|
||||
@@ -122,22 +130,22 @@
|
||||
|
||||
<!-- 新增 -->
|
||||
<insert id="insert" parameterType="com.nis.domain.specific.SpecificServiceCfg" useGeneratedKeys="true">
|
||||
insert into specific_service_cfg (spec_service_id,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id)
|
||||
values(#{specServiceId},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId})
|
||||
insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id)
|
||||
values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId})
|
||||
</insert>
|
||||
|
||||
<!-- 修改 -->
|
||||
<update id="update" parameterType="com.nis.domain.specific.SpecificServiceCfg">
|
||||
UPDATE specific_service_cfg s SET
|
||||
s.spec_service_id = #{specificServiceCfg.specServiceId},
|
||||
s.spec_service_name = #{specificServiceCfg.specServiceName},
|
||||
s.spec_service_desc = #{specificServiceCfg.specServiceDesc},
|
||||
s.is_valid = #{specificServiceCfg.isValid},
|
||||
s.op_time = #{specificServiceCfg.opTime},
|
||||
s.parent_id = #{specificServiceCfg.parent.specServiceId},
|
||||
s.is_leaf = #{specificServiceCfg.isLeaf},
|
||||
s.group_id = #{specificServiceCfg.groupId}
|
||||
WHERE s.spec_service_id = #{oldId}
|
||||
s.spec_service_code = #{specServiceCode},
|
||||
s.spec_service_name = #{specServiceName},
|
||||
s.spec_service_desc = #{specServiceDesc},
|
||||
s.is_valid = #{isValid},
|
||||
s.op_time = #{opTime},
|
||||
s.parent_id = #{parent.specServiceId},
|
||||
s.is_leaf = #{isLeaf},
|
||||
s.group_id = #{groupId}
|
||||
WHERE s.spec_service_id = #{specServiceId}
|
||||
</update>
|
||||
|
||||
<!-- 删除 -->
|
||||
|
||||
@@ -7,16 +7,14 @@
|
||||
<id column="host_id" property="hostId" jdbcType="INTEGER" />
|
||||
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
||||
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
|
||||
<result column="src_ip" property="srcIp" jdbcType="VARCHAR" />
|
||||
<result column="src_ip_mask" property="srcIpMask" jdbcType="VARCHAR" />
|
||||
<result column="src_port" property="srcPort" jdbcType="VARCHAR" />
|
||||
<result column="src_port_mask" property="srcPortMask" jdbcType="VARCHAR" />
|
||||
<result column="dst_ip" property="dstIp" jdbcType="VARCHAR" />
|
||||
<result column="dst_ip_mask" property="dstIpMask" jdbcType="VARCHAR" />
|
||||
<result column="dst_port" property="dstPort" jdbcType="VARCHAR" />
|
||||
<result column="dst_port_mask" property="dstPortMask" jdbcType="VARCHAR" />
|
||||
<result column="direction" property="direction" jdbcType="INTEGER" />
|
||||
<result column="protocol" property="protocol" 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="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
@@ -39,17 +37,8 @@
|
||||
<sql id="specificServiceHostCfgColumns">
|
||||
s.host_id AS hostId,
|
||||
s.spec_service_id AS specServiceId,
|
||||
s.ip_type AS ipType,
|
||||
s.src_ip AS srcIp,
|
||||
s.src_ip_mask AS srcIpMask,
|
||||
s.src_port AS srcPort,
|
||||
s.src_port_mask AS srcPortMask,
|
||||
s.dst_ip AS dstIp,
|
||||
s.dst_ip_mask AS dstIpMask,
|
||||
s.dst_port AS dstPort,
|
||||
s.dst_port_mask AS dstPortMask,
|
||||
s.direction AS direction,
|
||||
s.protocol AS protocol,
|
||||
s.ip_type,s.src_ip_address,s.ip_pattern,s.port_pattern,s.src_port
|
||||
,s.protocol,s.direction,s.dest_ip_address,s.dest_port,
|
||||
s.is_valid AS isValid,
|
||||
s.is_audit AS isAudit,
|
||||
s.creator_id AS "creator.id",
|
||||
@@ -81,11 +70,11 @@ select * from specific_service_host_cfg where is_valid = 1
|
||||
<if test="ipType !=null" >
|
||||
AND ip_type = #{ipType}
|
||||
</if>
|
||||
<if test="srcIp !=null and srcIp !='' " >
|
||||
AND src_ip = #{srcIp}
|
||||
<if test="srcIpAddress !=null and srcIpAddress !='' " >
|
||||
AND src_ip_address = #{srcIpAddress}
|
||||
</if>
|
||||
<if test="dstIp !=null and dstIp !='' " >
|
||||
AND dst_ip = #{dstIp}
|
||||
<if test="destIpAddress !=null and destIpAddress !='' " >
|
||||
AND dest_ip_address = #{destIpAddress}
|
||||
</if>
|
||||
<if test="protocol !=null" >
|
||||
AND protocol = #{protocol}
|
||||
@@ -131,24 +120,40 @@ from specific_service_host_cfg s where s.spec_service_id = #{specServiceId}
|
||||
|
||||
<!-- 新增 -->
|
||||
<insert id="insert" parameterType="com.nis.domain.specific.SpecificServiceHostCfg">
|
||||
insert into specific_service_host_cfg (spec_service_id,ip_type,src_ip,src_ip_mask,src_port,src_port_mask,dst_ip,dst_ip_mask,dst_port,dst_port_mask,direction,protocol,is_valid,is_audit,creator_id,create_time,editor_id,edit_time,auditor_id,audit_time)
|
||||
values(#{specServiceId},#{ipType},#{srcIp},#{srcIpMask},#{srcPort},#{srcPortMask},#{dstIp},#{dstIpMask},#{dstPort},#{dstPortMask},#{direction},#{protocol},#{isValid},#{isAudit},#{creator.id},#{createTime},#{editor.id},#{editTime},#{auditor.id},#{auditTime})
|
||||
insert into specific_service_host_cfg (spec_service_id,ip_type,
|
||||
src_ip_address,
|
||||
ip_pattern,
|
||||
port_pattern,
|
||||
src_port,
|
||||
protocol,
|
||||
direction,
|
||||
dest_port,
|
||||
dest_ip_address,
|
||||
is_valid,is_audit,creator_id,create_time,editor_id,edit_time,auditor_id,audit_time)
|
||||
values(#{specServiceId},#{ipType,jdbcType=INTEGER},
|
||||
#{srcIpAddress,jdbcType=VARCHAR},
|
||||
#{ipPattern,jdbcType=INTEGER},
|
||||
#{portPattern,jdbcType=INTEGER},
|
||||
#{srcPort,jdbcType=VARCHAR},
|
||||
#{protocol,jdbcType=INTEGER},
|
||||
#{direction,jdbcType=INTEGER},
|
||||
#{destPort,jdbcType=VARCHAR},
|
||||
#{destIpAddress,jdbcType=VARCHAR},
|
||||
#{isValid},#{isAudit},#{creator.id},#{createTime},#{editor.id},#{editTime},#{auditor.id},#{auditTime})
|
||||
</insert>
|
||||
<!-- 修改 -->
|
||||
<update id="update" parameterType="com.nis.domain.specific.SpecificServiceHostCfg">
|
||||
update specific_service_host_cfg s set
|
||||
s.spec_service_id = #{specServiceId},
|
||||
s.ip_type = #{ipType},
|
||||
s.src_ip = #{srcIp},
|
||||
s.src_ip_mask = #{srcIpMask},
|
||||
s.src_port = #{srcPort},
|
||||
s.src_port_mask = #{srcPortMask},
|
||||
s.dst_ip = #{dstIp},
|
||||
s.dst_ip_mask = #{dstIpMask},
|
||||
s.dst_port = #{dstPort},
|
||||
s.dst_port_mask = #{dstPortMask},
|
||||
s.direction = #{direction},
|
||||
s.protocol = #{protocol},
|
||||
s.IP_TYPE = #{ipType,jdbcType=INTEGER},
|
||||
s.IP_PATTERN=#{ipPattern,jdbcType=INTEGER},
|
||||
s.SRC_IP_ADDRESS=#{srcIpAddress,jdbcType=VARCHAR},
|
||||
s.DEST_IP_ADDRESS=#{destIpAddress,jdbcType=VARCHAR},
|
||||
s.PORT_PATTERN=#{portPattern,jdbcType=INTEGER},
|
||||
s.SRC_PORT=#{srcPort,jdbcType=VARCHAR},
|
||||
s.DEST_PORT=#{destPort,jdbcType=VARCHAR},
|
||||
s.direction = #{direction,jdbcType=INTEGER},
|
||||
s.protocol = #{protocol,jdbcType=INTEGER},
|
||||
s.is_valid = #{isValid},
|
||||
s.is_audit = #{isAudit},
|
||||
s.creator_id = #{creator.id},
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -13,6 +14,7 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
import com.nis.main.ConvertTool;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.specific.SpecificServiceCfgDao;
|
||||
import com.nis.web.service.BaseService;
|
||||
@@ -65,9 +67,10 @@ public class SpecificServiceCfgService extends BaseService{
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveOrUpdate(SpecificServiceCfg specificServiceCfg, Integer oldId) throws Exception {
|
||||
public void saveOrUpdate(SpecificServiceCfg specificServiceCfg) throws Exception {
|
||||
if(specificServiceCfg.getGroupId()==null || specificServiceCfg.getGroupId()==0){
|
||||
specificServiceCfg.setGroupId(new ConvertTool().getGroupId());
|
||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
specificServiceCfg.setGroupId(groupId);
|
||||
}
|
||||
//新增协议分组
|
||||
ConfigGroupInfo group = specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
||||
@@ -79,26 +82,28 @@ public class SpecificServiceCfgService extends BaseService{
|
||||
group.setGroupType(1);
|
||||
specificServiceCfgDao.insertConfigGroupInfo(group);
|
||||
}
|
||||
if(oldId==null){//新增
|
||||
if(specificServiceCfg.getSpecServiceId()==null){//新增
|
||||
if(specificServiceCfg.getIsLeaf()==null){
|
||||
if(specificServiceCfg.getParent().getSpecServiceId().equals(0)){
|
||||
specificServiceCfg.setIsLeaf(0);
|
||||
}else{
|
||||
specificServiceCfg.setIsLeaf(1);
|
||||
}
|
||||
}
|
||||
|
||||
specificServiceCfg.setIsValid(1);
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfgDao.insert(specificServiceCfg);
|
||||
}else{//修改
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
//修改id则将其子类的parent_id一并修改
|
||||
if(oldId!=specificServiceCfg.getSpecServiceId()){
|
||||
//找出所有子类
|
||||
List<SpecificServiceCfg> list = specificServiceCfgDao.getChildrenById(oldId);
|
||||
SpecificServiceCfg se =new SpecificServiceCfg();
|
||||
se.setSpecServiceId(specificServiceCfg.getSpecServiceId());
|
||||
for(SpecificServiceCfg ss:list){
|
||||
if(ss!=null){
|
||||
ss.setParent(se);
|
||||
specificServiceCfgDao.update(ss,ss.getSpecServiceId());
|
||||
}
|
||||
if(specificServiceCfg.getIsLeaf()==null){
|
||||
if(specificServiceCfg.getParent().getSpecServiceId().equals(0)){
|
||||
specificServiceCfg.setIsLeaf(0);
|
||||
}else{
|
||||
specificServiceCfg.setIsLeaf(1);
|
||||
}
|
||||
}
|
||||
specificServiceCfgDao.update(specificServiceCfg,oldId);
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfgDao.update(specificServiceCfg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -59,34 +59,44 @@ public class SpecificServiceHostCfgService extends BaseService{
|
||||
public void saveOrUpdate(SpecificServiceHostCfg specificServiceHostCfg) {
|
||||
SysUser user = UserUtils.getUser();
|
||||
String defaultIp = "0.0.0.0"; //缺省0.0.0.0值表示任意
|
||||
String defaultIpMask = "";
|
||||
if(specificServiceHostCfg.getIpType().equals(4)){
|
||||
defaultIpMask = "255.255.255.255"; //255.255.255.255表示无掩码
|
||||
if(specificServiceHostCfg.getIpPattern()==1){
|
||||
defaultIp = "0.0.0.0/32"; //0.0.0.0表示任意
|
||||
}else if(specificServiceHostCfg.getIpPattern()==2){
|
||||
defaultIp = "0.0.0.0-0.0.0.0";
|
||||
}else{
|
||||
defaultIp = "0.0.0.0";
|
||||
}
|
||||
|
||||
}
|
||||
if(specificServiceHostCfg.getIpType().equals(6)){
|
||||
defaultIpMask = "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"; //FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF表示无掩码
|
||||
if(specificServiceHostCfg.getIpPattern()==1){
|
||||
defaultIp = "::/64";
|
||||
}else if(specificServiceHostCfg.getIpPattern()==2){
|
||||
defaultIp = "::-::";
|
||||
}else{
|
||||
defaultIp = "::";
|
||||
}
|
||||
}
|
||||
String defaultPort = "0"; //0表示任意
|
||||
if(specificServiceHostCfg.getPortPattern().equals(1)){
|
||||
defaultPort = "0";
|
||||
}else{
|
||||
defaultPort = "0/0";
|
||||
}
|
||||
String defaultPortMask = "65535"; //65535表示无掩码
|
||||
//ip地址默认 缺省0.0.0.0值表示任意
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getSrcIp())){
|
||||
specificServiceHostCfg.setSrcIp(defaultIp);
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getSrcIpAddress())){
|
||||
specificServiceHostCfg.setSrcIpAddress(defaultIp);
|
||||
}
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getDstIp())){
|
||||
specificServiceHostCfg.setDstIp(defaultIp);
|
||||
}
|
||||
//ip掩码默认
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getSrcIpMask())){
|
||||
specificServiceHostCfg.setSrcIpMask(defaultIpMask);
|
||||
}
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getDstIpMask())){
|
||||
specificServiceHostCfg.setDstIpMask(defaultIpMask);
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getDestIpAddress())){
|
||||
specificServiceHostCfg.setDestIpAddress(defaultIp);
|
||||
}
|
||||
//端口掩码默认
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getSrcPortMask())){
|
||||
specificServiceHostCfg.setSrcPortMask(defaultPortMask);
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getSrcPort())){
|
||||
specificServiceHostCfg.setSrcPort(defaultPort);
|
||||
}
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getDstPortMask())){
|
||||
specificServiceHostCfg.setDstPortMask(defaultPortMask);
|
||||
if(StringUtil.isBlank(specificServiceHostCfg.getDestPort())){
|
||||
specificServiceHostCfg.setDestPort(defaultPort);
|
||||
}
|
||||
//方向缺省
|
||||
if(specificServiceHostCfg.getDirection()==null){
|
||||
@@ -181,7 +191,7 @@ public class SpecificServiceHostCfgService extends BaseService{
|
||||
}
|
||||
|
||||
//源IP
|
||||
if(!StringUtil.isEmpty(specificServiceHostCfg.getSrcIp())&&!BasicProvingUtil.isIpOrIpMask(specificServiceHostCfg.getSrcIp(), specificServiceHostCfg.getIpType())){
|
||||
/*if(!StringUtil.isEmpty(specificServiceHostCfg.getSrcIp())&&!BasicProvingUtil.isIpOrIpMask(specificServiceHostCfg.getSrcIp(), specificServiceHostCfg.getIpType())){
|
||||
logger.info(msgProp.getProperty("the_line_of").replace("rowNum", (i+3)+"")+ msgProp.getProperty("val_src_ip"));
|
||||
// throw new RuntimeException(msgProp.getProperty("the_line_of").replace("rowNum", (i+3)+"")+ msgProp.getProperty("val_src_ip"));
|
||||
importErrorInfo=new ImportErrorInfo(i+3+"",msgProp.getProperty("client_ip"),msgProp.getProperty("the_line_of").replace("rowNum", (i+3)+"")+ msgProp.getProperty("val_src_ip"));
|
||||
@@ -293,7 +303,7 @@ public class SpecificServiceHostCfgService extends BaseService{
|
||||
//方向缺省
|
||||
if(specificServiceHostCfg.getDirection()==null){
|
||||
specificServiceHostCfg.setDirection(0);
|
||||
}
|
||||
}*/
|
||||
Date date = new Date();
|
||||
specificServiceHostCfg.setIsValid(1);
|
||||
specificServiceHostCfg.setCreator(user);
|
||||
|
||||
Reference in New Issue
Block a user