diff --git a/src/main/java/com/nis/domain/configuration/IpPortCfg.java b/src/main/java/com/nis/domain/configuration/IpPortCfg.java index b4a959c47..ece15c8c5 100644 --- a/src/main/java/com/nis/domain/configuration/IpPortCfg.java +++ b/src/main/java/com/nis/domain/configuration/IpPortCfg.java @@ -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 */ diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index 477213301..129a67861 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -256,6 +256,20 @@ public class BaseController { List lables=serviceDictInfoService.findAllLableDict(); model.addAttribute("lables", lables); } + protected void initPageCondition(Model model,BaseCfg cfg){ + List requestInfos=requestInfoService.getAllRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findAllFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findAllXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findAllLableDict(); + model.addAttribute("lables", lables); + List regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId()); + model.addAttribute("regionList", regionList); + List serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId()); + model.addAttribute("serviceList", serviceList); + } protected void initFormCondition(Model model){ List requestInfos=requestInfoService.getValidRequestInfo(); model.addAttribute("requestInfos", requestInfos); diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java b/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java new file mode 100644 index 000000000..e4871fd32 --- /dev/null +++ b/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java @@ -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 searchPage=new Page(request,response,"r"); + Page 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 ipCfgs=new ArrayList(); + 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; + } +} diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml index eec414cb7..498bd6e38 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -338,6 +338,8 @@ + + ${sqlMap.dsf} @@ -391,25 +393,25 @@ cfg_desc = #{cfgDesc,jdbcType=VARCHAR}, - CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER} + CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}, - CFG_TYPE =#{CFG_TYPE,jdbcType=VARCHAR} + CFG_TYPE =#{cfgType,jdbcType=VARCHAR}, - ip_type = #{ipType,jdbcType=INTEGER}, + IP_TYPE = #{ipType,jdbcType=INTEGER}, - IP_PATTERN=#{ipPattern,jdbcType=INTEGER} + IP_PATTERN=#{ipPattern,jdbcType=INTEGER}, - IP_ADDRESS=#{ipAddress,jdbcType=VARCHAR} + IP_ADDRESS=#{ipAddress,jdbcType=VARCHAR}, - PORT_PATTERN=#{portPattern,jdbcType=INTEGER} + PORT_PATTERN=#{portPattern,jdbcType=INTEGER}, - PORT=#{port,jdbcType=VARCHAR} + PORT=#{port,jdbcType=VARCHAR}, direction = #{direction,jdbcType=INTEGER}, diff --git a/src/main/java/com/nis/web/service/CrudService.java b/src/main/java/com/nis/web/service/CrudService.java index 8f8929b71..da5937ae0 100644 --- a/src/main/java/com/nis/web/service/CrudService.java +++ b/src/main/java/com/nis/web/service/CrudService.java @@ -78,6 +78,7 @@ public abstract class CrudService, T extends BaseEntity> * @return */ public Page findPage(Page page, T entity) { + entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r")); entity.setPage(page); page.setList(dao.findList(entity)); return page; diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index 458be09da..1d3d60b4d 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -114,8 +114,8 @@ public class IpCfgService extends CrudService { @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public void deleteIpCfg(List baseIpCfg, List areaCfg){ List 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 { 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); } diff --git a/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp b/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp index 2eea3163f..6fa2a6b4e 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp @@ -6,12 +6,12 @@ + + +
+

+ +

+
+
+
+
+
+ + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + +

+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ + + +
+
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp new file mode 100644 index 000000000..eec36a0dd --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp @@ -0,0 +1,266 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="${cfgName}"></spring:message> + + + + +
+ +

+ + +

+ +
+
+
+
+
+ + + + + + + + +
+
+ + + + + + + +
+
+ +
+
+ + + + + + + +
+ + + +
+
+
+ + + +
+
+ + + + + +
+ + +
+
+ + href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ +
+
+
+ + + + + <%-- --%> + + + + + + + + + + + + + + <%-- --%> + + + + + + + <%-- --%> + + + + + + <%-- --%> + + + + + + + + + + + +
ip
${status.index+1 }${cfg.cfgDesc }V${cfg.ipType }${cfg.ipAddress }${cfg.port } + + + + ${cfg.areaEffectiveIds } + + + + + + + + + + + ${cfg.creatorName }${cfg.editorName }${cfg.auditorName }
+
${page}
+
+ +
+
+
+ + + \ No newline at end of file