mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
update 优化 登录授权代码,将loadUser()提取为公有代码
This commit is contained in:
parent
6dfa1080be
commit
77f4fcda25
@ -80,14 +80,7 @@ public class SysLoginService {
|
||||
throw new UserException("user.blocked", account);
|
||||
}
|
||||
|
||||
SysUserVo sysUserVo = null;
|
||||
switch (loginType) {
|
||||
case SMS: sysUserVo = userMapper.selectUserByPhonenumber(account); break;
|
||||
case EMAIL: sysUserVo = userMapper.selectUserByEmail(account); break;
|
||||
case PASSWORD: sysUserVo = userMapper.selectUserByUserName(account); break;
|
||||
case SOCIAL: sysUserVo = userMapper.selectUserById(Long.parseLong(account)); break;
|
||||
}
|
||||
return sysUserVo;
|
||||
return userMapper.selectUser(loginType, account);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.core.enums.LoginType;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
@ -61,6 +62,14 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
})
|
||||
Page<SysUserVo> selectUnallocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param account 账号:手机/邮箱/密码/UserId
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserVo selectUser(LoginType loginType, String account);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
|
||||
@ -123,5 +123,20 @@
|
||||
where u.del_flag = '0' and u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectUser" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.del_flag = '0'
|
||||
<if test="loginType.toString() == 'SMS'">
|
||||
and u.phonenumber = #{account}
|
||||
</if>
|
||||
<if test="loginType.toString() == 'EMAIL'">
|
||||
and u.email = #{account}
|
||||
</if>
|
||||
<if test="loginType.toString() == 'PASSWORD'">
|
||||
and u.user_name = #{account}
|
||||
</if>
|
||||
<if test="loginType.toString() == 'SOCIAL'">
|
||||
and u.user_id = #{account}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user