<?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.change.mapper.TbAssetOrderDetailMapper">
    
    <resultMap type="TbAssetOrderDetail" id="TbAssetOrderDetailResult">
        <result property="id"    column="id"    />
        <result property="orderNumber"    column="order_number"    />
        <result property="assetNumber"    column="asset_number"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTbAssetOrderDetailVo">
        select id, order_number, asset_number, remark from tb_asset_order_detail
    </sql>

    <select id="selectTbAssetOrderDetailList" parameterType="TbAssetOrderDetail" resultMap="TbAssetOrderDetailResult">
        <include refid="selectTbAssetOrderDetailVo"/>
        <where>  
            <if test="orderNumber != null  and orderNumber != ''"> and order_number = #{orderNumber}</if>
            <if test="assetNumber != null  and assetNumber != ''"> and asset_number = #{assetNumber}</if>
        </where>
    </select>
    
    <select id="selectTbAssetOrderDetailById" parameterType="Long" resultMap="TbAssetOrderDetailResult">
        <include refid="selectTbAssetOrderDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTbAssetOrderDetail" parameterType="TbAssetOrderDetail" useGeneratedKeys="true" keyProperty="id">
        insert into tb_asset_order_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNumber != null and orderNumber != ''">order_number,</if>
            <if test="assetNumber != null and assetNumber != ''">asset_number,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNumber != null and orderNumber != ''">#{orderNumber},</if>
            <if test="assetNumber != null and assetNumber != ''">#{assetNumber},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTbAssetOrderDetail" parameterType="TbAssetOrderDetail">
        update tb_asset_order_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNumber != null and orderNumber != ''">order_number = #{orderNumber},</if>
            <if test="assetNumber != null and assetNumber != ''">asset_number = #{assetNumber},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTbAssetOrderDetailById" parameterType="Long">
        delete from tb_asset_order_detail where id = #{id}
    </delete>

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