<?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') >= date_format(#{params.beginTime},'%y%m%d')
|
</if>
|
<if test="params.endTime != null and params.endTime != ''">
|
and date_format(create_time,'%y%m%d') <= 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>
|