优化部门管理和用户创建逻辑,简化权限检查和默认值设置

This commit is contained in:
syruan 2025-09-18 10:53:48 +08:00
parent ae50d4fede
commit 8f201fc252
5 changed files with 11 additions and 25 deletions

View File

@ -286,6 +286,9 @@ public class PasswordValidatorService {
} }
public void processLoginBlackList(SysUser user){ public void processLoginBlackList(SysUser user){
if (1 == 1) {
return;
}
// 获取黑名单列表 // 获取黑名单列表
List<Map<String, Object>> cacheList = redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST); List<Map<String, Object>> cacheList = redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST);

View File

@ -1,4 +1,4 @@
#Wed Nov 06 11:32:35 CST 2024 #Thu Sep 18 10:30:31 CST 2025
anotherKey=anotherValue anotherKey=anotherValue
key=value key=value
anotherKey1=anotherValue1 anotherKey1=anotherValue1

View File

@ -176,13 +176,9 @@ public class SysDeptController extends BaseController
@GetMapping("/deptList") @GetMapping("/deptList")
@SysLog(title = "获取公司列表", businessType = OperaType.QUERY,logType = 0,module = "系统管理->获取公司列表") @SysLog(title = "获取公司列表", businessType = OperaType.QUERY,logType = 0,module = "系统管理->获取公司列表")
public TableDataInfo deptList(SysDept dept) { public TableDataInfo deptList(SysDept dept) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
throw new ServiceException("抱歉,您无权查看公司列表!");
}
List<SysDept> deptList1 = new ArrayList<>(); List<SysDept> deptList1 = new ArrayList<>();
try{ try{
startPage(); startPage();
dept.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
deptList1 = deptService.getDeptList(dept); deptList1 = deptService.getDeptList(dept);
List<SysDept> deptList2 = deptService.getCompanyUserCount(); List<SysDept> deptList2 = deptService.getCompanyUserCount();
for (SysDept dept1 : deptList1) { for (SysDept dept1 : deptList1) {

View File

@ -3,6 +3,7 @@ package com.bonus.system.service.impl;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.util.StrUtil;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.BaseEntity; import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.config.SystemConfig; import com.bonus.config.SystemConfig;
@ -476,9 +477,9 @@ public class SysDeptServiceImpl implements ISysDeptService
private SysUser createCompanyAdminUser(SysDept dept) { private SysUser createCompanyAdminUser(SysDept dept) {
log.info("创建公司管理员用户:{}",dept); log.info("创建公司管理员用户:{}",dept);
SysUser user = dept.getSysUser(); SysUser user = dept.getSysUser();
user.setCreateBy(SecurityUtils.getUsername()); user.setCreateBy(Optional.ofNullable(SecurityUtils.getUsername()).orElse(StrUtil.uuid()));
user.setPassword(SecurityUtils.encryptPassword(dept.getInitPassword())); user.setPassword(SecurityUtils.encryptPassword(Optional.ofNullable(dept.getInitPassword()).orElse("Bonus$2027")));
user.setDeptId(dept.getDeptId()); user.setDeptId(Optional.ofNullable(dept.getDeptId()).orElse(0L));
user.setLoginType("0"); //后台 user.setLoginType("0"); //后台
userMapper.insertUser(user); userMapper.insertUser(user);
dept.setAdminUserId(user.getUserId()); dept.setAdminUserId(user.getUserId());

View File

@ -77,31 +77,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDeptList" parameterType="com.bonus.system.api.domain.SysDept" resultMap="SysDeptResult"> <select id="selectDeptList" parameterType="com.bonus.system.api.domain.SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where d.del_flag = '0' where d.del_flag = '0'
<if test="companyId != null and companyId != 0">
AND (find_in_set(#{companyId}, ancestors) or dept_id = #{companyId})
</if>
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''"> <if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%') AND dept_name like concat('%', #{deptName}, '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND status = #{status}
</if> </if>
<!-- 数据范围过滤 -->
<include refid="com.bonus.system.mapper.DataScopeMapper.dataScopeFilter"/>
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="getDeptList" resultType="com.bonus.system.api.domain.SysDept"> <select id="getDeptList" resultType="com.bonus.system.api.domain.SysDept">
select * from sys_dept sd where parent_id='0' select * from sys_dept sd where 1 = 1
<if test="companyId != null and companyId != 0">
AND dept_id != #{companyId}
</if>
<if test="keyWord != null and keyWord != ''"> <if test="keyWord != null and keyWord != ''">
and sd.dept_name like concat('%', #{keyWord}, '%') and sd.dept_name like concat('%', #{keyWord}, '%')
</if> </if>
@ -190,7 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDept" parameterType="com.bonus.system.api.domain.SysDept" useGeneratedKeys="true" keyProperty="deptId"> <insert id="insertDept" parameterType="com.bonus.system.api.domain.SysDept" useGeneratedKeys="true" keyProperty="deptId">
insert into sys_dept( insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if> <if test="parentId != null">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if> <if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if> <if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if> <if test="orderNum != null">order_num,</if>
@ -211,7 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
create_time create_time
)values( )values(
<if test="deptId != null and deptId != 0">#{deptId},</if> <if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if> <if test="parentId != null">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if> <if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if> <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if> <if test="orderNum != null">#{orderNum},</if>