thiszhc
2023-06-15 76dc2398757a4038f1930fb475a55983a9a8077a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.SocialUserMapper">
 
    <resultMap type="org.dromara.system.domain.vo.SocialUserVo" id="SocialUserAuthResult">
        <id property="id" column="id"/>
    </resultMap>
 
    <sql id="selectSocialUser">
        select id,
               user_id,
               tenant_id,
               auth_id,
               source,
               open_id,
               access_token,
               expire_in,
               refresh_token,
               access_code,
               union_id,
               scope,
               token_type,
               id_token,
               mac_algorithm,
               mac_key,
               code,
               oauth_token,
               oauth_token_secret,
               create_dept,
               create_by,
               create_time,
               update_by,
               update_time
        from social_user
    </sql>
 
    <!-- 根据userId查询SocialUser表对应userId的SysUser,返回SysUserBo的对象 -->
    <select id="selectSocialUserByUserId" parameterType="String" resultMap="SocialUserAuthResult">
        select b.*
        from social_user a
            left join sys_user b on a.user_id = b.user_id
        where a.user_id = #{userId}
    </select>
 
 
    <!-- 根据authId查询SocialUser表和SysUser表,返回SocialUserAuthResult映射的对象 -->
    <select id="selectSocialUserByAuthId" parameterType="String" resultMap="SocialUserAuthResult">
        select b.user_id as userId,
               b.tenant_id as tenantId,
               b.user_name as userName,
               b.password as password,
               a.auth_id as authId,
               a.source as source
        from social_user a
            left join sys_user b on a.user_id = b.user_id
        where a.auth_id = #{authId}
    </select>
 
    <!-- 根据userId和source查询SocialUser表,返回int类型的结果 -->
    <select id="checkSocialUser" parameterType="org.dromara.system.domain.vo.SocialUserVo" resultType="int">
        select count(*)
        from social_user
        where user_id = #{userId} and source = #{source} limit 1
    </select>
 
</mapper>