双重预防项目-国泰新华二开定制版
kongzy
2024-10-25 e6f72c636a956f2347dee6edfd5cb6f90daeb646
src/main/java/com/ruoyi/project/system/user/service/UserServiceImpl.java
@@ -2,6 +2,7 @@
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.RegexUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.text.Convert;
@@ -220,6 +221,12 @@
    @Override
    @Transactional
    public int insertUser(User user) {
        if(StringUtils.isEmpty(user.getPassword())){
            throw new BusinessException("密码不能为空");
        }
        if(!RegexUtil.isPassword(user.getPassword())){
            throw new BusinessException("密码无效。密码必须包含至少一个大写字母、一个小写字母和一个数字,并且至少10个字符长。");
        }
        user.randomSalt();
        user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
        user.setCreateBy(ShiroUtils.getLoginName());
@@ -299,6 +306,12 @@
     */
    @Override
    public int resetUserPwd(User user) {
        if(StringUtils.isEmpty(user.getPassword())){
            throw new BusinessException("密码不能为空");
        }
        if(!RegexUtil.isPassword(user.getPassword())){
            throw new BusinessException("密码无效。密码必须包含至少一个大写字母、一个小写字母和一个数字,并且至少10个字符长。");
        }
        user.randomSalt();
        user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
        return updateUserInfo(user);
@@ -581,4 +594,14 @@
    public List<User> getAllUser() {
        return userMapper.getAllUser();
    }
    @Override
    public List<User> selectForUpdatePwd() {
        return userMapper.selectForUpdatePwd();
    }
    @Override
    public int updateUserForUpdatePwd(User user) {
        return userMapper.updateUserForUpdatePwd(user);
    }
}