From a6f6562693ab430b76d3c4810defd03a5e19b3fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Tue, 27 Dec 2022 17:38:13 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=99=BB=E5=BD=95=20=E4=BD=BF=E7=94=A8=E5=8D=95?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E6=A0=A1=E9=AA=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=20=E9=81=BF=E5=85=8D=E5=A4=9A=E6=AC=A1join=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/system/service/SysLoginService.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java index 31f8c471..d65a4048 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java @@ -5,6 +5,7 @@ import cn.dev33.satoken.secure.BCrypt; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.event.LogininforEvent; @@ -25,6 +26,7 @@ import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.redis.RedisUtils; import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.mapper.SysUserMapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -45,7 +47,7 @@ import java.util.function.Supplier; @Service public class SysLoginService { - private final ISysUserService userService; + private final SysUserMapper userMapper; private final ISysConfigService configService; private final SysPermissionService permissionService; @@ -183,33 +185,31 @@ public class SysLoginService { } private SysUser loadUserByUsername(String username) { - SysUser user = userService.selectUserByUserName(username); + SysUser user = userMapper.selectOne(new LambdaQueryWrapper() + .select(SysUser::getUserName, SysUser::getStatus) + .eq(SysUser::getUserName, username)); if (ObjectUtil.isNull(user)) { log.info("登录用户:{} 不存在.", username); throw new UserException("user.not.exists", username); - } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { - log.info("登录用户:{} 已被删除.", username); - throw new UserException("user.password.delete", username); } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { log.info("登录用户:{} 已被停用.", username); throw new UserException("user.blocked", username); } - return user; + return userMapper.selectUserByUserName(username); } private SysUser loadUserByPhonenumber(String phonenumber) { - SysUser user = userService.selectUserByPhonenumber(phonenumber); + SysUser user = userMapper.selectOne(new LambdaQueryWrapper() + .select(SysUser::getPhonenumber, SysUser::getStatus) + .eq(SysUser::getPhonenumber, phonenumber)); if (ObjectUtil.isNull(user)) { log.info("登录用户:{} 不存在.", phonenumber); throw new UserException("user.not.exists", phonenumber); - } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { - log.info("登录用户:{} 已被删除.", phonenumber); - throw new UserException("user.password.delete", phonenumber); } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { log.info("登录用户:{} 已被停用.", phonenumber); throw new UserException("user.blocked", phonenumber); } - return user; + return userMapper.selectUserByPhonenumber(phonenumber); } private SysUser loadUserByOpenid(String openid) { @@ -219,9 +219,6 @@ public class SysLoginService { if (ObjectUtil.isNull(user)) { log.info("登录用户:{} 不存在.", openid); // todo 用户不存在 业务逻辑自行实现 - } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { - log.info("登录用户:{} 已被删除.", openid); - // todo 用户已被删除 业务逻辑自行实现 } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { log.info("登录用户:{} 已被停用.", openid); // todo 用户已被停用 业务逻辑自行实现 @@ -257,7 +254,7 @@ public class SysLoginService { sysUser.setLoginIp(ServletUtils.getClientIP()); sysUser.setLoginDate(DateUtils.getNowDate()); sysUser.setUpdateBy(username); - userService.updateUserProfile(sysUser); + userMapper.updateById(sysUser); } /**