| | |
| | | package com.stylefeng.guns.modular.code.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.common.annotion.BussinessLog; |
| | | import com.stylefeng.guns.core.common.constant.dictmap.DeptDict; |
| | | import com.stylefeng.guns.core.common.constant.factory.ConstantFactory; |
| | |
| | | import com.stylefeng.guns.core.node.ZTreeNode; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.Dept; |
| | | import com.stylefeng.guns.modular.system.model.User; |
| | | import com.stylefeng.guns.modular.system.service.IDeptService; |
| | | import com.stylefeng.guns.modular.system.service.IUserService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.DeptWarpper; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @GetMapping(value = "/list") |
| | | @ApiOperation(value = "列表", tags = {"后台-部门管理"}) |
| | | @ResponseBody |
| | | public Object list(String name) { |
| | | List<Map<String, Object>> list = this.deptService.list(name); |
| | | public Object list(String fullname) { |
| | | List<Map<String, Object>> list = this.deptService.list(fullname); |
| | | return list; |
| | | } |
| | | |
| | |
| | | throw new GunsException(BizExceptionEnum.REQUEST_NULL); |
| | | } |
| | | //完善pids,根据pid拿到pid的pids |
| | | dept.setPid(0); |
| | | deptSetPids(dept); |
| | | this.deptService.insert(dept); |
| | | return ResultUtil.success("添加成功"); |
| | |
| | | |
| | | @DataSource(name = "dataSourceBiz") |
| | | @GetMapping(value = "/tree") |
| | | @ApiOperation(value = "获取部门树", tags = {"后台-部门管理"}) |
| | | @ApiOperation(value = "获取部下拉框", tags = {"后台-部门管理"}) |
| | | @ResponseBody |
| | | public List<ZTreeNode> tree() { |
| | | public List<Dept> tree() { |
| | | List<ZTreeNode> tree = this.deptService.tree(); |
| | | tree.add(ZTreeNode.createParent()); |
| | | return tree; |
| | | |
| | | return deptService.selectList(null); |
| | | // return tree; |
| | | } |
| | | @Autowired |
| | | private IUserService userService; |
| | | @DeleteMapping ("/delete") |
| | | @ResponseBody |
| | | @ApiOperation(value = "删除部门", tags = {"后台-部门管理"}) |
| | | public ResultUtil delete(String ids) { |
| | | String[] split = ids.split(","); |
| | | for (String id : split) { |
| | | List<User> users = userService.selectList(new EntityWrapper<User>().eq("deptid",Integer.valueOf(id))); |
| | | if (!users.isEmpty()){ |
| | | return ResultUtil.error("当前部门已绑定用户,无法删除"); |
| | | } |
| | | deptService.deleteById(Integer.valueOf(id)); |
| | | |
| | | } |
| | | return ResultUtil.success("删除成功"); |
| | | } |
| | | |
| | | @DataSource(name = "dataSourceBiz") |
| | | @GetMapping ("pre/edit/{deptId}") |
| | | public Dept deptUpdate(@PathVariable Integer deptId, Model model) { |
| | | Dept dept = deptService.selectById(deptId); |
| | | return dept; |
| | | return dept; |
| | | } |
| | | |
| | | |
| | |
| | | if (ToolUtil.isEmpty(dept) || dept.getId() == null) { |
| | | throw new GunsException(BizExceptionEnum.REQUEST_NULL); |
| | | } |
| | | dept.setPid(0); |
| | | deptSetPids(dept); |
| | | Dept dept1 = deptService.selectById(dept.getId()); |
| | | deptService.updateById(dept); |