158 lines
6.0 KiB
Java
158 lines
6.0 KiB
Java
|
|
package com.nis.web.controller.basics;
|
||
|
|
|
||
|
|
import java.util.Properties;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
|
||
|
|
import org.apache.commons.lang.StringUtils;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.ui.Model;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||
|
|
|
||
|
|
import com.nis.domain.Page;
|
||
|
|
import com.nis.domain.basics.AsnGroupInfo;
|
||
|
|
import com.nis.util.StringUtil;
|
||
|
|
import com.nis.web.controller.BaseController;
|
||
|
|
/**
|
||
|
|
* 协议分组
|
||
|
|
* @author dell
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
@Controller
|
||
|
|
@RequestMapping(value = "${adminPath}/basics/asnGroup")
|
||
|
|
public class AsnGroupController extends BaseController {
|
||
|
|
|
||
|
|
//@RequiresPermissions(value={"basics:asnGroup:view"},logical=Logical.OR)
|
||
|
|
@RequestMapping(value = {"/asnGroupList", ""})
|
||
|
|
public String asnGroupList(AsnGroupInfo cfg,HttpServletRequest request
|
||
|
|
, HttpServletResponse response, Model model
|
||
|
|
,RedirectAttributes redirectAttributes) {
|
||
|
|
if(cfg == null)cfg=new AsnGroupInfo();
|
||
|
|
Page<AsnGroupInfo> pageCondition = new Page<AsnGroupInfo>(request, response,"r");
|
||
|
|
|
||
|
|
Page page = asnGroupInfoService.findAsnGroupInfoList(pageCondition,cfg);
|
||
|
|
model.addAttribute("cfg", cfg);
|
||
|
|
model.addAttribute("page", page);
|
||
|
|
return "/basics/asnGroupList";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 进入添加或修改页面
|
||
|
|
* @param serviceDictInfo
|
||
|
|
* @param model
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
//@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:label:add","basics:classification:edit","basics:attribute:edit","basics:label:edit","basics:classification:view","basics:attribute:view","basics:label:view"},logical=Logical.OR)
|
||
|
|
@RequestMapping(value={"/asnGroupForm"})
|
||
|
|
public String form(String ids,Model model,String doAction,RedirectAttributes redirectAttributes) {
|
||
|
|
AsnGroupInfo asnGroup=new AsnGroupInfo();
|
||
|
|
if(!StringUtil.isEmpty(ids)){
|
||
|
|
asnGroup=asnGroupInfoService.getById(Integer.parseInt(ids));
|
||
|
|
}
|
||
|
|
model.addAttribute("_cfg", asnGroup);
|
||
|
|
return "/basics/asnGroupForm";
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 新增或修改
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
//@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:label:add","basics:classification:edit","basics:attribute:edit","basics:label:edit"},logical=Logical.OR)
|
||
|
|
@RequestMapping(value = "saveOrUpdate")
|
||
|
|
public String saveOrUpdate(AsnGroupInfo cfg,Model model,
|
||
|
|
RedirectAttributes redirectAttributes,String itType) {
|
||
|
|
|
||
|
|
try {
|
||
|
|
AsnGroupInfo asnGroup=asnGroupInfoService.getGroupIdByNameAndASNId(cfg.getOrganization().trim(), cfg.getCountry().trim(), cfg.getAsnId());
|
||
|
|
if(asnGroup!=null) {
|
||
|
|
Properties props=this.getMsgProp();
|
||
|
|
addMessage(redirectAttributes,"error","ASN "+props.getProperty("repeat", "Repeat"));
|
||
|
|
}
|
||
|
|
asnGroupInfoService.saveOrUpdate(cfg);
|
||
|
|
addMessage(redirectAttributes,"success","save_success");
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("新增失败",e);
|
||
|
|
addMessage(redirectAttributes,"error","save_failed");
|
||
|
|
}
|
||
|
|
|
||
|
|
return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList";
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 删除
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
//@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del"},logical=Logical.OR)
|
||
|
|
@RequestMapping(value={"delete"})
|
||
|
|
public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds) {
|
||
|
|
try {
|
||
|
|
asnGroupInfoService.delete(ids,asnIds);
|
||
|
|
addMessage(redirectAttributes,"success","delete_success");
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("删除失败",e);
|
||
|
|
addMessage(redirectAttributes,"error","delete_failed");
|
||
|
|
}
|
||
|
|
return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList";
|
||
|
|
}
|
||
|
|
@RequestMapping(value="ajaxGetAuditedIP",method=RequestMethod.POST)
|
||
|
|
@ResponseBody
|
||
|
|
public boolean ajaxGetAuditedIP(Model model,@RequestParam(required=true,value="asnIds")String asnIds){
|
||
|
|
if(StringUtils.isNotBlank(asnIds)) {
|
||
|
|
return asnGroupInfoService.checkIps(asnIds);
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
@RequestMapping(value="asnGroupName",method=RequestMethod.POST)
|
||
|
|
@ResponseBody
|
||
|
|
public Integer asnGroupName(Model model,@RequestParam(required=true,value="id")Long id,@RequestParam(required=true,value="organization")String organization,@RequestParam(required=true,value="country")String country,
|
||
|
|
@RequestParam(required=true,value="detail")String detail,@RequestParam(required=true,value="asnId")Long asnId){
|
||
|
|
if(StringUtils.isNotBlank(organization)) {
|
||
|
|
AsnGroupInfo info= asnGroupInfoService.getGroupIdByNameAndASNId(organization,country,asnId);
|
||
|
|
if(info==null) {
|
||
|
|
return 0;
|
||
|
|
}else if(id!=null&&info.getId().longValue()==id.longValue()){
|
||
|
|
return 0;
|
||
|
|
}else if(id!=null&&info.getId().longValue()!=id.longValue()){
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
// @RequestMapping(value="asnGroupName1",method=RequestMethod.POST)
|
||
|
|
// @ResponseBody
|
||
|
|
// public String asnGroupName1(Model model,@RequestParam(required=true,value="id")Long id,@RequestParam(required=true,value="organization")String organization,@RequestParam(required=true,value="country")String country,
|
||
|
|
// @RequestParam(required=true,value="detail")String detail,@RequestParam(required=true,value="asnId")Long asnId){
|
||
|
|
// if(StringUtils.isNotBlank(organization)) {
|
||
|
|
// AsnGroupInfo info= asnGroupInfoService.getGroupIdByNameAndASNId(organization,country,asnId);
|
||
|
|
// if(info==null) {
|
||
|
|
// return "";
|
||
|
|
// }else if(info.get) {
|
||
|
|
//
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// return 0;
|
||
|
|
// }
|
||
|
|
/**
|
||
|
|
* 校验asn号是否已存在
|
||
|
|
*/
|
||
|
|
@ResponseBody
|
||
|
|
@RequestMapping(value = {"/checkAsnNo"})
|
||
|
|
public boolean checkIp(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){
|
||
|
|
|
||
|
|
AsnGroupInfo policyGroup = asnGroupInfoService.getInfoByAsnNo(cfg);
|
||
|
|
if(policyGroup == null){
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|