From bbe9826b889664d124e2fac69b5b900ad97f8351 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 30 五月 2024 09:16:17 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 50 insertions(+), 4 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java index 249facb..52c1c6a 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java @@ -1,5 +1,7 @@ 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; import lombok.extern.slf4j.Slf4j; @@ -7,23 +9,67 @@ import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Slf4j @Service public class SsoSv { private BaUserMapper baUserMapper; + private BaPrivilegeMapper baPrivilegeMapper; @Autowired private void setBaUserMapper(BaUserMapper baUserMapper){ this.baUserMapper = baUserMapper ; } + @Autowired + private void setBaPrivilegeMapper(BaPrivilegeMapper baPrivilegeMapper){ + this.baPrivilegeMapper = baPrivilegeMapper ; + } + + + /** + * 闇�瑕丅aUserMapper.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 + @Transactional @Cacheable(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid", sync=true) - public BaUser login(String uuid, String phone, String password){ - return this.baUserMapper.login(phone, 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") @@ -32,7 +78,7 @@ @Cacheable(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid") public BaUser getByUuid(String uuid){ - //姝ゆ柟娉曠洰鐨勬槸鐩存帴浠庣紦瀛樹腑璇诲彇锛屽鏋滅紦瀛樻棤姝ゅ�硷紝璇存槑鏁版嵁琚竻妤氫簡锛岃繑鍥瀗ull鍊硷紝闇�瑕侀噸鏂扮櫥褰� + //姝ゆ柟娉曠洰鐨勬槸鐩存帴浠庣紦瀛樹腑璇诲彇锛屽鏋滅紦瀛樻棤姝ゅ�硷紝璇存槑鏁版嵁琚竻闄や簡锛岃繑鍥瀗ull鍊硷紝闇�瑕侀噸鏂扮櫥褰� return null ; } -- Gitblit v1.8.0