2018-02-22 12:46:50 +08:00
|
|
|
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.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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-01 19:13:57 +08:00
|
|
|
* 查询业务辅助表-业务字典信息列表(无条件分页查询)
|
2018-02-22 12:46:50 +08:00
|
|
|
* @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) {
|
2018-03-01 19:13:57 +08:00
|
|
|
//查出顶层分页数据
|
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findTopDictList(new Page<ServiceDictInfo>(request, response), serviceDictInfo);
|
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
//查出所有数据
|
|
|
|
|
List<ServiceDictInfo> allList = serviceDictInfoService.findAllDictList();
|
|
|
|
|
//处理数据,保留顶层中的所有下层数据
|
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
for(int i=allList.size()-1;i>=0;i--){
|
|
|
|
|
ServiceDictInfo temp = allList.get(i);
|
|
|
|
|
if(temp.getParent()!=null&&temp.getParent().getServiceDictId()!=null&&temp.getParent().getServiceDictId()==0){
|
|
|
|
|
for(ServiceDictInfo topTemp:page.getList()){
|
|
|
|
|
if(temp.getServiceDictId()==topTemp.getServiceDictId()){
|
|
|
|
|
flag = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!flag){
|
|
|
|
|
allList.remove(temp);
|
|
|
|
|
flag=false;
|
|
|
|
|
}else{
|
|
|
|
|
flag=false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
ServiceDictInfo.sortList(list,allList,0,true);
|
|
|
|
|
//ServiceDictInfo.sortList(list, allList, 0, true);
|
|
|
|
|
model.addAttribute("list", list);
|
|
|
|
|
return "/cfg/serviceDictList";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询业务辅助表-业务字典信息列表(含条件查询)
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param model
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("sys:dict:view")
|
|
|
|
|
@RequestMapping(value = {"searchList"})
|
|
|
|
|
public String searchList(ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
|
if(StringUtils.strIsBlank(serviceDictInfo.getItemValue())
|
|
|
|
|
&&serviceDictInfo.getItemCode()==null
|
|
|
|
|
&&serviceDictInfo.getItemType()==null
|
|
|
|
|
&&serviceDictInfo.getBeginDate()==null
|
|
|
|
|
&&serviceDictInfo.getEditTime()==null){
|
|
|
|
|
|
|
|
|
|
return "redirect:"+ adminPath + "/configuration/serviceDictInfo/list";
|
|
|
|
|
}
|
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findDictSearchList(new Page<ServiceDictInfo>(request, response), serviceDictInfo);
|
2018-02-22 12:46:50 +08:00
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
return "/cfg/serviceDictInfoSearchList";
|
2018-02-22 12:46:50 +08:00
|
|
|
}
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
/**
|
|
|
|
|
* 进入添加或修改页面
|
|
|
|
|
* @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";
|
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
if (serviceDictInfo.getParent() == null || serviceDictInfo.getParent().getId() == null) {
|
|
|
|
|
ServiceDictInfo parent = new ServiceDictInfo();
|
|
|
|
|
parent.setServiceDictId(0);
|
|
|
|
|
serviceDictInfo.setParent(parent);
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("serviceDictInfo", serviceDictInfo);
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
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, "保存配置失败!");
|
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
if(serviceDictInfo.getItemType()==3){
|
|
|
|
|
return "redirect:" + adminPath + "/configuration/serviceDictInfo/markList";
|
|
|
|
|
}else{
|
|
|
|
|
return "redirect:" + adminPath + "/configuration/serviceDictInfo/list";
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-01 19:13:57 +08:00
|
|
|
* 删除(删除时删除所有下级菜单)
|
2018-02-22 12:46:50 +08:00
|
|
|
* @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();
|
2018-03-01 19:13:57 +08:00
|
|
|
//找出所有的非叶子配置
|
|
|
|
|
List<ServiceDictInfo> list = serviceDictInfoService.findAllNoLeafDictList();
|
2018-02-22 12:46:50 +08:00
|
|
|
for (int i=0; i<list.size(); i++){
|
|
|
|
|
ServiceDictInfo serviceDictInfo = list.get(i);
|
|
|
|
|
if (StringUtils.isBlank(extId) || (extId !=null && !extId.equals(serviceDictInfo.getServiceDictId().toString()))) {
|
2018-03-01 19:13:57 +08:00
|
|
|
if(serviceDictInfo.getIsValid().equals(0)){
|
2018-02-22 12:46:50 +08:00
|
|
|
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";
|
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
if (serviceDictInfo.getParent() == null || serviceDictInfo.getParent().getId() == null) {
|
|
|
|
|
ServiceDictInfo parent = new ServiceDictInfo();
|
|
|
|
|
parent.setServiceDictId(0);
|
|
|
|
|
serviceDictInfo.setParent(parent);
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("serviceDictInfo", serviceDictInfo);
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
return "/cfg/serviceDictMarkForm";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-01 19:13:57 +08:00
|
|
|
* 查询标签列表(无条件分页查询)
|
2018-02-22 12:46:50 +08:00
|
|
|
* @param serviceDictInfo
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param model
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("sys:dict:view")
|
2018-03-01 19:13:57 +08:00
|
|
|
@RequestMapping(value = {"markList", ""})
|
2018-02-22 12:46:50 +08:00
|
|
|
public String markList(ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
2018-03-01 19:13:57 +08:00
|
|
|
//查出顶层分页数据
|
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findTopDictMarkList(new Page<ServiceDictInfo>(request, response), serviceDictInfo);
|
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
//查出所有数据
|
|
|
|
|
List<ServiceDictInfo> allList = serviceDictInfoService.findAllDictMarkList();
|
|
|
|
|
//处理数据,保留顶层中的所有下层数据
|
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
for(int i=allList.size()-1;i>=0;i--){
|
|
|
|
|
ServiceDictInfo temp = allList.get(i);
|
|
|
|
|
if(temp.getParent()!=null&&temp.getParent().getServiceDictId()!=null&&temp.getParent().getServiceDictId()==0){
|
|
|
|
|
for(ServiceDictInfo topTemp:page.getList()){
|
|
|
|
|
if(temp.getServiceDictId()==topTemp.getServiceDictId()){
|
|
|
|
|
flag = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!flag){
|
|
|
|
|
allList.remove(temp);
|
|
|
|
|
flag=false;
|
|
|
|
|
}else{
|
|
|
|
|
flag=false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
ServiceDictInfo.sortList(list,allList,0,true);
|
|
|
|
|
//ServiceDictInfo.sortList(list, allList, 0, true);
|
|
|
|
|
model.addAttribute("list", list);
|
|
|
|
|
return "/cfg/serviceDictMarkList";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询业务辅助表-业务字典信息列表(含条件查询)
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param model
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("sys:dict:view")
|
|
|
|
|
@RequestMapping(value = {"searchMarkList"})
|
|
|
|
|
public String searchMarkList(ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
|
if(StringUtils.strIsBlank(serviceDictInfo.getItemValue())
|
|
|
|
|
&&serviceDictInfo.getItemCode()==null
|
|
|
|
|
&&serviceDictInfo.getItemType()==null
|
|
|
|
|
&&serviceDictInfo.getBeginDate()==null
|
|
|
|
|
&&serviceDictInfo.getEditTime()==null){
|
|
|
|
|
|
|
|
|
|
return "redirect:"+ adminPath + "/configuration/serviceDictInfo/markList";
|
|
|
|
|
}
|
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findDictSearchMarkList(new Page<ServiceDictInfo>(request, response), serviceDictInfo);
|
2018-02-22 12:46:50 +08:00
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
return "/cfg/serviceDictInfoSearchMarkList";
|
2018-02-22 12:46:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
/**
|
|
|
|
|
* 新增或修改
|
|
|
|
|
* @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";
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
/**
|
|
|
|
|
* isShowHide是否显示隐藏菜单
|
|
|
|
|
* @param extId
|
|
|
|
|
* @param isShowHidden
|
|
|
|
|
* @param response
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("user")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "treeMarkData")
|
|
|
|
|
public List<Map<String, Object>> treeMarkData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide, HttpServletResponse response) {
|
|
|
|
|
List<Map<String, Object>> mapList = Lists.newArrayList();
|
|
|
|
|
//找出所有的非叶子配置
|
|
|
|
|
List<ServiceDictInfo> list = serviceDictInfoService.findAllNoLeafDictMarkList();
|
|
|
|
|
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(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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
}
|