139 lines
4.7 KiB
Java
139 lines
4.7 KiB
Java
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;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||
|
||
import com.google.common.collect.Lists;
|
||
import com.nis.domain.Page;
|
||
import com.nis.domain.specific.SpecificServiceCfg;
|
||
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("specific:serviceIp: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);
|
||
//查询特定服务管理(specific_service_cfg)协议id供下拉选择
|
||
List<SpecificServiceCfg> listSpecService = specificServiceCfgService.findAllSpecificServiceCfg(new SpecificServiceCfg(), "spec_service_id DESC");
|
||
model.addAttribute("listSpecService", listSpecService);
|
||
return "/specific/specificServiceHostCfgList";
|
||
}
|
||
|
||
/**
|
||
* 进入查看、修改或新增页面
|
||
* @param specificServiceHostCfg
|
||
* @param request
|
||
* @param response
|
||
* @param model
|
||
* @return
|
||
*/
|
||
@RequiresPermissions("specific:serviceIp:edit")
|
||
@RequestMapping(value = "form")
|
||
public String form(SpecificServiceHostCfg specificServiceHostCfg, HttpServletRequest request, HttpServletResponse response, Model model) {
|
||
//查询协议id供下拉选择
|
||
List<SpecificServiceCfg> listSpecService = specificServiceCfgService.findAllSpecificServiceCfg(new SpecificServiceCfg(), "spec_service_id DESC");
|
||
model.addAttribute("listSpecService", listSpecService);
|
||
return "/specific/specificServiceHostCfgForm";
|
||
}
|
||
|
||
/**
|
||
* 新增或修改
|
||
* @param specificServiceHostCfg
|
||
* @param model
|
||
* @param redirectAttributes
|
||
* @param mulitId
|
||
* @return
|
||
*/
|
||
@RequiresPermissions("specific:serviceIp:edit")
|
||
@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, "保存失败!");
|
||
}
|
||
return "redirect:"+adminPath+"/specific/specificServiceHostCfg/list";
|
||
}
|
||
/**
|
||
* 删除
|
||
* @param specificServiceHostCfg
|
||
* @param redirectAttributes
|
||
* @param mulitId
|
||
* @return
|
||
*/
|
||
@RequiresPermissions("specific:serviceIp:edit")
|
||
@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";
|
||
}
|
||
/**
|
||
* 校验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;
|
||
}*/
|
||
}
|