132 lines
3.7 KiB
Java
132 lines
3.7 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.configuration.SysDictInfo;
|
||
|
|
import com.nis.util.StringUtil;
|
||
|
|
import com.nis.util.StringUtils;
|
||
|
|
import com.nis.web.controller.BaseController;
|
||
|
|
|
||
|
|
@Controller
|
||
|
|
@RequestMapping(value = "${adminPath}/configuration/sysDictInfo")
|
||
|
|
public class SysDictInfoController extends BaseController {
|
||
|
|
|
||
|
|
|
||
|
|
@ModelAttribute
|
||
|
|
public SysDictInfo get(@RequestParam(required=false) Integer sysDictId) {
|
||
|
|
if (!StringUtil.isEmpty(sysDictId)){
|
||
|
|
return sysDictInfoService.getDictById(sysDictId);
|
||
|
|
}else{
|
||
|
|
return new SysDictInfo();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 根据sysDictId查出配置对象
|
||
|
|
* @param sysDictId
|
||
|
|
* @param request
|
||
|
|
* @param response
|
||
|
|
* @param model
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@ResponseBody
|
||
|
|
@RequestMapping(value = "loadDataDict")
|
||
|
|
public SysDictInfo loadDataDict(@RequestParam(required=false) Integer sysDictId,HttpServletRequest request, HttpServletResponse response, Model model){
|
||
|
|
|
||
|
|
return sysDictInfoService.getDictById(sysDictId);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询业务辅助表-生效范围系统字典信息列表
|
||
|
|
* @param sysDictInfo
|
||
|
|
* @param request
|
||
|
|
* @param response
|
||
|
|
* @param model
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequiresPermissions("sys:dict:view")
|
||
|
|
@RequestMapping(value = {"list", ""})
|
||
|
|
public String list(SysDictInfo sysDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
||
|
|
|
||
|
|
Page<SysDictInfo> page = sysDictInfoService.findDictList(new Page<SysDictInfo>(request, response), sysDictInfo);
|
||
|
|
model.addAttribute("page", page);
|
||
|
|
|
||
|
|
return "/cfg/sysDictList";
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 进入添加或修改页面
|
||
|
|
* @param sysDictInfo
|
||
|
|
* @param model
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequestMapping(value={"form"})
|
||
|
|
public String form(SysDictInfo sysDictInfo, Model model,String doAction) {
|
||
|
|
if(doAction!=null&&doAction.equals("0")){
|
||
|
|
return "/cfg/sysDictInfo";
|
||
|
|
}
|
||
|
|
return "/cfg/sysDictForm";
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 新增或修改
|
||
|
|
* @param sysDictInfo
|
||
|
|
* @param model
|
||
|
|
* @param redirectAttributes
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequiresPermissions("sys:dict:edit")
|
||
|
|
@RequestMapping(value = "saveOrUpdate")
|
||
|
|
public String saveOrUpdate(SysDictInfo sysDictInfo,Model model, RedirectAttributes redirectAttributes) {
|
||
|
|
|
||
|
|
try {
|
||
|
|
sysDictInfoService.saveOrUpdate(sysDictInfo);
|
||
|
|
addMessage(redirectAttributes, "保存配置成功");
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
addMessage(redirectAttributes, "保存配置失败!");
|
||
|
|
}
|
||
|
|
|
||
|
|
return "redirect:" + adminPath + "/configuration/sysDictInfo/list";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 删除
|
||
|
|
* @param sysDictInfo
|
||
|
|
* @param model
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequestMapping(value={"delete"})
|
||
|
|
public String delete(SysDictInfo sysDictInfo, RedirectAttributes redirectAttributes) {
|
||
|
|
try {
|
||
|
|
sysDictInfoService.deleteDict(sysDictInfo);
|
||
|
|
addMessage(redirectAttributes, "删除配置成功");
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
addMessage(redirectAttributes, "删除配置失败!");
|
||
|
|
}
|
||
|
|
return "redirect:" + adminPath + "/configuration/sysDictInfo/list";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|