refactor: dept相关代码改造

This commit is contained in:
czc 2024-07-12 11:14:02 +08:00
parent ce0157c3b8
commit 26224750de
11 changed files with 224 additions and 174 deletions

View file

@ -6,10 +6,11 @@ import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.entity.SysDept;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.domain.vo.SysDeptVo;
import com.ruoyi.system.service.SysDeptService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -27,15 +28,15 @@ import java.util.List;
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController {
private final ISysDeptService deptService;
private final SysDeptService deptService;
/**
* 获取部门列表
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list")
public R<List<SysDept>> list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
public R<List<SysDeptVo>> list(SysDeptBo dept) {
List<SysDeptVo> depts = deptService.selectDeptList(dept);
return R.ok(depts);
}
@ -46,8 +47,8 @@ public class SysDeptController extends BaseController {
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
public R<List<SysDeptVo>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDeptVo> depts = deptService.selectDeptList(new SysDeptBo());
depts.removeIf(d -> d.getDeptId().equals(deptId)
|| StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
return R.ok(depts);
@ -60,7 +61,7 @@ public class SysDeptController extends BaseController {
*/
@SaCheckPermission("system:dept:query")
@GetMapping(value = "/{deptId}")
public R<SysDept> getInfo(@PathVariable Long deptId) {
public R<SysDeptVo> getInfo(@PathVariable Long deptId) {
deptService.checkDeptDataScope(deptId);
return R.ok(deptService.selectDeptById(deptId));
}
@ -71,7 +72,7 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:add")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public R<Void> add(@Validated @RequestBody SysDept dept) {
public R<Void> add(@Validated @RequestBody SysDeptBo dept) {
if (!deptService.checkDeptNameUnique(dept)) {
return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
@ -84,7 +85,7 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public R<Void> edit(@Validated @RequestBody SysDept dept) {
public R<Void> edit(@Validated @RequestBody SysDeptBo dept) {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {

View file

@ -8,13 +8,13 @@ import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.bo.SysRoleBo;
import com.ruoyi.system.domain.bo.SysUserBo;
import com.ruoyi.system.domain.entity.SysDept;
import com.ruoyi.system.domain.entity.SysUserRole;
import com.ruoyi.system.domain.vo.SysRoleVo;
import com.ruoyi.system.domain.vo.SysUserVo;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.SysDeptService;
import com.ruoyi.system.service.SysRoleService;
import com.ruoyi.system.service.SysUserService;
import jakarta.servlet.http.HttpServletResponse;
@ -38,7 +38,7 @@ public class SysRoleController extends BaseController {
private final SysRoleService roleService;
private final SysUserService userService;
private final ISysDeptService deptService;
private final SysDeptService deptService;
/**
* 获取角色信息列表
@ -221,7 +221,7 @@ public class SysRoleController extends BaseController {
public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
return R.ok(Map.of(
"checkedKeys", deptService.selectDeptListByRoleId(roleId),
"depts", deptService.selectDeptTreeList(new SysDept())
"depts", deptService.selectDeptTreeList(new SysDeptBo())
));
}
}

View file

@ -17,6 +17,7 @@ import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.bo.SysRoleBo;
import com.ruoyi.system.domain.bo.SysUserBo;
import com.ruoyi.system.domain.entity.SysDept;
@ -27,10 +28,7 @@ import com.ruoyi.system.domain.vo.SysUserExportVo;
import com.ruoyi.system.domain.vo.SysUserImportVo;
import com.ruoyi.system.domain.vo.SysUserVo;
import com.ruoyi.system.listener.SysUserImportListener;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.SysRoleService;
import com.ruoyi.system.service.SysUserService;
import com.ruoyi.system.service.*;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -59,7 +57,7 @@ public class SysUserController extends BaseController {
private final SysUserService userService;
private final SysRoleService roleService;
private final ISysPostService postService;
private final ISysDeptService deptService;
private final SysDeptService deptService;
/**
* 获取用户列表
@ -247,7 +245,7 @@ public class SysUserController extends BaseController {
*/
@SaCheckPermission("system:user:list")
@GetMapping("/deptTree")
public R<List<Tree<Long>>> deptTree(SysDept dept) {
public R<List<Tree<Long>>> deptTree(SysDeptBo dept) {
return R.ok(deptService.selectDeptTreeList(dept));
}

View file

@ -0,0 +1,74 @@
package com.ruoyi.system.domain.bo;
import com.ruoyi.common.core.xss.Xss;
import com.ruoyi.common.mybatis.core.domain.BaseEntity;
import com.ruoyi.system.domain.entity.SysDept;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 部门业务对象 sys_dept
*
* @author Michelle.Chung
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = SysDept.class, reverseConvertGenerate = false)
public class SysDeptBo extends BaseEntity {
/**
* 部门id
*/
private Long deptId;
/**
* 父部门ID
*/
private Long parentId;
/**
* 部门名称
*/
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "部门名称不能为空")
@Size(min = 0, max = 30, message = "部门名称长度不能超过{max}个字符")
private String deptName;
/**
* 显示顺序
*/
@NotNull(message = "显示顺序不能为空")
private Integer orderNum;
/**
* 负责人
*/
private String leader;
/**
* 联系电话
*/
@Size(min = 0, max = 11, message = "联系电话长度不能超过{max}个字符")
private String phone;
/**
* 邮箱
*/
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符")
private String email;
/**
* 部门状态0正常 1停用
*/
private String status;
}

View file

@ -0,0 +1,97 @@
package com.ruoyi.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
import com.ruoyi.common.excel.convert.ExcelDictConvert;
import com.ruoyi.common.sensitive.annotation.Sensitive;
import com.ruoyi.common.sensitive.core.SensitiveStrategy;
import com.ruoyi.system.domain.entity.SysDept;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 部门视图对象 sys_dept
*
* @author Michelle.Chung
*/
@Data
@AutoMapper(target = SysDept.class)
public class SysDeptVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 部门id
*/
@ExcelProperty(value = "部门id")
private Long deptId;
/**
* 父部门id
*/
private Long parentId;
/**
* 父部门名称
*/
private String parentName;
/**
* 祖级列表
*/
private String ancestors;
/**
* 部门名称
*/
@ExcelProperty(value = "部门名称")
private String deptName;
/**
* 显示顺序
*/
private Integer orderNum;
/**
* 负责人
*/
@ExcelProperty(value = "负责人")
private String leader;
/**
* 联系电话
*/
@ExcelProperty(value = "联系电话")
private String phone;
/**
* 邮箱
*/
@ExcelProperty(value = "邮箱")
private String email;
/**
* 部门状态0停用 1正常
*/
@ExcelProperty(value = "部门状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_normal_disable")
private String status;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "创建时间")
private LocalDateTime createTime;
}

View file

@ -6,6 +6,7 @@ import com.ruoyi.common.mybatis.annotation.DataColumn;
import com.ruoyi.common.mybatis.annotation.DataPermission;
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
import com.ruoyi.system.domain.entity.SysDept;
import com.ruoyi.system.domain.vo.SysDeptVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -15,7 +16,7 @@ import java.util.List;
*
* @author Lion Li
*/
public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDept> {
public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
/**
* 查询部门管理数据
@ -26,7 +27,7 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDept> {
@DataPermission({
@DataColumn(key = "deptName", value = "dept_id")
})
List<SysDept> selectDeptList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
List<SysDeptVo> selectDeptList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
/**
* 根据角色ID查询部门树信息

View file

@ -1,116 +0,0 @@
package com.ruoyi.system.service;
import cn.hutool.core.lang.tree.Tree;
import com.ruoyi.system.domain.entity.SysDept;
import java.util.List;
/**
* 部门管理 服务层
*
* @author Lion Li
*/
public interface ISysDeptService {
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
List<SysDept> selectDeptList(SysDept dept);
/**
* 查询部门树结构信息
*
* @param dept 部门信息
* @return 部门树信息集合
*/
List<Tree<Long>> selectDeptTreeList(SysDept dept);
/**
* 构建前端所需要下拉树结构
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts);
/**
* 根据角色ID查询部门树信息
*
* @param roleId 角色ID
* @return 选中部门列表
*/
List<Long> selectDeptListByRoleId(Long roleId);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
SysDept selectDeptById(Long deptId);
/**
* 根据ID查询所有子部门数正常状态
*
* @param deptId 部门ID
* @return 子部门数
*/
long selectNormalChildrenDeptById(Long deptId);
/**
* 是否存在部门子节点
*
* @param deptId 部门ID
* @return 结果
*/
boolean hasChildByDeptId(Long deptId);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
boolean checkDeptExistUser(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
boolean checkDeptNameUnique(SysDept dept);
/**
* 校验部门是否有数据权限
*
* @param deptId 部门id
*/
void checkDeptDataScope(Long deptId);
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
int insertDept(SysDept dept);
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
int updateDept(SysDept dept);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
int deleteDeptById(Long deptId);
}

View file

@ -1,4 +1,4 @@
package com.ruoyi.system.service.impl;
package com.ruoyi.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
@ -8,10 +8,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.service.DeptService;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.entity.SysDept;
import com.ruoyi.system.domain.entity.SysRole;
import com.ruoyi.system.domain.entity.SysUser;
import com.ruoyi.common.core.service.DeptService;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.mybatis.helper.DataBaseHelper;
import com.ruoyi.common.satoken.utils.LoginHelper;
@ -19,10 +21,10 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.TreeBuildUtils;
import com.ruoyi.common.redis.utils.CacheUtils;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.system.domain.vo.SysDeptVo;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysDeptService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@ -39,7 +41,7 @@ import java.util.List;
*/
@RequiredArgsConstructor
@Service
public class SysDeptServiceImpl implements ISysDeptService, DeptService {
public class SysDeptService implements DeptService {
private final SysDeptMapper baseMapper;
private final SysRoleMapper roleMapper;
@ -51,8 +53,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param dept 部门信息
* @return 部门信息集合
*/
@Override
public List<SysDept> selectDeptList(SysDept dept) {
public List<SysDeptVo> selectDeptList(SysDeptBo dept) {
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
lqw.eq(SysDept::getDelFlag, "0")
.eq(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId())
@ -61,7 +62,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
.eq(StringUtils.isNotBlank(dept.getStatus()), SysDept::getStatus, dept.getStatus())
.orderByAsc(SysDept::getParentId)
.orderByAsc(SysDept::getOrderNum);
return baseMapper.selectDeptList(lqw);
return baseMapper.selectVoList(lqw);
}
/**
@ -70,11 +71,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param dept 部门信息
* @return 部门树信息集合
*/
@Override
public List<Tree<Long>> selectDeptTreeList(SysDept dept) {
public List<Tree<Long>> selectDeptTreeList(SysDeptBo dept) {
// 只查询未禁用部门
dept.setStatus(UserConstants.DEPT_NORMAL);
List<SysDept> depts = this.selectDeptList(dept);
List<SysDeptVo> depts = this.selectDeptList(dept);
return buildDeptTreeSelect(depts);
}
@ -84,8 +84,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param depts 部门列表
* @return 下拉树结构列表
*/
@Override
public List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts) {
public List<Tree<Long>> buildDeptTreeSelect(List<SysDeptVo> depts) {
if (CollUtil.isEmpty(depts)) {
return CollUtil.newArrayList();
}
@ -102,7 +101,6 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param roleId 角色ID
* @return 选中部门列表
*/
@Override
public List<Long> selectDeptListByRoleId(Long roleId) {
SysRole role = roleMapper.selectById(roleId);
return baseMapper.selectDeptListByRoleId(roleId, role.getDeptCheckStrictly());
@ -115,13 +113,12 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @return 部门信息
*/
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override
public SysDept selectDeptById(Long deptId) {
SysDept dept = baseMapper.selectById(deptId);
public SysDeptVo selectDeptById(Long deptId) {
SysDeptVo dept = baseMapper.selectVoById(deptId);
if (ObjectUtil.isNull(dept)) {
return null;
}
SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
return dept;
@ -137,7 +134,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
public String selectDeptNameByIds(String deptIds) {
List<String> list = new ArrayList<>();
for (Long id : StringUtils.splitTo(deptIds, Convert::toLong)) {
SysDept dept = SpringUtils.getAopProxy(this).selectDeptById(id);
SysDeptVo dept = SpringUtils.getAopProxy(this).selectDeptById(id);
if (ObjectUtil.isNotNull(dept)) {
list.add(dept.getDeptName());
}
@ -151,7 +148,6 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param deptId 部门ID
* @return 子部门数
*/
@Override
public long selectNormalChildrenDeptById(Long deptId) {
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
@ -164,7 +160,6 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param deptId 部门ID
* @return 结果
*/
@Override
public boolean hasChildByDeptId(Long deptId) {
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getParentId, deptId));
@ -176,7 +171,6 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId) {
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getDeptId, deptId));
@ -188,8 +182,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param dept 部门信息
* @return 结果
*/
@Override
public boolean checkDeptNameUnique(SysDept dept) {
public boolean checkDeptNameUnique(SysDeptBo dept) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getDeptName, dept.getDeptName())
.eq(SysDept::getParentId, dept.getParentId())
@ -202,12 +195,11 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*
* @param deptId 部门id
*/
@Override
public void checkDeptDataScope(Long deptId) {
if (!LoginHelper.isAdmin()) {
SysDept dept = new SysDept();
dept.setDeptId(deptId);
List<SysDept> depts = this.selectDeptList(dept);
List<SysDeptVo> depts = this.selectDeptList(MapstructUtils.convert(dept, SysDeptBo.class));
if (CollUtil.isEmpty(depts)) {
throw new ServiceException("没有权限访问部门数据!");
}
@ -217,16 +209,16 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @param bo 部门信息
* @return 结果
*/
@Override
public int insertDept(SysDept dept) {
SysDept info = baseMapper.selectById(dept.getParentId());
public int insertDept(SysDeptBo bo) {
SysDept info = baseMapper.selectById(bo.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
SysDept dept = MapstructUtils.convert(bo, SysDept.class);
dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
return baseMapper.insert(dept);
}
@ -234,12 +226,12 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @param bo 部门信息
* @return 结果
*/
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#dept.deptId")
@Override
public int updateDept(SysDept dept) {
public int updateDept(SysDeptBo bo) {
SysDept dept = MapstructUtils.convert(bo, SysDept.class);
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
@ -301,7 +293,6 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @return 结果
*/
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override
public int deleteDeptById(Long deptId) {
return baseMapper.deleteById(deptId);
}

View file

@ -22,8 +22,10 @@ import com.ruoyi.common.log.event.LogininforEvent;
import com.ruoyi.common.redis.utils.RedisUtils;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.common.web.config.properties.CaptchaProperties;
import com.ruoyi.system.domain.bo.SysUserBo;
import com.ruoyi.system.domain.entity.SysDept;
import com.ruoyi.system.domain.entity.SysUser;
import com.ruoyi.system.domain.vo.SysDeptVo;
import com.ruoyi.system.domain.vo.SysRoleVo;
import com.ruoyi.system.domain.vo.SysUserVo;
import com.ruoyi.system.mapper.SysUserMapper;
@ -50,7 +52,7 @@ public class SysLoginService {
private final CaptchaProperties captchaProperties;
private final SysPermissionService permissionService;
private final SysRoleService roleService;
private final ISysDeptService deptService;
private final SysDeptService deptService;
@Value("${user.password.maxRetryCount}")
private Integer maxRetryCount;
@ -284,7 +286,7 @@ public class SysLoginService {
loginUser.setMenuPermission(permissionService.getMenuPermission(user.getUserId()));
loginUser.setRolePermission(permissionService.getRolePermission(user.getUserId()));
SysDept dept = null;
SysDeptVo dept = null;
if (ObjectUtil.isNotNull(user.getDeptId())) {
dept = deptService.selectDeptById(user.getDeptId());
}

View file

@ -1,6 +1,7 @@
package com.ruoyi.system.service;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.system.domain.entity.SysUser;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -18,6 +19,7 @@ public class SysPermissionService {
private final SysRoleService roleService;
private final ISysMenuService menuService;
private final SysUserService userService;
/**
* 获取角色数据权限

View file

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysDeptMapper">
<resultMap type="com.ruoyi.system.domain.entity.SysDept" id="SysDeptResult">
<resultMap type="com.ruoyi.system.domain.vo.SysDeptVo" id="SysDeptResult">
</resultMap>
<select id="selectDeptList" resultMap="SysDeptResult">