<?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.abuwx.mapper.UserInfoMapper">
    
    <resultMap type="UserInfo" id="UserInfoResult">
        <result property="id"    column="id"    />
        <result property="headPortait"    column="head_portait"    />
        <result property="nickName"    column="nick_name"    />
        <result property="content"    column="content"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="gender"    column="gender"    />
        <result property="lastLoginTime"    column="last_login_time"    />
    </resultMap>

    <sql id="selectUserInfoVo">
        select id, head_portait, nick_name, content, remark, create_time, update_time, create_by, update_by, gender, last_login_time from user_info
    </sql>

    <select id="selectUserInfoList" parameterType="UserInfo" resultMap="UserInfoResult">
        <include refid="selectUserInfoVo"/>
        <where>  
            <if test="headPortait != null  and headPortait != ''"> and head_portait = #{headPortait}</if>
            <if test="nickName != null "> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="gender != null  and gender != ''"> and gender = #{gender}</if>
            <if test="lastLoginTime != null "> and last_login_time = #{lastLoginTime}</if>
        </where>
    </select>
    
    <select id="selectUserInfoById" parameterType="Long" resultMap="UserInfoResult">
        <include refid="selectUserInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertUserInfo" parameterType="UserInfo" useGeneratedKeys="true" keyProperty="id">
        insert into user_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="headPortait != null">head_portait,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="content != null">content,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="gender != null">gender,</if>
            <if test="lastLoginTime != null">last_login_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="headPortait != null">#{headPortait},</if>
            <if test="nickName != null">#{nickName},</if>
            <if test="content != null">#{content},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="gender != null">#{gender},</if>
            <if test="lastLoginTime != null">#{lastLoginTime},</if>
         </trim>
    </insert>

    <update id="updateUserInfo" parameterType="UserInfo">
        update user_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="headPortait != null">head_portait = #{headPortait},</if>
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="content != null">content = #{content},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUserInfoById" parameterType="Long">
        delete from user_info where id = #{id}
    </delete>

    <delete id="deleteUserInfoByIds" parameterType="String">
        delete from user_info where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>