mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
系统基础模块:1、用户密码复杂度校验、长度(6->8),只有小写->必须有大小写;2、删除用户采用物理删除,适配用户表的username唯一索引;
This commit is contained in:
+10
@@ -13,6 +13,7 @@ import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
|
||||
import com.cf.imes.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@@ -172,4 +173,13 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
*/
|
||||
@Select("SELECT username FROM system_users WHERE id = #{id} FOR UPDATE")
|
||||
AdminUserDO selectByIdForUpdate(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据id物理删除user
|
||||
*
|
||||
* @param id
|
||||
* @return 改动数量
|
||||
*/
|
||||
@Delete("DELETE FROM system_users WHERE id = #{id}")
|
||||
int physicalDeleteById(@Param("id") Long id);
|
||||
}
|
||||
|
||||
+19
-12
@@ -114,8 +114,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
|
||||
// 定义密码校验的正则表达式
|
||||
private static final String LENGTH_PATTERN = ".{6,}";
|
||||
private static final String LETTER_PATTERN = ".*[A-Za-z].*";
|
||||
private static final String LENGTH_PATTERN = ".{8,}";
|
||||
private static final String UPPER_LETTER_PATTERN = ".*[A-Z].*";
|
||||
private static final String LOWER_LETTER_PATTERN = ".*[a-z].*";
|
||||
private static final String DIGIT_PATTERN = ".*\\d.*";
|
||||
private static final String VALID_CHAR_PATTERN = "^[A-Za-z\\d]+$";
|
||||
|
||||
@@ -320,12 +321,14 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
checkCurrentWhenOperate(id);
|
||||
// 校验用户存在
|
||||
validateUserExists(id);
|
||||
// 删除用户
|
||||
userMapper.deleteById(id);
|
||||
// 删除用户关联数据
|
||||
permissionService.processUserDeleted(id);
|
||||
// 删除用户岗位
|
||||
userPostMapper.deleteByUserId(id);
|
||||
// 物理删除用户
|
||||
int deleteNum = userMapper.physicalDeleteById(id);
|
||||
if (deleteNum > 0) {
|
||||
// 删除用户关联数据
|
||||
permissionService.processUserDeleted(id);
|
||||
// 删除用户岗位
|
||||
userPostMapper.deleteByUserId(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -463,11 +466,15 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
// 检查密码长度
|
||||
if (!Pattern.matches(LENGTH_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS);
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS);
|
||||
}
|
||||
// 检查是否包含字母
|
||||
if (!Pattern.matches(LETTER_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LETTER);
|
||||
// 检查是否包含大写字母
|
||||
if (!Pattern.matches(UPPER_LETTER_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_UPPER_LETTER);
|
||||
}
|
||||
// 检查是否包含小写字母
|
||||
if (!Pattern.matches(LOWER_LETTER_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LOWER_LETTER);
|
||||
}
|
||||
// 检查是否包含数字
|
||||
if (!Pattern.matches(DIGIT_PATTERN, password)) {
|
||||
|
||||
Reference in New Issue
Block a user