dnat复用策略提交.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.nis.util.Constants;
|
||||
|
||||
/**
|
||||
* IP复用DNAT策略实体
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
public class IpReuseDnatPolicyCfg extends IpPortCfg{
|
||||
|
||||
private static final long serialVersionUID = 3965263675989864475L;
|
||||
private String indexTable="ip_reuse_dnat_policy";
|
||||
|
||||
@Expose
|
||||
@SerializedName("configId")
|
||||
private Long cfgId;
|
||||
|
||||
@Expose
|
||||
@SerializedName("originalAddrType")
|
||||
private Integer ipType;
|
||||
|
||||
@Expose
|
||||
@SerializedName("originalDestIp")
|
||||
private String srcIpAddress;
|
||||
|
||||
@Expose
|
||||
@SerializedName("originalDestPort")
|
||||
private String srcPort;
|
||||
|
||||
@Expose
|
||||
@SerializedName("originalProtocol")
|
||||
private Integer protocol;
|
||||
|
||||
@Expose
|
||||
@SerializedName("translatedDestIp")
|
||||
private String destIpAddress;
|
||||
|
||||
@Expose
|
||||
@SerializedName("translatedDestPort")
|
||||
private String destPort;
|
||||
|
||||
@Expose
|
||||
private Integer doLog = Constants.MAAT_CFG_DOLOG_DEFAULT;
|
||||
|
||||
@Expose
|
||||
@SerializedName("effectiveRange")
|
||||
private String areaEffectiveIds;
|
||||
|
||||
|
||||
public String getIndexTable() {
|
||||
return indexTable;
|
||||
}
|
||||
|
||||
public void setIndexTable(String indexTable) {
|
||||
this.indexTable = indexTable;
|
||||
}
|
||||
|
||||
public Integer getIpType() {
|
||||
return ipType;
|
||||
}
|
||||
|
||||
public void setIpType(Integer ipType) {
|
||||
this.ipType = ipType;
|
||||
}
|
||||
|
||||
public Integer getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(Integer protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
|
||||
public void setCfgId(Long cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
}
|
||||
|
||||
public void setSrcIpAddress(String srcIpAddress) {
|
||||
this.srcIpAddress = srcIpAddress;
|
||||
}
|
||||
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
}
|
||||
|
||||
public void setSrcPort(String srcPort) {
|
||||
this.srcPort = srcPort;
|
||||
}
|
||||
|
||||
public String getDestIpAddress() {
|
||||
return destIpAddress;
|
||||
}
|
||||
|
||||
public void setDestIpAddress(String destIpAddress) {
|
||||
this.destIpAddress = destIpAddress;
|
||||
}
|
||||
|
||||
public String getDestPort() {
|
||||
return destPort;
|
||||
}
|
||||
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
|
||||
public Integer getDoLog() {
|
||||
return doLog;
|
||||
}
|
||||
|
||||
public void setDoLog(Integer doLog) {
|
||||
this.doLog = doLog;
|
||||
}
|
||||
|
||||
public String getAreaEffectiveIds() {
|
||||
return areaEffectiveIds;
|
||||
}
|
||||
|
||||
public void setAreaEffectiveIds(String areaEffectiveIds) {
|
||||
this.areaEffectiveIds = areaEffectiveIds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpAddrPoolCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
|
||||
import com.nis.domain.configuration.IpReusePolicyCfg;
|
||||
import com.nis.domain.configuration.UserManage;
|
||||
import com.nis.domain.configuration.template.IpMultiplexPolicyTemplate;
|
||||
@@ -280,42 +281,95 @@ public class IpMultiplexController extends CommonController {
|
||||
|
||||
|
||||
@RequestMapping(value = {"/dnatPolicyList"})
|
||||
public String dnatPolicyList(String cfgName,Model model,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) {
|
||||
this._ipList(cfgName,model, cfg, request, response);
|
||||
return "/cfg/manipulation/ipmulitiplex/dnatPolicyList";
|
||||
public String dnatPolicyList(String cfgName,Model model,@ModelAttribute("cfg")IpReuseDnatPolicyCfg cfg,
|
||||
HttpServletRequest request,HttpServletResponse response) {
|
||||
//this._ipList(cfgName,model, cfg, request, response);
|
||||
|
||||
Page<BaseIpCfg> page = ipMultiplexService.findPageDnat(new Page<BaseIpCfg>(request, response,"r"), cfg);
|
||||
model.addAttribute("page", page);
|
||||
initFormCondition(model,cfg);
|
||||
|
||||
return "/cfg/manipulation/ipmulitiplex/dnatPolicyList2";
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/dnatPolicyForm"})
|
||||
@RequiresPermissions(value={"dnat_policy:config"})
|
||||
public String dnatPolicyForm(String cfgName,Model model,String ids,Integer functionId,BaseIpCfg entity) {
|
||||
this._ipForm(cfgName,model, ids, functionId, entity);
|
||||
// 获取拥有区域信息的策略分组
|
||||
List<PolicyGroupInfo> policyGroups=policyGroupInfoService.getHasAreaPolicyGroups(3);
|
||||
model.addAttribute("policyGroups", policyGroups);
|
||||
model.addAttribute("urlPrefix","/manipulation/ipmulitiplex");
|
||||
return "/cfg/manipulation/ipmulitiplex/dnatPolicyForm";
|
||||
public String dnatPolicyForm(String cfgName,Model model,String ids,Integer functionId,IpReuseDnatPolicyCfg cfg) {
|
||||
//this._ipForm(cfgName,model, ids, functionId, entity);
|
||||
|
||||
if(cfg == null){
|
||||
cfg=new IpReuseDnatPolicyCfg();
|
||||
}
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
cfg = ipMultiplexService.getDnatPolicyCfg(Long.valueOf(ids),null);
|
||||
initUpdateFormCondition(model, cfg);
|
||||
}else{
|
||||
initFormCondition(model, cfg);
|
||||
}
|
||||
model.addAttribute("_cfg", cfg);
|
||||
return "/cfg/manipulation/ipmulitiplex/dnatPolicyForm2";
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/saveOrUpdateDnat"})
|
||||
public String saveOrUpdateDnat(String cfgName,RedirectAttributes model, IpPortCfg cfg) {
|
||||
// 设置生效区域信息
|
||||
groupAreaService.setAreaCodeByGroupId(cfg);
|
||||
this._saveOrUpdateIp(cfgName,model, cfg);
|
||||
public String saveOrUpdateDnat(Model model, RedirectAttributes redirectAttributes, IpReuseDnatPolicyCfg cfg,
|
||||
HttpServletRequest request,HttpServletResponse response) {
|
||||
try{
|
||||
// 添加策略配置信息
|
||||
ipMultiplexService.saveOrUpdateDnat(cfg, request, response);
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "save_failed");
|
||||
}
|
||||
}
|
||||
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/dnatPolicyList?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/dnatDelete"})
|
||||
@RequiresPermissions("dnat_policy:config")
|
||||
public String dnatDelete(String cfgName,String ids,String compileIds,Integer functionId,RedirectAttributes model) {
|
||||
this._deleteIp(cfgName,ids, compileIds, functionId, model);
|
||||
public String dnatDelete(String ids, Integer isValid, Integer functionId,RedirectAttributes redirectAttributes) {
|
||||
//this._deleteIp(cfgName,ids, compileIds, functionId, model);
|
||||
|
||||
try{
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
ipMultiplexService.deleteDnat(isValid,ids,functionId);
|
||||
}
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error(e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/dnatPolicyList?functionId="+functionId;
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/auditDnat"})
|
||||
@RequiresPermissions("dnat_policy:confirm")
|
||||
public String auditDnat(String cfgName,String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
this._auditIp(cfgName,ids, cfg, redirectAttributes);
|
||||
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/dnatPolicyList?functionId="+cfg.getFunctionId();
|
||||
public String auditDnat(String ids,Integer isAudit,Integer isValid,Integer functionId,RedirectAttributes redirectAttributes) {
|
||||
//this._auditIp(cfgName,ids, cfg, redirectAttributes);
|
||||
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
String[] idArray = ids.split(",");
|
||||
Date auditTime=new Date();
|
||||
for(String id :idArray){
|
||||
try {
|
||||
ipMultiplexService.auditDnatPolicy(isAudit,isValid,functionId,id,auditTime);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("DNAT策略配置下发失败:"+e.getMessage());
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "audit_failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/dnatPolicyList?functionId="+functionId;
|
||||
}
|
||||
|
||||
//snat配置导出
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
|
||||
import com.nis.domain.configuration.IpReusePolicyCfg;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
@@ -24,7 +26,19 @@ public interface IpMultiplexDao extends CrudDao<IpMultiplexDao>{
|
||||
|
||||
// 校验地址池是否被引用
|
||||
List<IpReusePolicyCfg> checkAddrPoolIsUsed(@Param("addrPoolId")String addrPoolId);
|
||||
|
||||
|
||||
// SNAT策略更新审核状态
|
||||
void updatePolicyAuditStatus(IpReusePolicyCfg cfg);
|
||||
|
||||
// DNAT策略更新审核状态
|
||||
void updateDnatPolicyStatus(IpReuseDnatPolicyCfg cfg);
|
||||
|
||||
void saveDnatPolicyCfg(IpReuseDnatPolicyCfg entity);
|
||||
|
||||
void updateDnatPolicyCfg(IpReuseDnatPolicyCfg entity);
|
||||
|
||||
List<BaseIpCfg> findPageDnat(IpReuseDnatPolicyCfg entity);
|
||||
|
||||
List<IpReuseDnatPolicyCfg> findDnatList(@Param("cfgId")Long cfgId, @Param("isValid")Integer isValid);
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,41 @@
|
||||
<result column="cancel_request_id" property="cancelRequestId" jdbcType="INTEGER" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="dnatPolicyMap" type="com.nis.domain.configuration.IpReuseDnatPolicyCfg" >
|
||||
<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="translated_dest_ip" property="destIpAddress" jdbcType="VARCHAR" />
|
||||
<result column="original_dest_ip" property="srcIpAddress" jdbcType="VARCHAR" />
|
||||
<result column="translated_dest_port" property="destPort" jdbcType="VARCHAR" />
|
||||
<result column="original_dest_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>
|
||||
|
||||
<sql id="policyColumns">
|
||||
r.CFG_ID,r.CFG_DESC,r.ADDR_POOL_ID,r.USER_NAME,r.USER_TYPE,r.IP_TYPE,r.IP_PATTERN,r.SRC_IP_ADDRESS,
|
||||
r.ACTION,r.DO_LOG,r.IS_VALID,r.IS_AUDIT,r.CFG_REGION_CODE,r.CFG_TYPE,r.FUNCTION_ID,
|
||||
@@ -49,6 +84,15 @@
|
||||
r.USER_REGION1,r.USER_REGION2,r.USER_REGION3,r.USER_REGION4,r.USER_REGION5
|
||||
</sql>
|
||||
|
||||
<sql id="dnatPolicyColumns" >
|
||||
a.cfg_id,a.cfg_desc,a.ip_type,a.original_dest_ip,a.ip_pattern,a.port_pattern,a.original_dest_port,
|
||||
a.protocol,a.protocol_id,a.cfg_type,a.action,a.translated_dest_port,a.translated_dest_ip,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,a.user_region1,a.user_region2,
|
||||
a.user_region3,a.user_region4,a.user_region5
|
||||
</sql>
|
||||
|
||||
<select id="findPage" resultMap="policyMap">
|
||||
SELECT
|
||||
<include refid="policyColumns"/>
|
||||
@@ -75,7 +119,10 @@
|
||||
<if test="cfgId != null">
|
||||
AND r.cfg_id=#{cfgId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="compileId != null">
|
||||
<if test="cfgDesc != null and cfgDesc != ''">
|
||||
AND r.cfg_desc like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="compileId != null">
|
||||
AND r.compile_id=#{compileId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="srcIpAddress != null and srcIpAddress != ''">
|
||||
@@ -94,10 +141,7 @@
|
||||
</where>
|
||||
)
|
||||
</if>
|
||||
<if test="compileId != null">
|
||||
AND r.compile_id=#{compileId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="action != null">
|
||||
<if test="action != null">
|
||||
AND r.ACTION=#{action,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isValid != null">
|
||||
@@ -362,4 +406,307 @@
|
||||
WHERE
|
||||
r.addr_pool_id = #{addrPoolId} AND r.is_valid != -1
|
||||
</select>
|
||||
|
||||
<update id="updateDnatPolicyStatus" parameterType="com.nis.domain.configuration.IpReuseDnatPolicyCfg">
|
||||
update ip_reuse_dnat_policy
|
||||
<set>
|
||||
<trim suffixOverrides=",">
|
||||
<if test="isValid != null" >
|
||||
is_valid = #{isValid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isAudit != null" >
|
||||
is_audit = #{isAudit,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="auditorId != null" >
|
||||
auditor_id = #{auditorId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="auditTime != null and createTime != ''" >
|
||||
audit_time = #{auditTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
WHERE cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
<insert id="saveDnatPolicyCfg" parameterType="com.nis.domain.configuration.IpReuseDnatPolicyCfg">
|
||||
INSERT INTO ip_reuse_dnat_policy (
|
||||
cfg_desc,
|
||||
ip_type,
|
||||
ip_pattern,
|
||||
port_pattern,
|
||||
original_dest_ip,
|
||||
original_dest_port,
|
||||
translated_dest_ip,
|
||||
translated_dest_port,
|
||||
protocol,
|
||||
protocol_id,
|
||||
is_valid,
|
||||
is_audit,
|
||||
do_log,
|
||||
action,
|
||||
service_id,
|
||||
function_id,
|
||||
compile_id,
|
||||
is_area_effective,
|
||||
area_effective_ids,
|
||||
creator_id,
|
||||
create_time,
|
||||
editor_id,
|
||||
edit_time,
|
||||
auditor_id,
|
||||
audit_time,
|
||||
request_id,
|
||||
classify,
|
||||
attribute,
|
||||
lable,
|
||||
cfg_region_code,
|
||||
cfg_type,
|
||||
user_region1,
|
||||
user_region2,
|
||||
user_region3,
|
||||
user_region4,
|
||||
user_region5
|
||||
)VALUES (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{ipType,jdbcType=INTEGER},
|
||||
#{ipPattern,jdbcType=INTEGER},
|
||||
#{portPattern,jdbcType=INTEGER},
|
||||
#{srcIpAddress,jdbcType=VARCHAR},
|
||||
#{srcPort,jdbcType=VARCHAR},
|
||||
#{destIpAddress,jdbcType=VARCHAR},
|
||||
#{destPort,jdbcType=VARCHAR},
|
||||
#{protocol,jdbcType=INTEGER},
|
||||
#{protocolId,jdbcType=INTEGER},
|
||||
#{isValid,jdbcType=INTEGER},
|
||||
#{isAudit,jdbcType=INTEGER},
|
||||
#{doLog,jdbcType=INTEGER},
|
||||
#{action,jdbcType=INTEGER},
|
||||
#{serviceId,jdbcType=INTEGER},
|
||||
#{functionId,jdbcType=INTEGER},
|
||||
#{compileId,jdbcType=INTEGER},
|
||||
#{isAreaEffective,jdbcType=INTEGER},
|
||||
#{areaEffectiveIds,jdbcType=VARCHAR},
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
#{editTime,jdbcType=TIMESTAMP},
|
||||
#{auditorId,jdbcType=INTEGER},
|
||||
#{auditTime,jdbcType=TIMESTAMP},
|
||||
#{requestId,jdbcType=INTEGER},
|
||||
#{classify,jdbcType=VARCHAR},
|
||||
#{attribute,jdbcType=VARCHAR},
|
||||
#{lable,jdbcType=VARCHAR},
|
||||
#{cfgRegionCode,jdbcType=INTEGER},
|
||||
#{cfgType,jdbcType=VARCHAR},
|
||||
#{userRegion1,jdbcType=VARCHAR},
|
||||
#{userRegion2,jdbcType=VARCHAR},
|
||||
#{userRegion3,jdbcType=VARCHAR},
|
||||
#{userRegion4,jdbcType=VARCHAR},
|
||||
#{userRegion5,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateDnatPolicyCfg" parameterType="com.nis.domain.configuration.IpReuseDnatPolicyCfg">
|
||||
update ip_reuse_dnat_policy
|
||||
<set>
|
||||
<trim suffixOverrides=",">
|
||||
<if test="cfgDesc != null and cfgDesc != ''" >
|
||||
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="ipType != null" >
|
||||
ip_type = #{ipType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="ipPattern != null">
|
||||
ip_pattern=#{ipPattern,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="portPattern != null">
|
||||
port_pattern=#{portPattern,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="srcIpAddress != null">
|
||||
original_dest_ip=#{srcIpAddress,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="destIpAddress != null and destIpAddress != ''">
|
||||
translated_dest_ip=#{destIpAddress,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="srcPort != null and srcPort !=''">
|
||||
original_dest_port=#{srcPort,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="destPort != null and destPort !=''">
|
||||
translated_dest_port=#{destPort,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="protocol != null" >
|
||||
protocol = #{protocol,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="protocolId != null" >
|
||||
protocol_id = #{protocolId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="doLog != null" >
|
||||
do_log = #{doLog,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>
|
||||
<if test="editTime != null and editTime != ''" >
|
||||
edit_time = #{editTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="auditorId != null" >
|
||||
auditor_id = #{auditorId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="auditTime != null and createTime != ''" >
|
||||
audit_time = #{auditTime,jdbcType=TIMESTAMP},
|
||||
</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>
|
||||
</trim>
|
||||
</set>
|
||||
WHERE cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
|
||||
</update>
|
||||
|
||||
<select id="findPageDnat" resultMap="dnatPolicyMap">
|
||||
SELECT
|
||||
<include refid="dnatPolicyColumns"/>
|
||||
<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
|
||||
ip_reuse_dnat_policy 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="compileId != null">
|
||||
AND a.compile_id=#{compileId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="srcIpAddress != null and srcIpAddress != ''">
|
||||
AND a.original_dest_ip=#{srcIpAddress,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="destIpAddress != null and destIpAddress != ''">
|
||||
AND a.translated_dest_ip=#{destIpAddress,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="srcPort != null and srcPort !=''">
|
||||
AND a.original_dest_port=#{srcPort,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="destPort != null and destPort !=''">
|
||||
AND a.translated_dest_port=#{destPort,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 a.CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="editorName != null and editorName != ''">
|
||||
AND a.EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="auditorName != null and auditorName != ''">
|
||||
AND a.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="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="functionId != null">
|
||||
AND a.function_id=#{functionId,jdbcType=INTEGER}
|
||||
</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="findDnatList" resultMap="dnatPolicyMap">
|
||||
SELECT
|
||||
<include refid="dnatPolicyColumns"/>
|
||||
FROM
|
||||
ip_reuse_dnat_policy a
|
||||
<where>
|
||||
<if test="cfgId != null">
|
||||
AND a.cfg_id=#{cfgId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="isValid !=null">
|
||||
AND a.is_valid = #{isValid,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isValid ==null">
|
||||
AND a.is_valid != -1
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.cfg_id
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -8,12 +8,15 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
|
||||
import com.nis.domain.configuration.IpReusePolicyCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
@@ -201,4 +204,134 @@ public class IpMultiplexService extends BaseService{
|
||||
return ipMultiplexDao.checkAddrPoolIsUsed(addrPoolId);
|
||||
}
|
||||
|
||||
/**
|
||||
* DNAT策略配置审核
|
||||
* @param isAudit
|
||||
* @param isValid
|
||||
* @param functionId
|
||||
* @param id
|
||||
* @param auditTime
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditDnatPolicy(Integer isAudit, Integer isValid, Integer functionId, String id, Date auditTime) {
|
||||
// 更新配置审核状态
|
||||
IpReuseDnatPolicyCfg cfg = new IpReuseDnatPolicyCfg();
|
||||
cfg.setCfgId(Long.valueOf(id));
|
||||
cfg.setIsValid(isValid);
|
||||
cfg.setIsAudit(isAudit);
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(auditTime);
|
||||
ipMultiplexDao.updateDnatPolicyStatus(cfg);
|
||||
|
||||
// 获取配置信息
|
||||
cfg = this.getDnatPolicyCfg(cfg.getCfgId(), null);
|
||||
|
||||
SysDictInfoService sysDictInfoService = SpringContextHolder.getBean(SysDictInfoService.class);
|
||||
cfg.setAreaEffectiveIds(cfg.getIsAreaEffective() == 1?sysDictInfoService.setEffectiveRange(cfg.getAreaEffectiveIds()):"0");
|
||||
|
||||
String json="";
|
||||
if(cfg.getIsAudit() == Constants.AUDIT_YES){
|
||||
List list = Lists.newArrayList();
|
||||
list.add(cfg);
|
||||
json=gsonToJson(list);
|
||||
logger.info("DNAT策略配置下发参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
||||
if(result!=null){
|
||||
logger.info("DNAT策略配置下发响应信息:"+result.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("DNAT策略配置下发失败",e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}else if(cfg.getIsAudit() == Constants.AUDIT_NOT_YES){
|
||||
List list = Lists.newArrayList();
|
||||
list.add(cfg);
|
||||
json=gsonToJson(list);
|
||||
logger.info("DNAT策略配置下发参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("DNAT策略配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("DNAT策略配置配置失败");
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DNAT策略新增
|
||||
* @param entity
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveOrUpdateDnat(IpReuseDnatPolicyCfg entity, HttpServletRequest request, HttpServletResponse response) {
|
||||
Date time = new Date();
|
||||
entity.setIsValid(0);
|
||||
entity.setIsAudit(0);
|
||||
setAreaEffectiveIds(entity);
|
||||
|
||||
if(entity.getCfgId() == null){
|
||||
entity.initDefaultValue();
|
||||
entity.setCreateTime(time);
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
//调用服务接口获取compileId
|
||||
try {
|
||||
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
if(compileIds != null && compileIds.size() > 0 ){
|
||||
entity.setCompileId(compileIds.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
ipMultiplexDao.saveDnatPolicyCfg(entity);
|
||||
|
||||
}else{
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(time);
|
||||
ipMultiplexDao.updateDnatPolicyCfg(entity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Page<BaseIpCfg> findPageDnat(Page<BaseIpCfg> page, IpReuseDnatPolicyCfg entity) {
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
||||
entity.setPage(page);
|
||||
List<BaseIpCfg> list=ipMultiplexDao.findPageDnat(entity);
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
public IpReuseDnatPolicyCfg getDnatPolicyCfg(Long cfgId, Integer isValid) {
|
||||
List<IpReuseDnatPolicyCfg> list=ipMultiplexDao.findDnatList(cfgId,isValid);
|
||||
IpReuseDnatPolicyCfg policyCfg=null;
|
||||
if(list != null && list.size()>0){
|
||||
policyCfg=list.get(0);
|
||||
}
|
||||
return policyCfg;
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void deleteDnat(Integer isValid, String ids, Integer functionId) {
|
||||
String[] idArray = ids.split(",");
|
||||
for(String id :idArray){
|
||||
IpReuseDnatPolicyCfg entity = new IpReuseDnatPolicyCfg();
|
||||
entity.setCfgId(Long.valueOf(id));
|
||||
entity.setFunctionId(functionId);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(new Date());
|
||||
ipMultiplexDao.updateDnatPolicyCfg(entity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user