zjk
23 小时以前 f8c73a38709f7120d11b04bd70c6af3ccc53014d
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
<?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.user.mapper.AccountUserMapper">
 
    <resultMap type="AccountUser" id="AccountUserResult">
        <id     property="userId"     column="user_id"     />
        <result property="userName"   column="username"    />
        <result property="phone"      column="phone"       />
        <result property="password"   column="password"    />
        <result property="nickname"   column="nickname"    />
        <result property="avatar"     column="avatar"      />
        <result property="gender"     column="gender"      />
        <result property="birthday"   column="birthday"    />
        <result property="status"     column="status"      />
        <result property="delFlag"    column="del_flag"    />
        <result property="myReferralCode"   column="my_referral_code"   />
        <result property="referrerId"       column="referrer_id"        />
        <result property="systemLevel"      column="system_level"       />
        <result property="createBy"   column="create_by"   />
        <result property="createTime" column="create_time" />
        <result property="updateBy"   column="update_by"   />
        <result property="updateTime" column="update_time" />
        <result property="remark"     column="remark"      />
    </resultMap>
 
    <sql id="selectAccountUserVo">
        select user_id, username, phone, password, nickname, avatar, gender, birthday, status, del_flag, my_referral_code, referrer_id, system_level, create_by, create_time, update_by, update_time, remark
        from account_user
    </sql>
 
    <select id="selectAccountUserList" parameterType="AccountUser" resultMap="AccountUserResult">
        <include refid="selectAccountUserVo"/>
        <where>
            del_flag = '0'
            <if test="userName != null and userName != ''"> and username like concat('%', #{userName}, '%')</if>
            <if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
            <if test="nickname != null and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
            <if test="gender != null and gender != ''"> and gender = #{gender}</if>
            <if test="status != null and status != ''"> and status = #{status}</if>
            <if test="params.beginTime != null and params.beginTime != ''">
                and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
        order by user_id desc
    </select>
 
    <select id="selectAccountUserById" parameterType="Long" resultMap="AccountUserResult">
        <include refid="selectAccountUserVo"/>
        where del_flag = '0' and user_id = #{userId}
    </select>
 
    <select id="selectAccountUserByUsername" parameterType="String" resultMap="AccountUserResult">
        <include refid="selectAccountUserVo"/>
        where del_flag = '0' and username = #{userName}
    </select>
 
    <select id="selectAccountUserByPhone" parameterType="String" resultMap="AccountUserResult">
        <include refid="selectAccountUserVo"/>
        where del_flag = '0' and phone = #{phone}
    </select>
 
    <select id="selectAccountUserByReferralCode" parameterType="String" resultMap="AccountUserResult">
        <include refid="selectAccountUserVo"/>
        where del_flag = '0' and my_referral_code = #{referralCode}
    </select>
 
    <insert id="insertAccountUser" parameterType="AccountUser" useGeneratedKeys="true" keyProperty="userId">
        insert into account_user(
            <if test="userName != null and userName != ''">username,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="password != null and password != ''">password,</if>
            <if test="nickname != null and nickname != ''">nickname,</if>
            <if test="avatar != null and avatar != ''">avatar,</if>
            <if test="gender != null and gender != ''">gender,</if>
            <if test="birthday != null">birthday,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="myReferralCode != null and myReferralCode != ''">my_referral_code,</if>
            <if test="referrerId != null">referrer_id,</if>
            <if test="systemLevel != null and systemLevel != ''">system_level,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            create_time
        )values(
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="password != null and password != ''">#{password},</if>
            <if test="nickname != null and nickname != ''">#{nickname},</if>
            <if test="avatar != null and avatar != ''">#{avatar},</if>
            <if test="gender != null and gender != ''">#{gender},</if>
            <if test="birthday != null">#{birthday},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="myReferralCode != null and myReferralCode != ''">#{myReferralCode},</if>
            <if test="referrerId != null">#{referrerId},</if>
            <if test="systemLevel != null and systemLevel != ''">#{systemLevel},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            sysdate()
        )
    </insert>
 
    <update id="updateAccountUser" parameterType="AccountUser">
        update account_user
        <set>
            <if test="userName != null and userName != ''">username = #{userName},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="password != null and password != ''">password = #{password},</if>
            <if test="nickname != null">nickname = #{nickname},</if>
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="gender != null and gender != ''">gender = #{gender},</if>
            <if test="birthday != null">birthday = #{birthday},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="myReferralCode != null and myReferralCode != ''">my_referral_code = #{myReferralCode},</if>
            <if test="referrerId != null">referrer_id = #{referrerId},</if>
            <if test="systemLevel != null and systemLevel != ''">system_level = #{systemLevel},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            update_time = sysdate()
        </set>
        where user_id = #{userId} and del_flag = '0'
    </update>
 
    <!-- 逻辑删除:保留行,仅置删除标志 -->
    <update id="deleteAccountUserById" parameterType="Long">
        update account_user set del_flag = '2' where user_id = #{userId}
    </update>
 
    <update id="deleteAccountUserByIds" parameterType="Long">
        update account_user set del_flag = '2' where user_id in
        <foreach item="userId" collection="array" open="(" separator="," close=")">
            #{userId}
        </foreach>
    </update>
 
</mapper>