xiaoyong931011
2021-04-23 92fb3070e7b46a1afd7e6b038f45a9fb37d0eaa3
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?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.xcong.excoin.system.mapper.UserMapper">
    <sql id="countUserDetailSql" >
        SELECT
        COUNT(1)
        FROM
        t_user u
        WHERE 1 = 1
        <if test="user.username != null and user.username != ''">
            AND u.username = #{user.username}
        </if>
        <if test="user.deptId != null and user.deptId != ''">
            AND u.dept_id = #{user.deptId}
        </if>
        <if test="user.sex != null and user.sex != ''">
            AND u.ssex = #{user.sex}
        </if>
        <if test="user.status != null and user.status != ''">
            AND u.status = #{user.status}
        </if>
        <if test="user.mobile != null and user.mobile != ''">
            AND u.mobile = #{user.mobile}
        </if>
        <if test="user.createTimeFrom != null and user.createTimeFrom !=''">
            And u.create_time &gt; #{user.createTimeFrom}
        </if>
        <if test="user.createTimeTo!= null and user.createTimeTo !=''">
            And u.create_time &lt; #{user.createTimeTo}
        </if>
    </sql>
 
    <sql id="findUserDetailSql">
        SELECT
        u.user_id userId,
        u.username,
        u.email,
        u.mobile,
        u.status,
        u.create_time createTime,
        u.ssex sex,
        u.dept_id deptId,
        u.last_login_time lastLoginTime,
        u.modify_time modifyTime,
        u.description,
        u.avatar,
        u.invite_id,
        u.system,
        u.type,
        u.agent_name,
        d.dept_name deptName,
        GROUP_CONCAT(r.role_id) roleId,
        GROUP_CONCAT(r.ROLE_NAME) roleName
        FROM
        t_user u
        LEFT JOIN t_dept d ON (u.dept_id = d.dept_id)
        LEFT JOIN t_user_role ur ON (u.user_id = ur.user_id)
        LEFT JOIN t_role r ON r.role_id = ur.role_id
        WHERE 1 = 1
        <if test="user.username != null and user.username != ''">
            AND u.username = #{user.username}
        </if>
        <if test="user.deptId != null and user.deptId != ''">
            AND d.dept_id = #{user.deptId}
        </if>
        <if test="user.sex != null and user.sex != ''">
            AND u.ssex = #{user.sex}
        </if>
        <if test="user.status != null and user.status != ''">
            AND u.status = #{user.status}
        </if>
        <if test="user.mobile != null and user.mobile != ''">
            AND u.mobile = #{user.mobile}
        </if>
        <if test="user.createTimeFrom != null and user.createTimeFrom !=''">
            And u.create_time &gt; #{user.createTimeFrom}
        </if>
        <if test="user.createTimeTo!= null and user.createTimeTo !=''">
            And u.create_time &lt; #{user.createTimeTo}
        </if>
        GROUP BY
            u.username,
            u.user_id,
            u.email,
            u.mobile,
            u.status,
            u.create_time,
            u.ssex,
            u.dept_id,
            u.last_login_time,
            u.modify_time,
            u.description,
            u.avatar,
            u.invite_id,
            u.system,
            u.type,
            u.agent_name
    </sql>
 
    <select id="countUserDetail" parameterType="user" resultType="long">
        <include refid="countUserDetailSql"/>
    </select>
 
    <select id="findUserDetailPage" parameterType="user" resultType="user">
        <include refid="findUserDetailSql"/>
    </select>
 
    <select id="findUserDetail" parameterType="user" resultType="user">
        <include refid="findUserDetailSql"/>
    </select>
 
    <select id="findByName" parameterType="string" resultType="user">
        SELECT
        u.user_id userId,
        u.username,
        u.email,
        u.mobile,
        u.password,
        u.status,
        u.create_time createTime,
        u.ssex sex,
        u.dept_id deptId,
        u.last_login_time lastLoginTime,
        u.modify_time modifyTime,
        u.description,
        u.avatar,
        u.invite_id,
        u.system,
        u.type,
        u.agent_name,
        u.theme,
        u.is_tab isTab,
        d.dept_name deptName,
        GROUP_CONCAT(r.role_id) roleId,
        GROUP_CONCAT(r.ROLE_NAME) roleName
        FROM
        t_user u
        LEFT JOIN t_dept d ON (u.dept_id = d.dept_id)
        LEFT JOIN t_user_role ur ON (u.user_id = ur.user_id)
        LEFT JOIN t_role r ON r.role_id = ur.role_id
        WHERE  u.username = #{username}
        GROUP BY
            u.username,
            u.user_id,
            u.email,
            u.mobile,
            u.password,
            u.status,
            u.create_time,
            u.ssex,
            u.dept_id,
            u.last_login_time,
            u.modify_time,
            u.description,
            u.avatar,
            u.invite_id,
            u.system,
            u.type,
            u.agent_name,
            u.theme,
            u.is_tab
    </select>
 
    <select id="findUserDataPermissions" parameterType="long" resultType="userDataPermission">
        select user_id userId, dept_id deptId from t_user_data_permission
        where user_id = #{userId}
    </select>
 
    <select id="selectAgentUserList" resultType="com.xcong.excoin.modules.agent.pojo.AgentUser">
        select
            a.user_id id,
            a.username account,
            a.agent_name name,
            a.invite_id,
            a.create_time,
            a.status,
            b.return_ratio,
            a.mobile telphone,
            c.referer_id refererId,
            c.certify_status
        from t_user a
        inner join agent_friend_relation b on a.user_id = b.user_id
        inner join member c on b.member_id = c.id
        <if test="record != null">
            <where>
                <if test="record.refererId!=null and record.refererId!=''">
                    find_in_set(#{record.refererId}, b.referer_ids)
                </if>
                <if test="record.startTime!=null and record.startTime!=''">
                    and c.create_time >=#{record.startTime}
                </if>
                <if test="record.endTime!=null and record.endTime!=''">
                    and #{record.endTime} >= c.create_time
                </if>
                <if test="record.account!=null and record.account!=''">
                    and (c.phone = #{record.account} or c.email = #{record.account} or c.invite_id=#{record.account})
                </if>
                <if test="record.accountStatus != null and record.accountStatus!=''" >
                    and a.status = #{record.accountStatus}
                </if>
                <if test="record.accountType != null and record.accountType!=''" >
                    and c.account_type = #{record.accountType}
                </if>
                <if test="record.certifyStatus!=null and record.certifyStatus!=''and record.certifyStatus!='6' ">
                    and c.certify_status = #{record.certifyStatus}
                </if>
            </where>
        </if>
    </select>
 
    <select id="selectUserByInviteId" resultType="user">
        select * from t_user where invite_id=#{inviteId}
    </select>
 
    <select id="selectUserInfoById" resultType="user">
        select
            a.user_id,
            a.agent_name,
            a.username,
            a.mobile,
            a.invite_id,
            b.return_ratio
        from t_user a
        left join agent_friend_relation b on a.user_id=b.user_id
        where a.user_id=#{id}
    </select>
</mapper>