<?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.SuggestionFjMapper">

    <resultMap type="SuggestionFj" id="SuggestionFjResult">
        <result property="suggestionFjId" column="suggestion_fj_id"/>
        <result property="suggestionId" column="suggestion_id"/>
        <result property="oldName" column="old_name"/>
        <result property="name" column="name"/>
        <result property="url" column="url"/>
        <result property="bigType" column="big_type"/>
        <result property="type" column="type"/>
        <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="selectSuggestionFjVo">
        select suggestion_fj_id,
               suggestion_id,
               old_name,
               name,
               url,
               big_type,
               type,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from suggestion_fj
    </sql>

    <select id="selectSuggestionFjList" parameterType="SuggestionFj" resultMap="SuggestionFjResult">
        <include refid="selectSuggestionFjVo"/>
        <where>
            <if test="suggestionId != null ">and suggestion_id = #{suggestionId}</if>
            <if test="oldName != null  and oldName != ''">and old_name like concat('%', #{oldName}, '%')</if>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="url != null  and url != ''">and url = #{url}</if>
            <if test="bigType != null  and bigType != ''">and big_type = #{bigType}</if>
            <if test="type != null  and type != ''">and type = #{type}</if>
        </where>
    </select>

    <select id="selectSuggestionFjBySuggestionFjId" parameterType="Long" resultMap="SuggestionFjResult">
        <include refid="selectSuggestionFjVo"/>
        where suggestion_fj_id = #{suggestionFjId}
    </select>

    <insert id="insertSuggestionFj" parameterType="SuggestionFj" useGeneratedKeys="true" keyProperty="suggestionFjId">
        insert into suggestion_fj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="suggestionId != null">suggestion_id,</if>
            <if test="oldName != null">old_name,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="url != null">url,</if>
            <if test="bigType != null">big_type,</if>
            <if test="type != null">type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="suggestionId != null">#{suggestionId},</if>
            <if test="oldName != null">#{oldName},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="url != null">#{url},</if>
            <if test="bigType != null">#{bigType},</if>
            <if test="type != null">#{type},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>
    <insert id="batchSuggestionFj">
        insert into suggestion_fj( suggestion_id, old_name, name,url,create_time) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.suggestionId}, #{item.oldName}, #{item.name},#{item.url},sysdate())
        </foreach>
    </insert>

    <update id="updateSuggestionFj" parameterType="SuggestionFj">
        update suggestion_fj
        <trim prefix="SET" suffixOverrides=",">
            <if test="suggestionId != null">suggestion_id = #{suggestionId},</if>
            <if test="oldName != null">old_name = #{oldName},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="url != null">url = #{url},</if>
            <if test="bigType != null">big_type = #{bigType},</if>
            <if test="type != null">type = #{type},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where suggestion_fj_id = #{suggestionFjId}
    </update>

    <delete id="deleteSuggestionFjBySuggestionFjId" parameterType="Long">
        delete
        from suggestion_fj
        where suggestion_fj_id = #{suggestionFjId}
    </delete>

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