114 lines
3.2 KiB
Plaintext
114 lines
3.2 KiB
Plaintext
|
|
package com.bonus.sys.controller;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.ui.Model;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
import org.springframework.web.servlet.ModelAndView;
|
||
|
|
|
||
|
|
import com.bonus.sys.AjaxRes;
|
||
|
|
import com.bonus.sys.BaseController;
|
||
|
|
import com.bonus.sys.GlobalConst;
|
||
|
|
import com.bonus.sys.Page;
|
||
|
|
import com.bonus.sys.beans.SysDictTypeBean;
|
||
|
|
import com.bonus.sys.beans.UserBean;
|
||
|
|
import com.bonus.sys.service.SysDictTypeService;
|
||
|
|
|
||
|
|
@Controller
|
||
|
|
@RequestMapping("/backstage/sysDictType/")
|
||
|
|
public class SysDictTypeController extends BaseController<SysDictTypeBean> {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
public SysDictTypeService service;
|
||
|
|
|
||
|
|
@RequestMapping("list")
|
||
|
|
public String index(Model model) {
|
||
|
|
return "/sys/sysDictType/dictTypeList";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("findByPage")
|
||
|
|
public String dictList(Page<SysDictTypeBean> page,SysDictTypeBean o,Model model) {
|
||
|
|
|
||
|
|
page = service.findByPage(o, page);
|
||
|
|
|
||
|
|
model.addAttribute("page", page);
|
||
|
|
|
||
|
|
return "/sys/sysDictType/dictList";
|
||
|
|
}
|
||
|
|
|
||
|
|
/*@RequiresPermissions({"idned:wqw"})*/
|
||
|
|
@RequestMapping("add")
|
||
|
|
@ResponseBody
|
||
|
|
public AjaxRes add(SysDictTypeBean o) {
|
||
|
|
AjaxRes ar = getAjaxRes();
|
||
|
|
try {
|
||
|
|
service.insert(o);
|
||
|
|
ar.setRes(GlobalConst.SUCCEED);
|
||
|
|
ar.setResMsg("保存成功!");
|
||
|
|
}catch(Exception e) {
|
||
|
|
logger.error(e.toString(), e);
|
||
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
|
|
}
|
||
|
|
return ar;
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("changeStatus")
|
||
|
|
@ResponseBody
|
||
|
|
public AjaxRes changeStatus(SysDictTypeBean o) {
|
||
|
|
AjaxRes ar = getAjaxRes();
|
||
|
|
String msgC = o.getIsActive() == 1?"启用成功":"关闭成功";
|
||
|
|
String msgF = o.getIsActive() == 1?"启用失败":"关闭失败";
|
||
|
|
try {
|
||
|
|
service.update(o);
|
||
|
|
ar.setRes(GlobalConst.SUCCEED);
|
||
|
|
ar.setResMsg(msgC);
|
||
|
|
}catch(Exception e) {
|
||
|
|
logger.error(e.toString(), e);
|
||
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
|
|
ar.setResMsg(msgF);
|
||
|
|
}
|
||
|
|
return ar;
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("batchDelete")
|
||
|
|
@ResponseBody
|
||
|
|
public AjaxRes batchDelete(String ids) {
|
||
|
|
AjaxRes ar = getAjaxRes();
|
||
|
|
try {
|
||
|
|
Map<String,List<Integer>> map = service.checkHasChild(ids);
|
||
|
|
|
||
|
|
List<Integer> noHas= map.get("noHas");
|
||
|
|
List<Integer> has = map.get("has");
|
||
|
|
|
||
|
|
if(noHas.size() > 0) {
|
||
|
|
int result = service.batchDeleteByList(noHas);
|
||
|
|
if(result > 0) {
|
||
|
|
ar.setRes(GlobalConst.SUCCEED);
|
||
|
|
ar.setResMsg("删除成功!");
|
||
|
|
}
|
||
|
|
if(has.size()>0) {
|
||
|
|
ar.setObj(has);
|
||
|
|
ar.setResMsg("部分删除成功,剩余类型正在被使用!");
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
if(has.size()>0) {
|
||
|
|
ar.setObj(has);
|
||
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
|
|
ar.setResMsg("删除失败,字典类型正在被使用!");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}catch(Exception e) {
|
||
|
|
logger.error(e.toString(), e);
|
||
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
|
|
}
|
||
|
|
return ar;
|
||
|
|
}
|
||
|
|
}
|