xuhy
2025-01-02 b94fffb01c94100b34e2908b4fe79c1c554b0912
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?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="com.ruoyi.system.mapper.TAppUserMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TAppUser">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="phone" property="phone" />
        <result column="avatar" property="avatar" />
        <result column="wx_openid" property="wxOpenid" />
        <result column="ali_openid" property="aliOpenid" />
        <result column="province" property="province" />
        <result column="province_code" property="provinceCode" />
        <result column="city" property="city" />
        <result column="city_code" property="cityCode" />
        <result column="country" property="country" />
        <result column="email" property="email" />
        <result column="address" property="address" />
        <result column="info" property="info" />
        <result column="remark" property="remark" />
        <result column="create_time" property="createTime" />
        <result column="last_login_time" property="lastLoginTime" />
        <result column="status" property="status" />
        <result column="is_delete" property="isDelete" />
        <result column="is_set_preference" property="isSetPreference" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, name, phone, avatar, wx_openid, ali_openid, province, province_code, city, city_code, country, email, address, info, remark, create_time, last_login_time, status, is_delete,is_set_preference
    </sql>
    <select id="getNewIds" resultType="java.lang.Long">
        SELECT
            au.id AS user_id
        FROM
        t_app_user au
                LEFT JOIN (
                SELECT
                    MAX(id) as id,
                    user_id,
                    MAX(create_time) AS newest_create_time
                FROM
                    t_user_change
                WHERE
                    is_delete = 0
                GROUP BY user_id
            ) uc_newest ON au.id = uc_newest.user_id
                LEFT JOIN t_user_change_detail td on td.change_id = uc_newest.id
        <where>
            <if test="appUserQuery.majorId1 != null">
                AND td.major_id = #{appUserQuery.majorId1}
            </if>
            <if test="appUserQuery.titleId1 != null">
                AND td.title_id = #{appUserQuery.titleId1}
            </if>
            <if test="appUserQuery.regionId1 != null">
                AND td.region_id = #{appUserQuery.regionId1}
            </if>
            <if test="appUserQuery.levelId1 != null">
                AND td.level_id = #{appUserQuery.levelId1}
            </if>
        </where>
        GROUP BY au.id
    </select>
    <select id="getNewIds1" resultType="java.lang.Long">
        SELECT
        au.id AS user_id
        FROM
        t_app_user au
        LEFT JOIN (
        SELECT
        id,
        user_id,
        MAX(create_time) AS newest_create_time
        FROM
        t_user_change
        WHERE
        is_delete = 0
        GROUP BY user_id
        ) uc_newest ON au.id = uc_newest.user_id
        LEFT JOIN t_user_change_detail td on td.change_id = uc_newest.id
        <where>
            <if test="appUserQuery.majorId1 != null">
                AND td.major_id = #{appUserQuery.majorId1}
            </if>
            <if test="appUserQuery.titleId1 != null">
                AND td.title_id = #{appUserQuery.titleId1}
            </if>
            <if test="appUserQuery.regionId1 != null">
                AND td.region_id = #{appUserQuery.regionId1}
            </if>
            <if test="appUserQuery.levelId1 != null">
                AND td.level_id = #{appUserQuery.levelId1}
            </if>
        </where>
        GROUP BY au.id
    </select>
    <select id="getLateIds" resultType="java.lang.Long">
        SELECT
        au.id AS user_id
        FROM
        t_app_user au
        LEFT JOIN (
        SELECT
        MIN(id) as id,
        user_id,
        MIN(create_time) AS newest_create_time
        FROM
        t_user_change
        WHERE
        is_delete = 0
        GROUP BY user_id
        ) uc_newest ON au.id = uc_newest.user_id
        LEFT JOIN t_user_change_detail td on td.change_id = uc_newest.id
        <where>
            <if test="appUserQuery.majorId != null">
                AND td.major_id = #{appUserQuery.majorId}
            </if>
            <if test="appUserQuery.titleId != null">
                AND td.title_id = #{appUserQuery.titleId}
            </if>
            <if test="appUserQuery.regionId != null">
                AND td.region_id = #{appUserQuery.regionId}
            </if>
            <if test="appUserQuery.levelId != null">
                AND td.level_id = #{appUserQuery.levelId}
            </if>
        </where>
        GROUP BY au.id
    </select>
 
</mapper>