snat策略增加用户类型选项.
This commit is contained in:
@@ -18,6 +18,11 @@ public class IpReusePolicyCfg extends BaseCfg<IpReusePolicyCfg>{
|
||||
private String userName;
|
||||
private String addrPoolName; // 仅用于列表条件检索
|
||||
|
||||
private Integer ipType;
|
||||
private Integer ipPattern;
|
||||
private String srcIpAddress;
|
||||
private String destIpAddress;
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
@@ -60,5 +65,29 @@ public class IpReusePolicyCfg extends BaseCfg<IpReusePolicyCfg>{
|
||||
public void setAddrPoolName(String addrPoolName) {
|
||||
this.addrPoolName = addrPoolName;
|
||||
}
|
||||
public Integer getIpType() {
|
||||
return ipType;
|
||||
}
|
||||
public void setIpType(Integer ipType) {
|
||||
this.ipType = ipType;
|
||||
}
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
}
|
||||
public void setSrcIpAddress(String srcIpAddress) {
|
||||
this.srcIpAddress = srcIpAddress;
|
||||
}
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
}
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
}
|
||||
public String getDestIpAddress() {
|
||||
return destIpAddress;
|
||||
}
|
||||
public void setDestIpAddress(String destIpAddress) {
|
||||
this.destIpAddress = destIpAddress;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface IpMultiplexDao extends CrudDao<IpMultiplexDao>{
|
||||
// 校验地址池是否被引用
|
||||
List<IpReusePolicyCfg> checkAddrPoolIsUsed(@Param("addrPoolId")String addrPoolId);
|
||||
|
||||
void updatePolicyAuditStatus(IpReusePolicyCfg cfg);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
<result column="addr_pool_id" property="addrPoolId" jdbcType="INTEGER"/>
|
||||
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
|
||||
<result column="user_type" property="userType" jdbcType="VARCHAR"/>
|
||||
|
||||
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
|
||||
<result column="ip_pattern" property="ipPattern" jdbcType="INTEGER" />
|
||||
<result column="src_ip_address" property="srcIpAddress" jdbcType="VARCHAR" />
|
||||
|
||||
<result column="do_log" property="doLog" jdbcType="INTEGER" />
|
||||
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
|
||||
@@ -38,7 +41,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="policyColumns">
|
||||
r.CFG_ID,r.CFG_DESC,r.ADDR_POOL_ID,r.USER_NAME,r.USER_TYPE,
|
||||
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,
|
||||
r.SERVICE_ID,r.COMPILE_ID,r.REQUEST_ID,r.CLASSIFY,r.ATTRIBUTE,r.LABLE,
|
||||
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
|
||||
@@ -75,13 +78,12 @@
|
||||
<if test="compileId != null">
|
||||
AND r.compile_id=#{compileId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND r.user_id in (SELECT u.id FROM user_manage u
|
||||
<where>
|
||||
u.user_name LIKE concat(concat('%',#{userName,jdbcType=VARCHAR}),'%')
|
||||
</where>
|
||||
)
|
||||
<if test="srcIpAddress != null and srcIpAddress != ''">
|
||||
AND r.src_ip_address=#{srcIpAddress,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND r.user_name LIKE concat(concat('%',#{userName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="addrPoolName != null and addrPoolName != ''">
|
||||
AND r.addr_pool_id in (SELECT i.cfg_id FROM ip_reuse_addr_pool i
|
||||
<where>
|
||||
@@ -173,6 +175,9 @@
|
||||
addr_pool_id,
|
||||
user_name,
|
||||
user_type,
|
||||
ip_type,
|
||||
ip_pattern,
|
||||
src_ip_address,
|
||||
action,
|
||||
do_log,
|
||||
is_valid,
|
||||
@@ -204,6 +209,9 @@
|
||||
#{addrPoolId,jdbcType=INTEGER},
|
||||
#{userName,jdbcType=VARCHAR},
|
||||
#{userType,jdbcType=VARCHAR},
|
||||
#{ipType,jdbcType=INTEGER},
|
||||
#{ipPattern,jdbcType=INTEGER},
|
||||
#{srcIpAddress,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
#{doLog,jdbcType=INTEGER},
|
||||
0,
|
||||
@@ -246,7 +254,7 @@
|
||||
update ip_reuse_policy_cfg
|
||||
<set>
|
||||
<trim suffixOverrides=",">
|
||||
<if test="userName != null and userName != ''" >
|
||||
<if test="userName != null" >
|
||||
user_name = #{userName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userType != null and userType != ''" >
|
||||
@@ -258,6 +266,15 @@
|
||||
<if test="addrPoolId != null" >
|
||||
addr_pool_id = #{addrPoolId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<!-- <if test="ipType != null" > -->
|
||||
ip_type = #{ipType,jdbcType=INTEGER},
|
||||
<!-- </if>
|
||||
<if test="ipPattern != null"> -->
|
||||
ip_pattern=#{ipPattern,jdbcType=INTEGER},
|
||||
<!-- </if> -->
|
||||
<if test="srcIpAddress != null">
|
||||
src_ip_address=#{srcIpAddress,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="translateParam != null and translateParam != ''" >
|
||||
translate_param = #{translateParam,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@@ -312,6 +329,28 @@
|
||||
|
||||
</update>
|
||||
|
||||
<update id="updatePolicyAuditStatus" parameterType="com.nis.domain.configuration.IpReusePolicyCfg">
|
||||
update ip_reuse_policy_cfg
|
||||
<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>
|
||||
|
||||
<select id="checkAddrPoolIsUsed" resultMap="policyMap">
|
||||
SELECT
|
||||
<include refid="policyColumns"/>
|
||||
|
||||
@@ -119,7 +119,17 @@ public class IpAddrPoolCfgService extends BaseService{
|
||||
// 2.更新地址池IP信息
|
||||
ipAddrPoolCfgDao.deleteReuseIpCfgs(addrPoolId);
|
||||
for (BaseIpCfg IpCfg : entity.getIpCfgs()) {
|
||||
BeanUtils.copyProperties(entity, IpCfg, new String[]{"cfgId"});
|
||||
try {
|
||||
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
if(compileIds != null && compileIds.size() > 0 ){
|
||||
IpCfg.setCompileId(compileIds.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
BeanUtils.copyProperties(entity, IpCfg, new String[]{"cfgId","compileId"});
|
||||
IpCfg.setUserRegion1(addrPoolId+"");
|
||||
ipAddrPoolCfgDao.saveReuseIpCfgs(IpCfg);
|
||||
}
|
||||
@@ -169,7 +179,7 @@ public class IpAddrPoolCfgService extends BaseService{
|
||||
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
|
||||
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
|
||||
IpAddrPool ip = new IpAddrPool();
|
||||
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
|
||||
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId","compileId"});
|
||||
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
|
||||
if (cfgs.size() > 1) {
|
||||
throw new RuntimeException("CallBack IP did not support IP range!");
|
||||
@@ -216,7 +226,7 @@ public class IpAddrPoolCfgService extends BaseService{
|
||||
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
|
||||
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
|
||||
IpAddrPool ip = new IpAddrPool();
|
||||
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
|
||||
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId","compileId"});
|
||||
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
|
||||
if (cfgs.size() > 1) {
|
||||
throw new RuntimeException("CallBack IP did not support IP range!");
|
||||
|
||||
@@ -56,10 +56,12 @@ public class IpMultiplexService extends BaseService{
|
||||
entity.setIsAudit(0);
|
||||
setAreaEffectiveIds(entity);
|
||||
|
||||
// 获取用户/账号类型
|
||||
if(StringUtils.isNotBlank(entity.getUserName())){
|
||||
String userType = ipMultiplexDao.getUserType(entity.getUserName());
|
||||
entity.setUserType(userType);
|
||||
if("VPN".equals(entity.getUserType())){
|
||||
entity.setIpType(null);
|
||||
entity.setIpPattern(null);
|
||||
entity.setSrcIpAddress("");
|
||||
}else{
|
||||
entity.setUserName("");
|
||||
}
|
||||
|
||||
// 更新策略信息
|
||||
@@ -120,8 +122,7 @@ public class IpMultiplexService extends BaseService{
|
||||
cfg.setIsAudit(isAudit);
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(auditTime);
|
||||
cfg.setDoLog(null);
|
||||
ipMultiplexDao.updatePolicyCfg(cfg);
|
||||
ipMultiplexDao.updatePolicyAuditStatus(cfg);
|
||||
|
||||
SysDictInfoService sysDictInfoService = SpringContextHolder.getBean(SysDictInfoService.class);
|
||||
// 获取配置信息
|
||||
@@ -133,7 +134,7 @@ public class IpMultiplexService extends BaseService{
|
||||
params.put("configId", cfg.getCompileId());
|
||||
params.put("addrPoolId", cfg.getAddrPoolId());
|
||||
params.put("userType", cfg.getUserType());
|
||||
params.put("userId", keywordsEscape(cfg.getUserName()));
|
||||
params.put("userId", keywordsEscape(StringUtils.isNotBlank(cfg.getUserName())?cfg.getUserName():cfg.getSrcIpAddress()));
|
||||
params.put("doLog", cfg.getDoLog());
|
||||
params.put("action", cfg.getAction());
|
||||
params.put("service", cfg.getServiceId());
|
||||
@@ -164,7 +165,7 @@ public class IpMultiplexService extends BaseService{
|
||||
params.put("configId", cfg.getCompileId());
|
||||
params.put("addrPoolId", cfg.getAddrPoolId());
|
||||
params.put("userType", cfg.getUserType());
|
||||
params.put("userId", keywordsEscape(cfg.getUserName()));
|
||||
params.put("userId", keywordsEscape(StringUtils.isNotBlank(cfg.getUserName())?cfg.getUserName():cfg.getSrcIpAddress()));
|
||||
params.put("doLog", cfg.getDoLog());
|
||||
params.put("action", cfg.getAction());
|
||||
params.put("service", cfg.getServiceId());
|
||||
|
||||
Reference in New Issue
Block a user