246 lines
7.2 KiB
Java
246 lines
7.2 KiB
Java
package com.nis.web.controller.configuration;
|
|
|
|
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.google.common.collect.Maps;
|
|
import com.nis.domain.Page;
|
|
import com.nis.domain.SysDataDictionaryName;
|
|
import com.nis.domain.SysMenu;
|
|
import com.nis.domain.configuration.ServiceDictInfo;
|
|
import com.nis.util.StringUtil;
|
|
import com.nis.util.StringUtils;
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
@Controller
|
|
@RequestMapping(value = "${adminPath}/configuration/serviceDictInfo")
|
|
public class ServiceDictInfoController extends BaseController {
|
|
|
|
|
|
@ModelAttribute
|
|
public ServiceDictInfo get(@RequestParam(required=false) Integer serviceDictId) {
|
|
if (!StringUtil.isEmpty(serviceDictId)){
|
|
return serviceDictInfoService.getDictById(serviceDictId);
|
|
}else{
|
|
return new ServiceDictInfo();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* 根据serviceDictId查出配置对象
|
|
* @param serviceDictId
|
|
* @param request
|
|
* @param response
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@ResponseBody
|
|
@RequestMapping(value = "loadDataDict")
|
|
public ServiceDictInfo loadDataDict(@RequestParam(required=false) Integer serviceDictId,HttpServletRequest request, HttpServletResponse response, Model model){
|
|
|
|
return serviceDictInfoService.getDictById(serviceDictId);
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询业务辅助表-业务字典信息列表
|
|
* @param serviceDictInfo
|
|
* @param request
|
|
* @param response
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequiresPermissions("sys:dict:view")
|
|
@RequestMapping(value = {"list", ""})
|
|
public String list(ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findDictList(new Page<ServiceDictInfo>(request, response), serviceDictInfo);
|
|
model.addAttribute("page", page);
|
|
|
|
return "/cfg/serviceDictList";
|
|
}
|
|
|
|
/**
|
|
* 进入添加或修改页面
|
|
* @param serviceDictInfo
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequestMapping(value={"form"})
|
|
public String form(ServiceDictInfo serviceDictInfo, Model model,String doAction) {
|
|
if(doAction!=null&&doAction.equals("0")){
|
|
return "/cfg/serviceDictInfo";
|
|
}
|
|
return "/cfg/serviceDictForm";
|
|
}
|
|
/**
|
|
* 新增或修改
|
|
* @param serviceDictInfo
|
|
* @param model
|
|
* @param redirectAttributes
|
|
* @return
|
|
*/
|
|
@RequiresPermissions("sys:dict:edit")
|
|
@RequestMapping(value = "saveOrUpdate")
|
|
public String saveOrUpdate(ServiceDictInfo serviceDictInfo,Model model, RedirectAttributes redirectAttributes) {
|
|
|
|
try {
|
|
serviceDictInfoService.saveOrUpdate(serviceDictInfo);
|
|
addMessage(redirectAttributes, "保存配置成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
addMessage(redirectAttributes, "保存配置失败!");
|
|
}
|
|
|
|
return "redirect:" + adminPath + "/configuration/serviceDictInfo/list";
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除
|
|
* @param serviceDictInfo
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequestMapping(value={"delete"})
|
|
public String delete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes) {
|
|
try {
|
|
serviceDictInfoService.deleteDict(serviceDictInfo);
|
|
addMessage(redirectAttributes, "删除配置成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
addMessage(redirectAttributes, "删除配置失败!");
|
|
}
|
|
return "redirect:" + adminPath + "/configuration/serviceDictInfo/list";
|
|
}
|
|
|
|
|
|
/**
|
|
* isShowHide是否显示隐藏菜单
|
|
* @param extId
|
|
* @param isShowHidden
|
|
* @param response
|
|
* @return
|
|
*/
|
|
@RequiresPermissions("user")
|
|
@ResponseBody
|
|
@RequestMapping(value = "treeData")
|
|
public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide, HttpServletResponse response) {
|
|
List<Map<String, Object>> mapList = Lists.newArrayList();
|
|
List<ServiceDictInfo> list = serviceDictInfoService.findAllDict();
|
|
for (int i=0; i<list.size(); i++){
|
|
ServiceDictInfo serviceDictInfo = list.get(i);
|
|
if (StringUtils.isBlank(extId) || (extId !=null && !extId.equals(serviceDictInfo.getServiceDictId().toString()))) {
|
|
if(isShowHide != null && isShowHide.equals("0") && serviceDictInfo.getIsValid().equals(0)){
|
|
continue;
|
|
}
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
map.put("id", serviceDictInfo.getServiceDictId());
|
|
map.put("pId", serviceDictInfo.getParent().getServiceDictId());
|
|
map.put("name",serviceDictInfo.getItemValue());
|
|
mapList.add(map);
|
|
}
|
|
}
|
|
return mapList;
|
|
}
|
|
|
|
|
|
|
|
|
|
//标签配置
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 进入添加或修改页面
|
|
* @param serviceDictInfo
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequestMapping(value={"markForm"})
|
|
public String markForm(ServiceDictInfo serviceDictInfo, Model model,String doAction) {
|
|
if(doAction!=null&&doAction.equals("0")){
|
|
return "/cfg/serviceDictMarkInfo";
|
|
}
|
|
return "/cfg/serviceDictMarkForm";
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询业务辅助表-业务字典信息列表
|
|
* @param serviceDictInfo
|
|
* @param request
|
|
* @param response
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequiresPermissions("sys:dict:view")
|
|
@RequestMapping(value = {"markList"})
|
|
public String markList(ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findDictMarkList(new Page<ServiceDictInfo>(request, response), serviceDictInfo);
|
|
model.addAttribute("page", page);
|
|
|
|
return "/cfg/serviceDictMarkList";
|
|
}
|
|
|
|
|
|
/**
|
|
* 新增或修改
|
|
* @param serviceDictInfo
|
|
* @param model
|
|
* @param redirectAttributes
|
|
* @return
|
|
*/
|
|
@RequiresPermissions("sys:dict:edit")
|
|
@RequestMapping(value = "markSaveOrUpdate")
|
|
public String markSaveOrUpdate(ServiceDictInfo serviceDictInfo,Model model, RedirectAttributes redirectAttributes) {
|
|
|
|
try {
|
|
serviceDictInfoService.saveOrUpdate(serviceDictInfo);
|
|
addMessage(redirectAttributes, "保存配置成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
addMessage(redirectAttributes, "保存配置失败!");
|
|
}
|
|
|
|
return "redirect:" + adminPath + "/configuration/serviceDictInfo/markList";
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除
|
|
* @param serviceDictInfo
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequestMapping(value={"markDelete"})
|
|
public String markDelete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes) {
|
|
try {
|
|
serviceDictInfoService.deleteDict(serviceDictInfo);
|
|
addMessage(redirectAttributes, "删除配置成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
addMessage(redirectAttributes, "删除配置失败!");
|
|
}
|
|
return "redirect:" + adminPath + "/configuration/serviceDictInfo/markList";
|
|
}
|
|
|
|
}
|