<?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.orderPlan.mapper.FtmsorderbillsattachsMapper">

    <resultMap type="ftmsorderbillsattachs" id="ftmsorderbillsattachsResult">
        <result property="id"    column="id"    />
        <result property="pId"    column="p_id"    />
        <result property="orgId"    column="org_id"    />
        <result property="actId"    column="act_id"    />
        <result property="attachUrl"    column="attach_url"    />
        <result property="attachName"    column="attach_name"    />
        <result property="billStatus"    column="bill_status"    />
        <result property="delFlag"    column="del_flag"    />
        <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="remarks"    column="remarks"    />
        <result property="thumbnailUrl"    column="thumbnail_url"    />
    </resultMap>

    <sql id="selectftmsorderbillsattachsVo">
        select id, p_id, org_id, act_id, attach_url, attach_name, bill_status, del_flag, create_by, create_time, update_by, update_time, remarks, thumbnail_url from F_TMSORDERBILLSATTACHS
    </sql>

    <select id="selectftmsorderbillsattachsList" parameterType="ftmsorderbillsattachs"
            resultMap="ftmsorderbillsattachsResult">
        <include refid="selectftmsorderbillsattachsVo"/>
        <where>
            <if test="pId != null ">and p_id = #{pId}</if>
            <if test="orgId != null ">and org_id = #{orgId}</if>
            <if test="actId != null ">and act_id = #{actId}</if>
            <if test="attachUrl != null  and attachUrl != ''">and attach_url = #{attachUrl}</if>
            <if test="attachName != null  and attachName != ''">and attach_name like concat('%', #{attachName}, '%')</if>
            <if test="billStatus != null ">and bill_status = #{billStatus}</if>
            <if test="remarks != null  and remarks != ''">and remarks = #{remarks}</if>
        </where>
    </select>

    <select id="selectftmsorderbillsattachsById" parameterType="Long" resultMap="ftmsorderbillsattachsResult">
        <include refid="selectftmsorderbillsattachsVo"/>
        where id = #{id}
    </select>

    <insert id="insertftmsorderbillsattachs" parameterType="ftmsorderbillsattachs" useGeneratedKeys="true"
            keyProperty="id">
        insert into F_TMSORDERBILLSATTACHS
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pId != null">p_id,</if>
            <if test="orgId != null">org_id,</if>
            <if test="actId != null">act_id,</if>
            <if test="attachUrl != null">attach_url,</if>
            <if test="attachName != null">attach_name,</if>
            <if test="billStatus != null">bill_status,</if>
            <if test="delFlag != null">del_flag,</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="remarks != null">remarks,</if>
            <if test="thumbnailUrl != null">thumbnail_url,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pId != null">#{pId},</if>
            <if test="orgId != null">#{orgId},</if>
            <if test="actId != null">#{actId},</if>
            <if test="attachUrl != null">#{attachUrl},</if>
            <if test="attachName != null">#{attachName},</if>
            <if test="billStatus != null">#{billStatus},</if>
            <if test="delFlag != null">#{delFlag},</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="remarks != null">#{remarks},</if>
            <if test="thumbnailUrl != null">#{thumbnailUrl},</if>
        </trim>
    </insert>

    <update id="updateftmsorderbillsattachs" parameterType="ftmsorderbillsattachs">
        update F_TMSORDERBILLSATTACHS
        <trim prefix="SET" suffixOverrides=",">
            <if test="pId != null">p_id = #{pId},</if>
            <if test="orgId != null">org_id = #{orgId},</if>
            <if test="actId != null">act_id = #{actId},</if>
            <if test="attachUrl != null">attach_url = #{attachUrl},</if>
            <if test="attachName != null">attach_name = #{attachName},</if>
            <if test="billStatus != null">bill_status = #{billStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="remarks != null">remarks = #{remarks},</if>
            <if test="thumbnailUrl != null">thumbnail_url = #{thumbnailUrl},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteftmsorderbillsattachsById" parameterType="Long">
        delete from F_TMSORDERBILLSATTACHS where id = #{id}
    </delete>

    <delete id="deleteftmsorderbillsattachsByPId" parameterType="Long">
        delete from F_TMSORDERBILLSATTACHS where p_id = #{id}
    </delete>

    <delete id="deleteftmsorderbillsattachs" parameterType="ftmsorderbillsattachs">
        delete from F_TMSORDERBILLSATTACHS
        <where>
            <if test="pId != null ">and p_id = #{pId}</if>
            <if test="orgId != null ">and org_id = #{orgId}</if>
            <if test="actId != null ">and act_id = #{actId}</if>
            <if test="attachUrl != null  and attachUrl != ''">and attach_url = #{attachUrl}</if>
            <if test="attachName != null  and attachName != ''">and attach_name like concat('%', #{attachName}, '%')</if>
            <if test="billStatus != null ">and bill_status = #{billStatus}</if>
            <if test="remarks != null  and remarks != ''">and remarks = #{remarks}</if>
        </where>
    </delete>

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

</mapper>