Files
xservice-auth-center/xs-service/src/main/resources/mapper/user/XUserMapper.xml
2025-08-25 22:54:41 +08:00

226 lines
8.3 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" />
</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
</sql>
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.auth.service.entity.XUser">
INSERT INTO x_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != name and '' != name">
name,
</if>
<if test="null != username and '' != username">
username,
</if>
<if test="null != password and '' != password">
password,
</if>
<if test="null != email and '' != email">
email,
</if>
<if test="null != phone and '' != phone">
phone,
</if>
<if test="null != avatar and '' != avatar">
avatar,
</if>
<if test="null != loginIp and '' != loginIp">
login_ip,
</if>
<if test="null != loginDate ">
login_date,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != status ">
status,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != updateTime ">
update_time
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != name and '' != name">
#{name},
</if>
<if test="null != username and '' != username">
#{username},
</if>
<if test="null != password and '' != password">
#{password},
</if>
<if test="null != email and '' != email">
#{email},
</if>
<if test="null != phone and '' != phone">
#{phone},
</if>
<if test="null != avatar and '' != avatar">
#{avatar},
</if>
<if test="null != loginIp and '' != loginIp">
#{loginIp},
</if>
<if test="null != loginDate ">
#{loginDate},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != updateTime ">
#{updateTime}
</if>
</trim>
</insert>
<insert id="insertBatch">
insert into x_user(name, username, password, email, phone, status) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.name}, #{item.username}, #{item.password}, #{item.email}, #{item.phone}, #{item.status})
</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>
</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 and status = 1
</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>