IP白名单增删改查提交
This commit is contained in:
@@ -34,6 +34,11 @@ public class IpPortCfg extends BaseIpCfg {
|
||||
super.initDefaultValue();
|
||||
this.protocolId = 0;
|
||||
}
|
||||
public void initDefaultValueImpl(){
|
||||
initDefaultValue();
|
||||
this.portPattern=1;
|
||||
this.port="0/0";
|
||||
}
|
||||
/**
|
||||
* 此表固定写0
|
||||
*/
|
||||
|
||||
@@ -256,6 +256,20 @@ public class BaseController {
|
||||
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
||||
model.addAttribute("lables", lables);
|
||||
}
|
||||
protected void initPageCondition(Model model,BaseCfg cfg){
|
||||
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
||||
model.addAttribute("requestInfos", requestInfos);
|
||||
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
||||
model.addAttribute("fls", fls);
|
||||
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
||||
model.addAttribute("xzs", xzs);
|
||||
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
||||
model.addAttribute("lables", lables);
|
||||
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
||||
model.addAttribute("regionList", regionList);
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
}
|
||||
protected void initFormCondition(Model model){
|
||||
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
||||
model.addAttribute("requestInfos", requestInfos);
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
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.IpPortCfg;
|
||||
import com.nis.main.ConvertTool;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* 白名单
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/ntc/whitelist")
|
||||
public class WhiteListController extends BaseController{
|
||||
|
||||
@RequestMapping(value = {"ipList"})
|
||||
@RequiresPermissions(value={"whitelist:config","whitelist:audit"},logical=Logical.OR)
|
||||
public String ipList(Model model,String cfgName,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) {
|
||||
model.addAttribute("cfgName", cfgName);
|
||||
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/whitelist/ipList";
|
||||
}
|
||||
@RequestMapping(value = {"ipForm"})
|
||||
@RequiresPermissions(value={"whitelist:config"})
|
||||
public String ipForm(Model model,String ids,BaseIpCfg entity) {
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
entity = ipCfgService.getIpCfgById(IpPortCfg.getTablename(),Long.parseLong(ids));
|
||||
}
|
||||
initFormCondition(model,entity);
|
||||
if(entity.getCfgId()!=null){
|
||||
model.addAttribute("_cfg", entity);
|
||||
}else{
|
||||
IpPortCfg cfg=new IpPortCfg();
|
||||
cfg.initDefaultValueImpl();
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
model.addAttribute("_cfg", cfg);
|
||||
}
|
||||
|
||||
return "/cfg/whitelist/ipForm";
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"saveOrUpdateIp"})
|
||||
public String saveOrUpdateIp(Model model, IpPortCfg cfg) {
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
logger.info("saveOrUpdateIp loaded");
|
||||
try{
|
||||
if(cfg.getCompileId()==null){
|
||||
int compileId=0;
|
||||
cfg.setCompileId(compileId);
|
||||
}
|
||||
Date date=new Date();
|
||||
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((BaseIpCfg)cfg,null);
|
||||
}else{//修改
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(new Date());
|
||||
ipCfgService.updateIpCfg((BaseIpCfg)cfg,null,null,null);
|
||||
}
|
||||
addMessage(model,"save_success");
|
||||
}catch(Exception e){
|
||||
logger.error("保存失败",e);
|
||||
addMessage(model,"save_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/whitelist/ipList?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = {"deleteIp"})
|
||||
@RequiresPermissions("whitelist:config")
|
||||
public String deleteIp(Integer isAudit,Integer isValid,String ids,Integer functionId,Model model) {
|
||||
try{
|
||||
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String idStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(idStr)){
|
||||
BaseIpCfg cfg=new BaseIpCfg();
|
||||
cfg.setCfgId(Long.parseLong(idStr));
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(date);
|
||||
cfg.setIsValid(Constants.VALID_DEL);
|
||||
ipCfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
ipCfgService.deleteIpCfg(ipCfgs,null);
|
||||
addMessage(model,"delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error("删除失败", e);
|
||||
addMessage(model,"delete_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/whitelist/ipList?functionId="+functionId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* getCompileId(获取编译ID)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @return
|
||||
*long
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected long getCompileId(BaseIpCfg cfg){
|
||||
long compileId=0l;
|
||||
try {
|
||||
compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return compileId;
|
||||
}
|
||||
}
|
||||
@@ -338,6 +338,8 @@
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<!-- 数据范围过滤 -->
|
||||
${sqlMap.dsf}
|
||||
</trim>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
@@ -391,25 +393,25 @@
|
||||
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="cfgRegionCode != null">
|
||||
CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
|
||||
CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="cfgType != null and cfgType != ''">
|
||||
CFG_TYPE =#{CFG_TYPE,jdbcType=VARCHAR}
|
||||
CFG_TYPE =#{cfgType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="ipType != null" >
|
||||
ip_type = #{ipType,jdbcType=INTEGER},
|
||||
IP_TYPE = #{ipType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="ipPattern != null">
|
||||
IP_PATTERN=#{ipPattern,jdbcType=INTEGER}
|
||||
IP_PATTERN=#{ipPattern,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="ipAddress != null and ipAddress != ''">
|
||||
IP_ADDRESS=#{ipAddress,jdbcType=VARCHAR}
|
||||
IP_ADDRESS=#{ipAddress,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="portPattern != null">
|
||||
PORT_PATTERN=#{portPattern,jdbcType=INTEGER}
|
||||
PORT_PATTERN=#{portPattern,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="port != null and port !=''">
|
||||
PORT=#{port,jdbcType=VARCHAR}
|
||||
PORT=#{port,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="direction != null" >
|
||||
direction = #{direction,jdbcType=INTEGER},
|
||||
|
||||
@@ -78,6 +78,7 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
* @return
|
||||
*/
|
||||
public Page<T> findPage(Page<T> page, T entity) {
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findList(entity));
|
||||
return page;
|
||||
|
||||
@@ -114,8 +114,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void deleteIpCfg(List<BaseIpCfg> baseIpCfg, List<AreaIpCfg> areaCfg){
|
||||
List<BaseIpCfg> cfgs=new ArrayList<>();
|
||||
cfgs.addAll(areaCfg);
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
cfgs.addAll(areaCfg);
|
||||
this.deleteBatch(cfgs,IpCfgDao.class);
|
||||
}
|
||||
if(baseIpCfg!=null&&baseIpCfg.size()>0){
|
||||
@@ -137,6 +137,9 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){
|
||||
return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId());
|
||||
}
|
||||
public BaseIpCfg getIpCfgById(String tableName,long id){
|
||||
return ipCfgDao.getById(tableName, id);
|
||||
}
|
||||
public Integer getIsValid(BaseIpCfg baseIpCfg){
|
||||
return ipCfgDao.getIsValid(baseIpCfg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user