<?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.system.mapper.FollowInfoMapper">
    
    <resultMap type="FollowInfo" id="FollowInfoResult">
        <result property="followInfoId"    column="follow_info_id"    />
        <result property="followerId"    column="follower_id"    />
        <result property="userId"    column="user_id"    />
        <result property="followTime"    column="follow_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="remark"    column="remark"    />
        <result property="followStatus"    column="follow_status"    />
    </resultMap>

    <sql id="selectFollowInfoVo">
        select follow_info_id, follower_id, user_id, follow_time, del_flag, remark, follow_status from follow_info
    </sql>

    <select id="selectFollowInfoList" parameterType="FollowInfo" resultMap="FollowInfoResult">
        <include refid="selectFollowInfoVo"/>
        <where>  
            <if test="followerId != null  and followerId != ''"> and follower_id = #{followerId}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="followTime != null "> and follow_time = #{followTime}</if>
            <if test="followStatus != null  and followStatus != ''"> and follow_status = #{followStatus}</if>
        </where>
    </select>
    
    <select id="selectFollowInfoByFollowInfoId" parameterType="Long" resultMap="FollowInfoResult">
        <include refid="selectFollowInfoVo"/>
        where follow_info_id = #{followInfoId}
    </select>
        
    <insert id="insertFollowInfo" parameterType="FollowInfo" useGeneratedKeys="true" keyProperty="followInfoId">
        insert into follow_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="followerId != null and followerId != ''">follower_id,</if>
            <if test="userId != null and userId != ''">user_id,</if>
            <if test="followTime != null">follow_time,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="followStatus != null and followStatus != ''">follow_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="followerId != null and followerId != ''">#{followerId},</if>
            <if test="userId != null and userId != ''">#{userId},</if>
            <if test="followTime != null">#{followTime},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="followStatus != null and followStatus != ''">#{followStatus},</if>
         </trim>
    </insert>

    <update id="updateFollowInfo" parameterType="FollowInfo">
        update follow_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="followerId != null and followerId != ''">follower_id = #{followerId},</if>
            <if test="userId != null and userId != ''">user_id = #{userId},</if>
            <if test="followTime != null">follow_time = #{followTime},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="followStatus != null and followStatus != ''">follow_status = #{followStatus},</if>
        </trim>
        where follow_info_id = #{followInfoId}
    </update>

    <delete id="deleteFollowInfoByFollowInfoId" parameterType="Long">
        delete from follow_info where follow_info_id = #{followInfoId}
    </delete>

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