This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/java/com/nis/web/controller/specific/SpecificServiceHostCfgController.java

137 lines
4.6 KiB
Java
Raw Normal View History

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;
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.SpecificServiceCfg;
2018-03-17 17:09:19 +08:00
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);
//查询特定服务管理specific_service_cfg协议id供下拉选择
List<SpecificServiceCfg> listSpecService = specificServiceCfgService.findAllSpecificServiceCfg(new SpecificServiceCfg(), "spec_service_id DESC");
model.addAttribute("listSpecService", listSpecService);
2018-03-17 17:09:19 +08:00
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) {
//查询协议id供下拉选择
List<SpecificServiceCfg> listSpecService = specificServiceCfgService.findAllSpecificServiceCfg(new SpecificServiceCfg(), "spec_service_id DESC");
model.addAttribute("listSpecService", listSpecService);
2018-03-17 17:09:19 +08:00
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, "保存失败!");
}
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";
}
/**
* 校验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
}