Files
xservice-auth-center/xs-service/src/main/resources/mapper/user/XUserMapper.xml
2026-03-20 17:15:56 +08:00

143 lines
5.8 KiB
XML

<?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.xiang.xservice.auth.service.repository.mapper.XUserMapper">
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XUser" >
<result column="id" property="id" />
<result column="name" property="name" />
<result column="username" property="username" />
<result column="password" property="password" />
<result column="email" property="email" />
<result column="phone" property="phone" />
<result column="avatar" property="avatar" />
<result column="login_ip" property="loginIp" />
<result column="login_date" property="loginDate" />
<result column="status" property="status"/>
<result column="del_flag" property="delFlag" />
<result column="create_by" property="createBy" />
<result column="create_time" property="createTime" />
<result column="update_by" property="updateBy" />
<result column="update_time" property="updateTime" />
<result column="tenant_id" property="tenantId"/>
<result column="token" property="token"/>
<result column="refresh_token" property="refreshToken"/>
</resultMap>
<sql id="Base_Column_List">
id,
name,
username,
password,
email,
phone,
avatar,
login_ip,
login_date,
status,
del_flag,
create_by,
create_time,
update_by,
update_time,
tenant_id,
token,
refresh_token
</sql>
<insert id="insertBatch">
insert into x_user(name, username, password, email, phone, status, tenant_id) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.name}, #{item.username}, #{item.password}, #{item.email}, #{item.phone}, #{item.status}, #{item.tenantId})
</foreach>
</insert>
<update id="delete" >
update x_user set del_flag = 1 where id = #{id}
</update>
<update id="update" parameterType="com.xiang.xservice.auth.service.entity.XUser">
UPDATE x_user
<set>
<if test="null != name and '' != name">name = #{name},</if>
<if test="null != username and '' != username">username = #{username},</if>
<if test="null != password and '' != password">password = #{password},</if>
<if test="null != email and '' != email">email = #{email},</if>
<if test="null != phone and '' != phone">phone = #{phone},</if>
<if test="null != avatar and '' != avatar">avatar = #{avatar},</if>
<if test="null != loginIp and '' != loginIp">login_ip = #{loginIp},</if>
<if test="null != loginDate ">login_date = #{loginDate},</if>
<if test="null != delFlag ">del_flag = #{delFlag},</if>
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
<if test="null != createTime ">create_time = #{createTime},</if>
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
<if test="null != updateTime ">update_time = #{updateTime},</if>
<if test="null != tenantId ">tenant_id = #{tenantId},</if>
<if test="null != token and '' != token ">token = #{token},</if>
<if test="null != refreshToken and '' != refreshToken ">refresh_token = #{refreshToken}</if>
</set>
WHERE id = #{id}
</update>
<update id="deleteBatch">
update x_user set del_flag = 0, update_time = #{time}, update_by = #{operator} where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
<select id="selectByUsername" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_user
where username = #{username} and del_flag = 0
</select>
<select id="getUserList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_user
<trim prefix="AND">
<where>
<if test="name != null and name != ''">
AND name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="username != null and username != ''">
AND username = #{username}
</if>
<if test="email != null and email != ''">
AND email = #{email}
</if>
<if test="phone != null and phone != ''">
AND phone = #{phone}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="delFlag != null">
AND del_flag = #{delFlag}
</if>
<if test="loginIp != null and loginIp != ''">
AND login_ip = #{loginIp}
</if>
<if test="loginDate != null">
AND login_date = #{loginDate}
</if>
<if test="createBy != null and createBy != ''">
AND create_by = #{createBy}
</if>
<if test="updateBy != null and updateBy != ''">
AND update_by = #{updateBy}
</if>
<if test="createTime != null">
AND create_time &gt;= #{createTime}
</if>
<if test="updateTime != null">
AND update_time &lt;= #{updateTime}
</if>
</where>
</trim>
</select>
<select id="getUserById" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_user
where id = #{id}
</select>
</mapper>