2018-03-17 17:09:19 +08:00
|
|
|
package com.nis.web.controller.specific;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
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.bind.annotation.RequestParam;
|
2018-03-21 13:43:43 +08:00
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
2018-03-17 17:09:19 +08:00
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
import com.nis.domain.specific.SpecificServiceHostCfg;
|
|
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
|
@RequestMapping(value = "${adminPath}/specific/specificServiceHostCfg")
|
|
|
|
|
public class SpecificServiceHostCfgController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ModelAttribute
|
|
|
|
|
public SpecificServiceHostCfg get(@RequestParam(required=false) Integer hostId) {
|
|
|
|
|
if (!StringUtil.isEmpty(hostId)){
|
|
|
|
|
return specificServiceHostCfgService.getDictByHostId(hostId);
|
|
|
|
|
}else{
|
|
|
|
|
return new SpecificServiceHostCfg();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询
|
|
|
|
|
* @param specificServiceHostCfg
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param model
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("sys:dict:view")
|
|
|
|
|
@RequestMapping(value = "list")
|
|
|
|
|
public String list(SpecificServiceHostCfg specificServiceHostCfg, HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
Model model) {
|
|
|
|
|
|
|
|
|
|
//查出分页数据
|
|
|
|
|
Page<SpecificServiceHostCfg> page = specificServiceHostCfgService.findSpecHostList(new Page<SpecificServiceHostCfg>(request, response), specificServiceHostCfg);
|
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
//查出所有
|
|
|
|
|
List<SpecificServiceHostCfg> list = specificServiceHostCfgService.getAll();
|
|
|
|
|
List<Integer> listSpecServiceId = Lists.newArrayList();
|
|
|
|
|
List<String> listSrcIp = Lists.newArrayList();
|
|
|
|
|
List<String> listDstIp = Lists.newArrayList();
|
|
|
|
|
for(SpecificServiceHostCfg ssh:list){
|
2018-03-21 13:43:43 +08:00
|
|
|
if(ssh!=null&&ssh.getSpecServiceId()!=null&&(!listSpecServiceId.contains(ssh.getSpecServiceId()))){
|
2018-03-17 17:09:19 +08:00
|
|
|
listSpecServiceId.add(ssh.getSpecServiceId());
|
|
|
|
|
}
|
2018-03-21 13:43:43 +08:00
|
|
|
if(ssh!=null&&ssh.getSrcIp()!=null&&(!listSrcIp.contains(ssh.getSrcIp()))){
|
2018-03-17 17:09:19 +08:00
|
|
|
listSrcIp.add(ssh.getSrcIp());
|
|
|
|
|
}
|
2018-03-21 13:43:43 +08:00
|
|
|
if(ssh!=null&&ssh.getDstIp()!=null&&(!listDstIp.contains(ssh.getDstIp()))){
|
2018-03-17 17:09:19 +08:00
|
|
|
listDstIp.add(ssh.getDstIp());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("listSpecServiceId", listSpecServiceId);
|
|
|
|
|
model.addAttribute("listSrcIp", listSrcIp);
|
|
|
|
|
model.addAttribute("listDstIp", listDstIp);
|
|
|
|
|
return "/specific/specificServiceHostCfgList";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进入查看、修改或新增页面
|
|
|
|
|
* @param specificServiceHostCfg
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param model
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("sys:dict:view")
|
|
|
|
|
@RequestMapping(value = "form")
|
|
|
|
|
public String form(SpecificServiceHostCfg specificServiceHostCfg, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
|
|
|
|
|
|
return "/specific/specificServiceHostCfgForm";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增或修改
|
|
|
|
|
* @param specificServiceHostCfg
|
|
|
|
|
* @param model
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
* @param mulitId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value = "saveOrUpdate")
|
|
|
|
|
public String saveOrUpdate(SpecificServiceHostCfg specificServiceHostCfg,Model model,RedirectAttributes redirectAttributes){
|
|
|
|
|
try {
|
|
|
|
|
specificServiceHostCfgService.saveOrUpdate(specificServiceHostCfg);
|
|
|
|
|
addMessage(redirectAttributes, "保存成功");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
addMessage(redirectAttributes, "保存失败!");
|
|
|
|
|
}
|
2018-03-21 13:43:43 +08:00
|
|
|
return "redirect:"+adminPath+"/specific/specificServiceHostCfg/list";
|
2018-03-17 17:09:19 +08:00
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* @param specificServiceHostCfg
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
* @param mulitId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="delete")
|
|
|
|
|
public String delete(SpecificServiceHostCfg specificServiceHostCfg, RedirectAttributes redirectAttributes, String mulitId){
|
|
|
|
|
try{
|
|
|
|
|
specificServiceHostCfgService.delete(mulitId);
|
|
|
|
|
addMessage(redirectAttributes,"删除成功");
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
addMessage(redirectAttributes,"删除失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "redirect:"+adminPath+"/specific/specificServiceHostCfg/list";
|
|
|
|
|
}
|
2018-03-21 13:43:43 +08:00
|
|
|
/**
|
|
|
|
|
* 校验spec_service_id重复
|
|
|
|
|
* @param newId
|
|
|
|
|
* @param oldId
|
|
|
|
|
*/
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "isSpecServiceIdRepeat")
|
|
|
|
|
public boolean isSpecServiceIdRepeat(String newId,String oldId){
|
|
|
|
|
if(oldId!=null){
|
|
|
|
|
oldId.trim().equals(newId);
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
SpecificServiceHostCfg sshc = specificServiceHostCfgService.getBySpecServiceId(Integer.valueOf(newId));
|
|
|
|
|
if(sshc==null){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-03-17 17:09:19 +08:00
|
|
|
}
|