ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysDept.java
@@ -1,14 +1,16 @@ package com.ruoyi.system.api.domain.poji.sys; import java.util.ArrayList; import java.util.List; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.web.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.web.domain.BaseEntity; import java.util.ArrayList; import java.util.List; /** * 部门表 sys_dept @@ -52,8 +54,15 @@ /** 父部门名称 */ private String parentName; /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") private String dataScope; /** 子部门 */ private List<SysDept> children = new ArrayList<SysDept>(); /** 菜单组 */ private Long[] menuIds; public Long getDeptId() { @@ -181,6 +190,22 @@ this.children = children; } public String getDataScope() { return dataScope; } public void setDataScope(String dataScope) { this.dataScope = dataScope; } public Long[] getMenuIds() { return menuIds; } public void setMenuIds(Long[] menuIds) { this.menuIds = menuIds; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -198,6 +223,7 @@ .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("dataScope", getDataScope()) .toString(); } } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysUser.java
@@ -1,19 +1,21 @@ package com.ruoyi.system.api.domain.poji.sys; import java.util.Date; import java.util.List; import javax.validation.constraints.*; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel.ColumnType; import com.ruoyi.common.core.annotation.Excel.Type; import com.ruoyi.common.core.annotation.Excels; import com.ruoyi.common.core.web.domain.BaseEntity; import com.ruoyi.common.core.xss.Xss; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import java.util.Date; import java.util.List; /** * 用户对象 sys_user @@ -96,6 +98,10 @@ /** 角色ID */ private Long roleId; /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") private String dataScope; public SysUser() { @@ -313,6 +319,14 @@ this.userType = userType; } public String getDataScope() { return dataScope; } public void setDataScope(String dataScope) { this.dataScope = dataScope; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -336,6 +350,7 @@ .append("remark", getRemark()) .append("dept", getDept()) .append("userType", getUserType()) .append("dataScope", getDataScope()) .toString(); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java
@@ -5,6 +5,7 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; import com.ruoyi.system.domain.dto.MgtReplayStaffSuggestDto; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.dto.MgtStaffSuggestPageDto; import com.ruoyi.system.domain.dto.MgtTagStaffSuggestDto; import com.ruoyi.system.domain.vo.MgtDeptStaffListVo; @@ -86,4 +87,22 @@ staffSuggestService.mgtEditStaffSuggestTag(mgtTagStaffSuggestDto); return R.ok(); } @RequestMapping(value = "/mgtEditStaff", method = RequestMethod.POST) @ApiOperation(value = "平台编辑员工") public R mgtEditStaff(@RequestBody MgtStaffEditDto mgtStaffEditDto) { Long userId = SecurityUtils.getUserId(); mgtStaffEditDto.setUserId(userId); sysStaffService.mgtStaffEdit(mgtStaffEditDto); return R.ok(); } @RequestMapping(value = "/mgtDeleteStaff", method = RequestMethod.POST) @ApiOperation(value = "平台编辑员工") public R mgtStaffEdit(@RequestBody MgtBaseGetDto mgtBaseGetDto) { Long userId = SecurityUtils.getUserId(); mgtBaseGetDto.setUserId(userId); sysStaffService.mgtDeleteStaff(mgtBaseGetDto); return R.ok(); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/sys/SysDeptController.java
@@ -1,17 +1,5 @@ package com.ruoyi.system.controller.sys; import java.util.List; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.controller.BaseController; @@ -22,6 +10,12 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.poji.sys.SysDept; import com.ruoyi.system.service.sys.ISysDeptService; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 部门信息 @@ -130,4 +124,6 @@ deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/sys/SysMenuController.java
@@ -1,16 +1,5 @@ package com.ruoyi.system.controller.sys; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.controller.BaseController; @@ -21,6 +10,12 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.domain.pojo.sys.SysMenu; import com.ruoyi.system.service.sys.ISysMenuService; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 菜单信息 @@ -67,6 +62,7 @@ return success(menuService.buildMenuTreeSelect(menus)); } /** * 加载对应角色菜单列表树 */ @@ -81,6 +77,32 @@ return ajax; } @ApiOperation(value = "加载对应部门菜单列表树") @GetMapping(value = "/roleMenuTreeselect/{deptId}") public AjaxResult deptMenuTreeselect(@PathVariable("deptId") Long deptId) { Long userId = SecurityUtils.getUserId(); List<SysMenu> menus = menuService.selectMenuList(userId); AjaxResult ajax = AjaxResult.success(); ajax.put("checkedKeys", menuService.selectMenuListByDeptId(deptId)); ajax.put("menus", menuService.buildMenuTreeSelect(menus)); return ajax; } @ApiOperation(value = "加载对应部门用户菜单列表树") @GetMapping(value = "/deptUserMenuTreeselect/{deptUserId}") public AjaxResult deptUserMenuTreeselect(@PathVariable("deptUserId") Long deptUserId) { Long userId = SecurityUtils.getUserId(); List<SysMenu> menus = menuService.selectMenuList(userId); AjaxResult ajax = AjaxResult.success(); ajax.put("checkedKeys", menuService.selectMenuListByDeptUserId(deptUserId)); ajax.put("menus", menuService.buildMenuTreeSelect(menus)); return ajax; } /** * 新增菜单 */ ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtStaffEditDto.java
New file @@ -0,0 +1,56 @@ package com.ruoyi.system.domain.dto; import com.ruoyi.system.api.domain.dto.MgtBaseDto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author jqs34 * @version 1.0 * @classname MgtStaffEditDto * @description: TODO * @date 2023 2023/6/18 20:52 */ @Data public class MgtStaffEditDto extends MgtBaseDto { @ApiModelProperty(value = "部门id") private Long deptId; /** * 用户id */ @ApiModelProperty(value = "用户id 新增不传") private Long userId; /** * 员工姓名 */ @ApiModelProperty(value = "员工姓名") private String staffName; /** * 员工电话 */ @ApiModelProperty(value = "员工电话") private String staffMobile; /** * 员工邮箱 */ @ApiModelProperty(value = "员工邮箱") private String staffEmail; /** * 员工职位 */ @ApiModelProperty(value = "员工职位") private String staffPost; /** * 员工头像 */ @ApiModelProperty(value = "员工头像") private String staffAvatar; /** * 负责人标记 */ @ApiModelProperty(value = "负责人标记") private String headFlag; } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java
@@ -40,7 +40,7 @@ * 用户id */ @TableField("user_id") private Integer userId; private Long userId; /** * 员工姓名 */ @@ -51,7 +51,26 @@ */ @TableField("staff_mobile") private String staffMobile; /** * 员工邮箱 */ @TableField("staff_email") private String staffEmail; /** * 员工职位 */ @TableField("staff_post") private String staffPost; /** * 员工头像 */ @TableField("staff_avatar") private String staffAvatar; /** * 负责人标记 */ @TableField("head_flag") private String headFlag; @Override protected Serializable pkVal() { ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/sys/SysDeptMenu.java
New file @@ -0,0 +1,46 @@ package com.ruoyi.system.domain.pojo.sys; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; /** * 角色和菜单关联 sys_dept_menu * * @author jqs */ public class SysDeptMenu { /** 角色ID */ private Long deptId; /** 菜单ID */ private Long menuId; public Long getDeptId() { return deptId; } public void setDeptId(Long deptId) { this.deptId = deptId; } public Long getMenuId() { return menuId; } public void setMenuId(Long menuId) { this.menuId = menuId; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("deptId", getDeptId()) .append("menuId", getMenuId()) .toString(); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/sys/SysUserMenu.java
New file @@ -0,0 +1,46 @@ package com.ruoyi.system.domain.pojo.sys; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; /** * 角色和菜单关联 sys_user_menu * * @author jqs */ public class SysUserMenu { /** 角色ID */ private Long userId; /** 菜单ID */ private Long menuId; public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public Long getMenuId() { return menuId; } public void setMenuId(Long menuId) { this.menuId = menuId; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("userId", getUserId()) .append("menuId", getMenuId()) .toString(); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysDeptMenuMapper.java
New file @@ -0,0 +1,45 @@ package com.ruoyi.system.mapper.sys; import com.ruoyi.system.domain.pojo.sys.SysDeptMenu; import java.util.List; /** * 角色与菜单关联表 数据层 * * @author jqs */ public interface SysDeptMenuMapper { /** * 查询菜单使用数量 * * @param menuId 菜单ID * @return 结果 */ public int checkMenuExistDept(Long menuId); /** * 通过角色ID删除角色和菜单关联 * * @param deptId 角色ID * @return 结果 */ public int deleteDeptMenuByDeptId(Long deptId); /** * 批量删除角色菜单关联信息 * * @param ids 需要删除的数据ID * @return 结果 */ public int deleteDeptMenu(Long[] ids); /** * 批量新增角色菜单信息 * * @param deptMenuList 角色菜单列表 * @return 结果 */ public int batchDeptMenu(List<SysDeptMenu> deptMenuList); } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysMenuMapper.java
@@ -1,8 +1,9 @@ package com.ruoyi.system.mapper.sys; import java.util.List; import org.apache.ibatis.annotations.Param; import com.ruoyi.system.domain.pojo.sys.SysMenu; import org.apache.ibatis.annotations.Param; import java.util.List; /** * 菜单表 数据层 @@ -75,6 +76,24 @@ public List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); /** * @description selectMenuListByDeptId * @param deptId * @return List<SysMenu> * @author jqs34 * @date 2023/6/18 19:13 */ public List<Long> selectMenuListByDeptId(@Param("deptId") Long deptId, @Param("menuCheckStrictly") boolean menuCheckStrictly); /** * @description selectMenuListByDeptUserId * @param deptUserId * @return List<SysMenu> * @author jqs34 * @date 2023/6/18 19:13 */ public List<Long> selectMenuListByDeptUserId(@Param("deptUserId") Long deptUserId, @Param("menuCheckStrictly") boolean menuCheckStrictly); /** * 根据菜单ID查询信息 * * @param menuId 菜单ID ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysUserMenuMapper.java
New file @@ -0,0 +1,45 @@ package com.ruoyi.system.mapper.sys; import com.ruoyi.system.domain.pojo.sys.SysUserMenu; import java.util.List; /** * 角色与菜单关联表 数据层 * * @author jqs */ public interface SysUserMenuMapper { /** * 查询菜单使用数量 * * @param menuId 菜单ID * @return 结果 */ public int checkMenuExistUser(Long menuId); /** * 通过角色ID删除角色和菜单关联 * * @param userId 角色ID * @return 结果 */ public int deleteUserMenuByUserId(Long userId); /** * 批量删除角色菜单关联信息 * * @param ids 需要删除的数据ID * @return 结果 */ public int deleteUserMenu(Long[] ids); /** * 批量新增角色菜单信息 * * @param userMenuList 角色菜单列表 * @return 结果 */ public int batchUserMenu(List<SysUserMenu> userMenuList); } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java
@@ -1,10 +1,17 @@ package com.ruoyi.system.service.impl.staff; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.utils.uuid.IdUtils; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; import com.ruoyi.system.domain.vo.MgtDeptStaffListVo; import com.ruoyi.system.mapper.staff.SysStaffMapper; import com.ruoyi.system.service.staff.SysStaffService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.service.sys.ISysUserService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -24,6 +31,9 @@ @Resource private SysStaffMapper sysStaffMapper; @Resource private ISysUserService sysUserService; /** * @description 获取部门员工列表 * @author jqs @@ -35,4 +45,84 @@ public List<MgtDeptStaffListVo> listMgtDeptStaff(){ return sysStaffMapper.listMgtDeptStaff(); } /** * @description getBYUserId * @param userId * @return SysStaff * @author jqs34 * @date 2023/6/18 21:01 */ @Override public SysStaff getByUserId(Long userId){ LambdaQueryWrapper<SysStaff> queryWrapper = new LambdaQueryWrapper(); queryWrapper.eq(SysStaff::getDelFlag,0); queryWrapper.eq(SysStaff::getUserId,userId); return this.getOne(queryWrapper, false); } /** * @description mgtStaffEdit * @param mgtStaffEditDto * @return void * @author jqs34 * @date 2023/6/18 20:59 */ @Override public void mgtStaffEdit(MgtStaffEditDto mgtStaffEditDto){ SysStaff sysStaff; SysUser sysUser; if(mgtStaffEditDto.getUserId()!=null){ sysStaff = this.getByUserId(mgtStaffEditDto.getUserId()); sysUser = sysUserService.getById(mgtStaffEditDto.getUserId()); sysUser.setUserName(mgtStaffEditDto.getStaffMobile()); sysUser.setPhonenumber(mgtStaffEditDto.getStaffMobile()); sysUser.setNickName(mgtStaffEditDto.getStaffName()); sysUser.setAvatar(mgtStaffEditDto.getStaffAvatar()); sysUser.setEmail(mgtStaffEditDto.getStaffEmail()); sysUserService.saveOrUpdate(sysUser); }else{ sysStaff = new SysStaff(); String staffId = IdUtils.simpleUUID(); sysStaff.setStaffId(staffId); sysStaff.setDelFlag(0); sysUser = new SysUser(); sysUser.setDelFlag("0"); sysUser.setUserType("00"); sysUser.setUserName(mgtStaffEditDto.getStaffMobile()); sysUser.setPhonenumber(mgtStaffEditDto.getStaffMobile()); sysUser.setNickName(mgtStaffEditDto.getStaffName()); sysUser.setAvatar(mgtStaffEditDto.getStaffAvatar()); sysUser.setEmail(mgtStaffEditDto.getStaffEmail()); String password = "123456"; sysUser.setPassword(SecurityUtils.encryptPassword(password)); sysUser.setDeptId(mgtStaffEditDto.getDeptId()); sysUser = sysUserService.registerUser(sysUser); sysStaff.setUserId(sysUser.getUserId()); } sysStaff.setStaffName(mgtStaffEditDto.getStaffName()); sysStaff.setStaffMobile(mgtStaffEditDto.getStaffMobile()); sysStaff.setStaffEmail(mgtStaffEditDto.getStaffEmail()); sysStaff.setStaffPost(mgtStaffEditDto.getStaffPost()); sysStaff.setStaffAvatar(mgtStaffEditDto.getStaffAvatar()); sysStaff.setHeadFlag(mgtStaffEditDto.getHeadFlag()); this.saveOrUpdate(sysStaff); } /** * @description mgtDeleteStaff * @param mgtBaseGetDto * @return void * @author jqs34 * @date 2023/6/18 22:00 */ @Override public void mgtDeleteStaff(MgtBaseGetDto mgtBaseGetDto){ Long userId = Long.valueOf(mgtBaseGetDto.getId()); SysStaff sysStaff = this.getByUserId(userId); sysStaff.setDelFlag(1); this.saveOrUpdate(sysStaff); sysUserService.deleteUserById(mgtBaseGetDto.getUserId()); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
@@ -1,11 +1,5 @@ package com.ruoyi.system.service.impl.sys; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.text.Convert; @@ -16,10 +10,19 @@ import com.ruoyi.system.api.domain.poji.sys.SysDept; import com.ruoyi.system.api.domain.poji.sys.SysRole; import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.domain.pojo.sys.SysDeptMenu; import com.ruoyi.system.domain.vo.TreeSelect; import com.ruoyi.system.mapper.sys.SysDeptMapper; import com.ruoyi.system.mapper.sys.SysDeptMenuMapper; import com.ruoyi.system.mapper.sys.SysRoleMapper; import com.ruoyi.system.service.sys.ISysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; /** * 部门管理 服务实现 @@ -34,6 +37,9 @@ @Autowired private SysRoleMapper roleMapper; @Autowired private SysDeptMenuMapper deptMenuMapper; /** * 查询部门管理数据 @@ -218,7 +224,33 @@ throw new ServiceException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); //新增部门 deptMapper.insertDept(dept); return insertDeptMenu(dept); } /** * 新增角色菜单信息 * * @param dept 部门对象 */ public int insertDeptMenu(SysDept dept) { int rows = 1; // 新增用户与角色管理 List<SysDeptMenu> list = new ArrayList<SysDeptMenu>(); for (Long menuId : dept.getMenuIds()) { SysDeptMenu rm = new SysDeptMenu(); rm.setDeptId(dept.getDeptId()); rm.setMenuId(menuId); list.add(rm); } if (list.size() > 0) { rows = deptMenuMapper.batchDeptMenu(list); } return rows; } /** @@ -246,6 +278,9 @@ // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatusNormal(dept); } // 删除角色与菜单关联 deptMenuMapper.deleteDeptMenuByDeptId(dept.getDeptId()); insertDeptMenu(dept); return result; } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysMenuServiceImpl.java
@@ -1,15 +1,5 @@ package com.ruoyi.system.service.impl.sys; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.utils.StringUtils; @@ -24,6 +14,11 @@ import com.ruoyi.system.mapper.sys.SysRoleMapper; import com.ruoyi.system.mapper.sys.SysRoleMenuMapper; import com.ruoyi.system.service.sys.ISysMenuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; /** * 菜单 业务层处理 @@ -156,6 +151,29 @@ } /** * @description selectMenuListByDeptId * @param deptId * @return List<SysMenu> * @author jqs34 * @date 2023/6/18 19:13 */ @Override public List<Long> selectMenuListByDeptId(Long deptId){ return menuMapper.selectMenuListByDeptId(deptId, true); } /** * @description selectMenuListByDeptId * @param deptUserId * @return List<SysMenu> * @author jqs34 * @date 2023/6/18 19:13 */ public List<Long> selectMenuListByDeptUserId(Long deptUserId){ return menuMapper.selectMenuListByDeptUserId(deptUserId, true); } /** * 构建前端路由所需要的菜单 * * @param menus 菜单列表 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java
@@ -1,5 +1,7 @@ package com.ruoyi.system.service.staff; import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.vo.MgtDeptStaffListVo; @@ -25,4 +27,30 @@ */ List<MgtDeptStaffListVo> listMgtDeptStaff(); /** * @description mgtStaffEdit * @param mgtStaffEditDto * @return void * @author jqs34 * @date 2023/6/18 20:59 */ void mgtStaffEdit(MgtStaffEditDto mgtStaffEditDto); /** * @description getBYUserId * @param userId * @return SysStaff * @author jqs34 * @date 2023/6/18 21:01 */ SysStaff getByUserId(Long userId); /** * @description mgtDeleteStaff * @param mgtBaseGetDto * @return void * @author jqs34 * @date 2023/6/18 22:01 */ void mgtDeleteStaff(MgtBaseGetDto mgtBaseGetDto); } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/sys/ISysMenuService.java
@@ -1,10 +1,11 @@ package com.ruoyi.system.service.sys; import java.util.List; import java.util.Set; import com.ruoyi.system.domain.pojo.sys.SysMenu; import com.ruoyi.system.domain.vo.RouterVo; import com.ruoyi.system.domain.vo.TreeSelect; import java.util.List; import java.util.Set; /** * 菜单 业务层 @@ -29,6 +30,7 @@ * @return 菜单列表 */ public List<SysMenu> selectMenuList(SysMenu menu, Long userId); /** * 根据用户ID查询权限 @@ -63,6 +65,24 @@ public List<Long> selectMenuListByRoleId(Long roleId); /** * @description selectMenuListByDeptId * @param deptId * @return List<SysMenu> * @author jqs34 * @date 2023/6/18 19:13 */ public List<Long> selectMenuListByDeptId(Long deptId); /** * @description selectMenuListByDeptId * @param deptUserId * @return List<SysMenu> * @author jqs34 * @date 2023/6/18 19:13 */ public List<Long> selectMenuListByDeptUserId(Long deptUserId); /** * 构建前端路由所需要的菜单 * * @param menus 菜单列表 ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMenuMapper.xml
New file @@ -0,0 +1,34 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.sys.SysDeptMenuMapper"> <resultMap type="SysDeptMenu" id="SysDeptMenuResult"> <result property="deptId" column="dept_id" /> <result property="menuId" column="menu_id" /> </resultMap> <select id="checkMenuExistDept" resultType="Integer"> select count(1) from sys_dept_menu where menu_id = #{menuId} </select> <delete id="deleteDeptMenuByDeptId" parameterType="Long"> delete from sys_dept_menu where dept_id=#{deptId} </delete> <delete id="deleteDeptMenu" parameterType="Long"> delete from sys_dept_menu where dept_id in <foreach collection="array" item="deptId" open="(" separator="," close=")"> #{deptId} </foreach> </delete> <insert id="batchDeptMenu"> insert into sys_dept_menu(dept_id, menu_id) values <foreach item="item" index="index" collection="list" separator=","> (#{item.deptId},#{item.menuId}) </foreach> </insert> </mapper> ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysMenuMapper.xml
@@ -94,6 +94,28 @@ </if> order by m.parent_id, m.order_num </select> <select id="selectMenuListByDeptId" resultType="Long"> select m.menu_id from sys_menu m left join sys_dept_menu rm on m.menu_id = rm.menu_id where rm.dept_id = #{deptId} <if test="menuCheckStrictly"> and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_dept_menu rm on m.menu_id = rm.menu_id and rm.dept_id = #{deptId}) </if> order by m.parent_id, m.order_num </select> <select id="selectMenuListByDeptUserId" resultType="Long"> select m.menu_id from sys_menu m left join sys_user_menu rm on m.menu_id = rm.menu_id where rm.user_id = #{deprUserId} <if test="menuCheckStrictly"> and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_user_menu rm on m.menu_id = rm.menu_id and rm.user_id = #{deptUserId}) </if> order by m.parent_id, m.order_num </select> <select id="selectMenuPerms" resultType="String"> select distinct m.perms ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysUserMenuMapper.xml
New file @@ -0,0 +1,34 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.sys.SysUserMenuMapper"> <resultMap type="SysUserMenu" id="SysUserMenuResult"> <result property="userId" column="user_id" /> <result property="menuId" column="menu_id" /> </resultMap> <select id="checkMenuExistUser" resultType="Integer"> select count(1) from sys_user_menu where menu_id = #{menuId} </select> <delete id="deleteUserMenuByUserId" parameterType="Long"> delete from sys_user_menu where user_id=#{userId} </delete> <delete id="deleteUserMenu" parameterType="Long"> delete from sys_user_menu where user_id in <foreach collection="array" item="userId" open="(" separator="," close=")"> #{userId} </foreach> </delete> <insert id="batchUserMenu"> insert into sys_user_menu(user_id, menu_id) values <foreach item="item" index="index" collection="list" separator=","> (#{item.userId},#{item.menuId}) </foreach> </insert> </mapper>