From 1cf88d43994ec7ec403319032a9d118b39fe3571 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 25 四月 2025 14:35:35 +0800
Subject: [PATCH] 登录代码优化

---
 pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java |  103 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 103 insertions(+), 0 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
new file mode 100644
index 0000000..05687dd
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java
@@ -0,0 +1,103 @@
+package com.dy.sso.busi;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.dy.pipIrrGlobal.daoBa.BaCaptchaMapper;
+import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
+import com.dy.pipIrrGlobal.pojoBa.BaUser;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class SsoSv {
+    private BaUserMapper baUserMapper;
+
+    @Autowired
+    private void setBaUserMapper(BaUserMapper baUserMapper){
+        this.baUserMapper = baUserMapper ;
+    }
+
+    @Autowired
+    private BaCaptchaMapper baCaptchaMapper;
+
+    /**
+     * 闇�瑕丅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
+    @Cacheable(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid", sync=true)
+    public BaUser loginWithMapperXml(String uuid, String phone, String password){
+        return this.baUserMapper.login(phone, password) ;
+    }
+
+    /**
+     * 涓嶉渶瑕� 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);
+        return this.baUserMapper.selectOne(qw) ;
+    }
+
+    @CacheEvict(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid")
+    public void logout(String uuid){
+    }
+
+    @Cacheable(cacheNames=CacheConstants.cacheNames, key="'" + CacheConstants.loginUserKeyPrefix + "' + #uuid")
+    public BaUser getByUuid(String uuid){
+        //姝ゆ柟娉曠洰鐨勬槸鐩存帴浠庣紦瀛樹腑璇诲彇锛屽鏋滅紦瀛樻棤姝ゅ�硷紝璇存槑鏁版嵁琚竻闄や簡锛岃繑鍥瀗ull鍊硷紝闇�瑕侀噸鏂扮櫥褰�
+        return null ;
+    }
+
+    /**
+     * 鍒ゆ柇鎵嬫満鍙锋槸鍚﹀瓨鍦�
+     * @return
+     */
+    public boolean existPhone(String phone){
+        Long count = baUserMapper.countPhone(phone) ;
+        if(count == null || count == 0){
+            return false ;
+        }
+        return true ;
+    }
+
+    /**
+     * 寰楀埌鎵�鏈夌敤鎴锋墜鏈哄彿
+     * @return
+     */
+    public List<String> getPhones(){
+        return baUserMapper.getPhones() ;
+    }
+
+    /**
+     * 渚濇嵁楠岃瘉鐮乼oken鑾峰彇楠岃瘉瀛楃
+     * @param token
+     * @return
+     */
+    public Map getCodeByToken(String token) {
+        return baCaptchaMapper.getCodeByToken(token);
+    }
+}

--
Gitblit v1.8.0