diff --git a/ruoyi-vip/src/main/java/com/ruoyi/vip/controller/VipDeptController.java b/ruoyi-vip/src/main/java/com/ruoyi/vip/controller/VipDeptController.java deleted file mode 100644 index 5b514e827..000000000 --- a/ruoyi-vip/src/main/java/com/ruoyi/vip/controller/VipDeptController.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.ruoyi.vip.controller; - -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.base.AjaxResult; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.base.BaseController; -import com.ruoyi.framework.web.util.ShiroUtils; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.vip.domain.VipDept; -import com.ruoyi.vip.service.IVipDeptService; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; - -/** - * 部门信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/vip/dept") -public class VipDeptController extends BaseController -{ - private String prefix = "vip/dept"; - - @Autowired - private IVipDeptService deptService; - - @RequiresPermissions("vip:dept:view") - @GetMapping() - public String dept() - { - return prefix + "/dept"; - } - - @RequiresPermissions("vip:dept:list") - @GetMapping("/list") - @ResponseBody - public List list(VipDept dept) - { - List deptList = deptService.selectDeptList(dept); - return deptList; - } - - /** - * 新增部门 - */ - @GetMapping("/add/{parentId}") - public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) - { - mmap.put("dept", deptService.selectDeptById(parentId)); - return prefix + "/add"; - } - - /** - * 新增保存部门 - */ - @Log(title = "部门管理", businessType = BusinessType.INSERT) - @RequiresPermissions("vip:dept:add") - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(VipDept dept) - { - dept.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(deptService.insertDept(dept)); - } - - /** - * 修改 - */ - @GetMapping("/edit/{deptId}") - public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) - { - VipDept dept = deptService.selectDeptById(deptId); - if (StringUtils.isNotNull(dept) && 100L == deptId) - { - dept.setParentName("无"); - } - mmap.put("dept", dept); - return prefix + "/edit"; - } - - /** - * 保存 - */ - @Log(title = "部门管理", businessType = BusinessType.UPDATE) - @RequiresPermissions("vip:dept:edit") - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(VipDept dept) - { - dept.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(deptService.updateDept(dept)); - } - - /** - * 删除 - */ - @Log(title = "部门管理", businessType = BusinessType.DELETE) - @RequiresPermissions("vip:dept:remove") - @PostMapping("/remove/{deptId}") - @ResponseBody - public AjaxResult remove(@PathVariable("deptId") Long deptId) - { - if (deptService.selectDeptCount(deptId) > 0) - { - return error(1, "存在下级部门,不允许删除"); - } - if (deptService.checkDeptExistUser(deptId)) - { - return error(1, "部门存在用户,不允许删除"); - } - return toAjax(deptService.deleteDeptById(deptId)); - } - - /** - * 校验部门名称 - */ - @PostMapping("/checkDeptNameUnique") - @ResponseBody - public String checkDeptNameUnique(VipDept dept) - { - return deptService.checkDeptNameUnique(dept); - } - - /** - * 选择部门树 - */ - @GetMapping("/selectDeptTree/{deptId}") - public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap) - { - mmap.put("dept", deptService.selectDeptById(deptId)); - return prefix + "/tree"; - } - - /** - * 加载部门列表树 - */ - @GetMapping("/treeData") - @ResponseBody - public List> treeData() - { - List> tree = deptService.selectDeptTree(); - return tree; - } - -} diff --git a/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipDept.java b/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipDept.java deleted file mode 100644 index abe4f9a26..000000000 --- a/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipDept.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.ruoyi.vip.domain; - -import com.ruoyi.common.base.BaseEntity; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -import javax.persistence.Id; - -/** - * 部门表 sys_dept - * - * @author ruoyi - */ -public class VipDept extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 部门ID */ - @Id - private Long deptId; - - /** 父部门ID */ - private Long parentId; - - /** 祖级列表 */ - private String parentIds; - - /** 部门名称 */ - private String deptName; - - /** 显示顺序 */ - private String orderNum; - - /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; - - /** 父部门名称 */ - private String parentName; - - public Long getDeptId() - { - return deptId; - } - - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - public Long getParentId() - { - return parentId; - } - - public void setParentId(Long parentId) - { - this.parentId = parentId; - } - - public String getParentIds() { - return parentIds; - } - - public void setParentIds(String parentIds) { - this.parentIds = parentIds; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public String getOrderNum() - { - return orderNum; - } - - public void setOrderNum(String orderNum) - { - this.orderNum = orderNum; - } - - - public String getDelFlag() - { - return delFlag; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getParentName() - { - return parentName; - } - - public void setParentName(String parentName) - { - this.parentName = parentName; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("deptId", getDeptId()) - .append("parentId", getParentId()) - .append("ancestors", getParentIds()) - .append("deptName", getDeptName()) - .append("orderNum", getOrderNum()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } -} diff --git a/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipUser.java b/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipUser.java index 36113b280..3e0512f6e 100644 --- a/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipUser.java +++ b/ruoyi-vip/src/main/java/com/ruoyi/vip/domain/VipUser.java @@ -2,6 +2,7 @@ package com.ruoyi.vip.domain; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.base.BaseEntity; +import com.ruoyi.system.domain.SysDept; import com.ruoyi.system.domain.SysRole; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -75,7 +76,7 @@ public class VipUser extends BaseEntity private Date loginDate; /** 部门对象 */ - private VipDept dept; + private SysDept dept; public Long getId() { @@ -226,12 +227,12 @@ public class VipUser extends BaseEntity this.loginDate = loginDate; } - public VipDept getDept() + public SysDept getDept() { return dept; } - public void setDept(VipDept dept) + public void setDept(SysDept dept) { this.dept = dept; } diff --git a/ruoyi-vip/src/main/java/com/ruoyi/vip/mapper/VipDeptMapper.java b/ruoyi-vip/src/main/java/com/ruoyi/vip/mapper/VipDeptMapper.java deleted file mode 100644 index e07683f21..000000000 --- a/ruoyi-vip/src/main/java/com/ruoyi/vip/mapper/VipDeptMapper.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.ruoyi.vip.mapper; - -import com.ruoyi.framework.web.base.MyMapper; -import com.ruoyi.vip.domain.VipDept; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 部门管理 数据层 - * - * @author ruoyi - */ -public interface VipDeptMapper extends MyMapper -{ - /** - * 查询部门人数 - * - * @param dept 部门信息 - * @return 结果 - */ - public int selectDeptCount(VipDept dept); - - /** - * 查询部门是否存在用户 - * - * @param deptId 部门ID - * @return 结果 - */ - public int checkDeptExistUser(Long deptId); - - /** - * 查询部门管理数据 - * - * @param dept 部门信息 - * @return 部门信息集合 - */ - public List selectDeptList(VipDept dept); - - /** - * 删除部门管理信息 - * - * @param deptId 部门ID - * @return 结果 - */ - public int deleteDeptById(Long deptId); - - /** - * 新增部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int insertDept(VipDept dept); - - /** - * 修改部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int updateDept(VipDept dept); - - /** - * 修改子元素关系 - * - * @param depts 子元素 - * @return 结果 - */ - public int updateDeptChildren(@Param("depts") List depts); - - /** - * 根据部门ID查询信息 - * - * @param deptId 部门ID - * @return 部门信息 - */ - public VipDept selectDeptById(Long deptId); - - /** - * 校验部门名称是否唯一 - * - * @param deptName 部门名称 - * @param parentId 父部门ID - * @return 结果 - */ - public VipDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); - - /** - * 根据角色ID查询部门 - * - * @param roleId 角色ID - * @return 部门列表 - */ - public List selectRoleDeptTree(Long roleId); -} diff --git a/ruoyi-vip/src/main/java/com/ruoyi/vip/service/IVipDeptService.java b/ruoyi-vip/src/main/java/com/ruoyi/vip/service/IVipDeptService.java deleted file mode 100644 index 94167699b..000000000 --- a/ruoyi-vip/src/main/java/com/ruoyi/vip/service/IVipDeptService.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.ruoyi.vip.service; - -import com.ruoyi.framework.web.base.AbstractBaseService; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.vip.domain.VipDept; - -import java.util.List; -import java.util.Map; - -/** - * 部门管理 服务层 - * - * @author ruoyi - */ -public interface IVipDeptService extends AbstractBaseService -{ - /** - * 查询部门管理数据 - * - * @param dept 部门信息 - * @return 部门信息集合 - */ - public List selectDeptList(VipDept dept); - - /** - * 查询部门管理树 - * - * @return 所有部门信息 - */ - public List> selectDeptTree(); - - - - /** - * 查询部门人数 - * - * @param parentId 父部门ID - * @return 结果 - */ - public int selectDeptCount(Long parentId); - - /** - * 查询部门是否存在用户 - * - * @param deptId 部门ID - * @return 结果 true 存在 false 不存在 - */ - public boolean checkDeptExistUser(Long deptId); - - /** - * 删除部门管理信息 - * - * @param deptId 部门ID - * @return 结果 - */ - public int deleteDeptById(Long deptId); - - /** - * 新增保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int insertDept(VipDept dept); - - /** - * 修改保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int updateDept(VipDept dept); - - /** - * 根据部门ID查询信息 - * - * @param deptId 部门ID - * @return 部门信息 - */ - public VipDept selectDeptById(Long deptId); - - /** - * 校验部门名称是否唯一 - * - * @param dept 部门信息 - * @return 结果 - */ - public String checkDeptNameUnique(VipDept dept); -} diff --git a/ruoyi-vip/src/main/java/com/ruoyi/vip/service/impl/VipDeptServiceImpl.java b/ruoyi-vip/src/main/java/com/ruoyi/vip/service/impl/VipDeptServiceImpl.java deleted file mode 100644 index 9fdea5dcc..000000000 --- a/ruoyi-vip/src/main/java/com/ruoyi/vip/service/impl/VipDeptServiceImpl.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.ruoyi.vip.service.impl; - -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.base.AbstractBaseServiceImpl; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.vip.domain.VipDept; -import com.ruoyi.vip.mapper.VipDeptMapper; -import com.ruoyi.vip.service.IVipDeptService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 部门管理 服务实现 - * - * @author ruoyi - */ -@Service -public class VipDeptServiceImpl extends AbstractBaseServiceImpl implements IVipDeptService { - @Autowired - private VipDeptMapper deptMapper; - - /** - * 查询部门管理数据 - * - * @return 部门信息集合 - */ - @Override - @DataScope(tableAlias = "d") - public List selectDeptList(VipDept dept) { - return mapper.selectDeptList( dept ); - } - - /** - * 查询部门管理树 - * - * @return 所有部门信息 - */ - @Override - public List> selectDeptTree() { - List> trees = new ArrayList>(); - List deptList = selectDeptList( new VipDept() ); - trees = getTrees( deptList, false, null ); - return trees; - } - - - /** - * 对象转部门树 - * - * @param deptList 部门列表 - * @param isCheck 是否需要选中 - * @param roleDeptList 角色已存在菜单列表 - * @return - */ - public List> getTrees(List deptList, boolean isCheck, List roleDeptList) { - - List> trees = new ArrayList>(); - for (VipDept dept : deptList) { - if (UserConstants.DEPT_NORMAL.equals( dept.getDelFlag() )) { - Map deptMap = new HashMap(); - deptMap.put( "id", dept.getDeptId() ); - deptMap.put( "pId", dept.getParentId() ); - deptMap.put( "name", dept.getDeptName() ); - deptMap.put( "title", dept.getDeptName() ); - if (isCheck) { - deptMap.put( "checked", roleDeptList.contains( dept.getDeptId() + dept.getDeptName() ) ); - } else { - deptMap.put( "checked", false ); - } - trees.add( deptMap ); - } - } - return trees; - } - - /** - * 查询部门人数 - * - * @param parentId 部门ID - * @return 结果 - */ - @Override - public int selectDeptCount(Long parentId) { - VipDept dept = new VipDept(); - dept.setParentId( parentId ); - return deptMapper.selectDeptCount( dept ); - } - - /** - * 查询部门是否存在用户 - * - * @param deptId 部门ID - * @return 结果 true 存在 false 不存在 - */ - @Override - public boolean checkDeptExistUser(Long deptId) { - int result = deptMapper.checkDeptExistUser( deptId ); - return result > 0 ? true : false; - } - - /** - * 删除部门管理信息 - * - * @param deptId 部门ID - * @return 结果 - */ - @Override - public int deleteDeptById(Long deptId) { - return deptMapper.deleteDeptById( deptId ); - } - - /** - * 新增保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - @Override - public int insertDept(VipDept dept) { - VipDept info = deptMapper.selectDeptById( dept.getParentId() ); - dept.setParentIds( info.getParentIds() + "," + dept.getParentId() ); - return deptMapper.insertDept( dept ); - } - - /** - * 修改保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - @Override - public int updateDept(VipDept dept) { - VipDept info = deptMapper.selectDeptById( dept.getParentId() ); - if (StringUtils.isNotNull( info )) { - String ancestors = info.getParentIds() + "," + dept.getParentId(); - dept.setParentIds( ancestors ); - updateDeptChildren( dept.getDeptId(), ancestors ); - } - return deptMapper.updateDept( dept ); - } - - /** - * 修改子元素关系 - * - * @param deptId 部门ID - * @param ancestors 元素列表 - */ - public void updateDeptChildren(Long deptId, String ancestors) { - VipDept dept = new VipDept(); - dept.setParentId( deptId ); - List childrens = deptMapper.selectDeptList( dept ); - for (VipDept children : childrens) { - children.setParentIds( ancestors + "," + dept.getParentId() ); - } - if (childrens.size() > 0) { - deptMapper.updateDeptChildren( childrens ); - } - } - - /** - * 根据部门ID查询信息 - * - * @param deptId 部门ID - * @return 部门信息 - */ - @Override - public VipDept selectDeptById(Long deptId) { - return deptMapper.selectDeptById( deptId ); - } - - /** - * 校验部门名称是否唯一 - * - * @param dept 部门信息 - * @return 结果 - */ - @Override - public String checkDeptNameUnique(VipDept dept) { - Long deptId = StringUtils.isNull( dept.getDeptId() ) ? -1L : dept.getDeptId(); - VipDept info = deptMapper.checkDeptNameUnique( dept.getDeptName(), dept.getParentId() ); - if (StringUtils.isNotNull( info ) && info.getDeptId().longValue() != deptId.longValue()) { - return UserConstants.DEPT_NAME_NOT_UNIQUE; - } - return UserConstants.DEPT_NAME_UNIQUE; - } -} diff --git a/ruoyi-vip/src/main/resources/mapper/vip/SysDeptMapper.xml b/ruoyi-vip/src/main/resources/mapper/vip/SysDeptMapper.xml deleted file mode 100644 index 6d2b107a9..000000000 --- a/ruoyi-vip/src/main/resources/mapper/vip/SysDeptMapper.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - select d.dept_id, d.parent_id, d.parent_ids, d.dept_name, d.order_num, d.del_flag, d.create_by, d.create_time - from vip_dept d - - - - - - - - - - - - - - - insert into vip_dept( - dept_id, - parent_id, - dept_name, - parent_ids, - order_num, - - create_by, - create_time - )values( - #{deptId}, - #{parentId}, - #{deptName}, - #{parentIds}, - #{orderNum}, - - #{createBy}, - sysdate() - ) - - - - update vip_dept - - parent_id = #{parentId}, - dept_name = #{deptName}, - parent_ids = #{parentIds}, - order_num = #{orderNum}, - - update_by = #{updateBy}, - update_time = sysdate() - - where dept_id = #{deptId} - - - - update vip_dept set parent_ids = - - when #{item.deptId} then #{item.parent_ids} - - where dept_id in - - #{item.deptId} - - - - - update vip_dept set del_flag = '2' where dept_id = #{deptId} - - - \ No newline at end of file diff --git a/ruoyi-vip/src/main/resources/mapper/vip/SysUserMapper.xml b/ruoyi-vip/src/main/resources/mapper/vip/SysUserMapper.xml index e8113a460..75e82d23f 100644 --- a/ruoyi-vip/src/main/resources/mapper/vip/SysUserMapper.xml +++ b/ruoyi-vip/src/main/resources/mapper/vip/SysUserMapper.xml @@ -24,10 +24,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + diff --git a/ruoyi-vip/src/main/resources/templates/vip/dept/add.html b/ruoyi-vip/src/main/resources/templates/vip/dept/add.html deleted file mode 100644 index 87c4ca132..000000000 --- a/ruoyi-vip/src/main/resources/templates/vip/dept/add.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - -
-
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
-
-
-
-
- - - diff --git a/ruoyi-vip/src/main/resources/templates/vip/dept/dept.html b/ruoyi-vip/src/main/resources/templates/vip/dept/dept.html deleted file mode 100644 index cafc36472..000000000 --- a/ruoyi-vip/src/main/resources/templates/vip/dept/dept.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - -
-
-
-
-
- -
-
-
- - -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/ruoyi-vip/src/main/resources/templates/vip/dept/edit.html b/ruoyi-vip/src/main/resources/templates/vip/dept/edit.html deleted file mode 100644 index 93ff8c1c4..000000000 --- a/ruoyi-vip/src/main/resources/templates/vip/dept/edit.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - -
-
- - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
-
-
-
-
- - - diff --git a/ruoyi-vip/src/main/resources/templates/vip/dept/tree.html b/ruoyi-vip/src/main/resources/templates/vip/dept/tree.html deleted file mode 100644 index 4ea5a3119..000000000 --- a/ruoyi-vip/src/main/resources/templates/vip/dept/tree.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - -
- - -
- -
- 展开 / - 折叠 -
-
-
-
- - - -