mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
修改-根据多个排单号查询板材数据
This commit is contained in:
+38
-4
@@ -49,6 +49,7 @@ import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
|
||||
@@ -88,6 +89,13 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
|
||||
// 定义密码校验的正则表达式
|
||||
private static final String LENGTH_PATTERN = ".{6,}";
|
||||
private static final String LETTER_PATTERN = ".*[A-Za-z].*";
|
||||
private static final String DIGIT_PATTERN = ".*\\d.*";
|
||||
private static final String VALID_CHAR_PATTERN = "^[A-Za-z\\d]+$";
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createUser(UserSaveReqVO createReqVO) {
|
||||
@@ -102,7 +110,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
});
|
||||
// 校验正确性
|
||||
validateUserForCreateOrUpdate(null, createReqVO.getUsername(),
|
||||
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds(), organId);
|
||||
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds(),createReqVO.getPassword(), organId);
|
||||
// 插入用户
|
||||
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
||||
user.setOrganId(createReqVO.getOrganId());
|
||||
@@ -131,7 +139,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
updateReqVO.setPassword(null); // 特殊:此处不更新密码
|
||||
// 校验正确性
|
||||
validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
|
||||
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(), organId);
|
||||
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(),null, organId);
|
||||
// 更新用户
|
||||
AdminUserDO updateObj = BeanUtils.toBean(updateReqVO, AdminUserDO.class);
|
||||
|
||||
@@ -187,6 +195,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
public void updateUserPassword(Long id, UserProfileUpdatePasswordReqVO reqVO) {
|
||||
// 校验旧密码密码
|
||||
validateOldPassword(id, reqVO.getOldPassword());
|
||||
// 校验密码是否符合要求
|
||||
validatePassword(reqVO.getNewPassword());
|
||||
// 执行更新
|
||||
AdminUserDO updateObj = new AdminUserDO().setId(id);
|
||||
updateObj.setPassword(encodePassword(reqVO.getNewPassword())); // 加密密码
|
||||
@@ -349,9 +359,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
}
|
||||
|
||||
private void validateUserForCreateOrUpdate(Long id, String username, String mobile, String email,
|
||||
Long deptId, Set<Long> postIds, Long organId) {
|
||||
Long deptId, Set<Long> postIds,String password ,Long organId) {
|
||||
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
||||
DataPermissionUtils.executeIgnore(() -> {
|
||||
// 校验用户的密码是否符合规则
|
||||
validatePassword(password);
|
||||
// 校验用户存在
|
||||
validateUserExists(id);
|
||||
// 校验用户名唯一
|
||||
@@ -367,6 +379,28 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validatePassword(String password){
|
||||
|
||||
// 检查密码长度
|
||||
if (!Pattern.matches(LENGTH_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS);
|
||||
}
|
||||
// 检查是否包含字母
|
||||
if (!Pattern.matches(LETTER_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LETTER);
|
||||
}
|
||||
// 检查是否包含数字
|
||||
if (!Pattern.matches(DIGIT_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_NUMBER);
|
||||
}
|
||||
// 检查是否只包含字母和数字
|
||||
if (!Pattern.matches(VALID_CHAR_PATTERN, password)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PASSWORDS_CAN_ONLY_CONTAIN_LETTERS_AND_NUMBERS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateUserExists(Long id) {
|
||||
if (id == null) {
|
||||
@@ -462,7 +496,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
// 校验,判断是否有不符合的原因
|
||||
try {
|
||||
validateUserForCreateOrUpdate(null, null, importUser.getMobile(), importUser.getEmail(),
|
||||
importUser.getDeptId(), null, organId);
|
||||
importUser.getDeptId(), null,null, organId);
|
||||
} catch (ServiceException ex) {
|
||||
respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user