<?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.hzya.frame.seeyon.dao.impl.CtpAttachmentDaoImpl">
    <resultMap id="get-CtpAttachmentEntity-result" type="com.hzya.frame.seeyon.entity.CtpAttachmentEntity">
        <result property="id" column="id" />
        <result property="sub_reference" column="sub_reference" />
        <result property="category" column="category" />
        <result property="type" column="type" />
        <result property="filename" column="filename" />
        <result property="file_url" column="file_url" />
        <result property="mime_type" column="mime_type" />
        <result property="createdate" column="createdate" />
        <result property="attachment_size" column="attachment_size" />
        <result property="sort" column="sort" />
        <result property="att_reference" column="att_reference" />
    </resultMap>

    <sql id="CtpAttachmentEntity_Column_List">
		id,
		sub_reference,
		category,
		type,
		filename,
		file_url,
		mime_type,
		createdate,
		attachment_size,
		sort,
		att_reference
	</sql>



    <!-- 查询 采用==查询 -->
    <select id="entity_list_base" resultMap="get-CtpAttachmentEntity-result" parameterType="com.hzya.frame.seeyon.entity.CtpAttachmentEntity">
        select
        <include refid="CtpAttachmentEntity_Column_List" />
        from CTP_ATTACHMENT
        <trim prefix="where" prefixOverrides="and">
            <if test="file_url != null and file_url !='' ">file_url = #{file_url} </if>
        </trim>
    </select>

    <!-- 新增 -->
    <insert id="entity_insert" parameterType="com.hzya.frame.seeyon.entity.CtpAttachmentEntity">
        insert into CTP_ATTACHMENT(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id !='' "> id, </if>
            <if test="sub_reference != null and sub_reference !='' "> sub_reference, </if>
            <if test="category != null and category !='' "> category, </if>
            <if test="type != null and type !='' "> type, </if>
            <if test="filename != null and filename !='' "> filename, </if>
            <if test="file_url != null and file_url !='' "> file_url, </if>
            <if test="mime_type != null and mime_type !='' "> mime_type, </if>
            <if test="attachment_size != null and attachment_size !='' "> attachment_size, </if>
            <if test="sort != null and sort !='' "> sort, </if>
            <if test="att_reference != null and att_reference !='' "> att_reference, </if>
            <if test="createdate != null"> createdate</if>
        </trim>
        )values
        (
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id !='' "> #{id}, </if>
            <if test="sub_reference != null and sub_reference !='' "> #{sub_reference}, </if>
            <if test="category != null and category !='' "> #{category}, </if>
            <if test="type != null and type !='' "> #{type}, </if>
            <if test="filename != null and filename !='' "> #{filename}, </if>
            <if test="file_url != null and file_url !='' "> #{file_url}, </if>
            <if test="mime_type != null and mime_type !='' "> #{mime_type}, </if>
            <if test="attachment_size != null and attachment_size !='' "> #{attachment_size}, </if>
            <if test="sort != null and sort !='' "> #{sort}, </if>
            <if test="att_reference != null and att_reference !='' "> #{att_reference}, </if>
            <if test="createdate != null "> #{createdate}</if>
        </trim>
        )
    </insert>

    <!-- 修改 付款单中的电子回单字段-->
    <update id="entity_update" parameterType="com.hzya.frame.seeyon.entity.CtpAttachmentEntity">
        update CTP_ATTACHMENT set
        <trim suffix="" suffixOverrides=",">
            <if test="sub_reference != null and sub_reference !='' "> sub_reference = #{sub_reference},</if>
            <if test="att_reference != null and att_reference !='' "> att_reference = #{att_reference}</if>
        </trim>
        where file_url = #{file_url}
    </update>


</mapper>
