| | |
| | | package com.dy.sso.busi; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaPrivilegeMapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaUserMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaUser; |
| | |
| | | this.baPrivilegeMapper = baPrivilegeMapper ; |
| | | } |
| | | |
| | | /** |
| | | * 需要BaUserMapper.xml |
| | | * @param uuid 给登录成功的用户赋值其token |
| | | * @param phone 用户手机号 |
| | | * @param password 用户密码 |
| | | * @return 登录成功用户 |
| | | */ |
| | | //当未注解@Transactional时,会输出日志:SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@46727a0c] was not registered for synchronization because synchronization is not active |
| | | @Transactional |
| | | @Cacheable(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid", sync=true) |
| | | public BaUser login(String uuid, String phone, String password){ |
| | | public BaUser loginWithMapperXml(String uuid, String phone, String password){ |
| | | BaUser baUser = this.baUserMapper.login(phone, password) ; |
| | | if(baUser != null && baUser.id != null){ |
| | | baUser.privileges = this.baPrivilegeMapper.selectPrivilegeByUserId(baUser.id) ; |
| | |
| | | return baUser; |
| | | } |
| | | |
| | | /** |
| | | * 不需要 BaUserMapper.xml |
| | | * @param uuid 给登录成功的用户赋值其token |
| | | * @param phone 用户手机号 |
| | | * @param password 用户密码 |
| | | * @return 登录成功用户 |
| | | */ |
| | | //当未注解@Transactional时,会输出日志:SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@46727a0c] was not registered for synchronization because synchronization is not active |
| | | @Transactional |
| | | @Cacheable(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid", sync=true) |
| | | public BaUser loginWithOutMapperXml(String uuid, String phone, String password){ |
| | | QueryWrapper<BaUser> qw = new QueryWrapper<>(); |
| | | //QueryWrapper<DemoMp> queryWrapper = Wrappers.<DemoMp>query() ; |
| | | qw.select("id", "name", "phone", "orgTag", "supperAdmin") |
| | | .eq("disabled", 0) |
| | | .eq("deleted", 0) |
| | | .eq("phone", phone) |
| | | .eq("password", password); |
| | | BaUser baUser = this.baUserMapper.selectOne(qw) ; |
| | | if(baUser != null && baUser.id != null){ |
| | | baUser.privileges = this.baPrivilegeMapper.selectPrivilegeByUserId(baUser.id) ; |
| | | } |
| | | return baUser; |
| | | } |
| | | |
| | | @CacheEvict(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid") |
| | | public void logout(String uuid){ |
| | | } |