AfmsInventoryFeedPurchaseMapper.xml 3.7 KB
<?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.zhonglai.luhui.afms.mapper.AfmsInventoryFeedPurchaseMapper">
    
    <resultMap type="AfmsInventoryFeedPurchase" id="AfmsInventoryFeedPurchaseResult">
        <result property="id"    column="id"    />
        <result property="feed_id"    column="feed_id"    />
        <result property="purchase_time"    column="purchase_time"    />
        <result property="weight"    column="weight"    />
        <result property="unit_price"    column="unit_price"    />
        <result property="total_price"    column="total_price"    />
    </resultMap>

    <sql id="selectAfmsInventoryFeedPurchaseVo">
        select `id`, `feed_id`, `purchase_time`, `weight`, `unit_price`, `total_price` from afms_inventory_feed_purchase
    </sql>

    <select id="selectAfmsInventoryFeedPurchaseList" parameterType="AfmsInventoryFeedPurchase" resultMap="AfmsInventoryFeedPurchaseResult">
        <include refid="selectAfmsInventoryFeedPurchaseVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="feed_id != null "> and feed_id = #{feed_id}</if>
            <if test="params.beginPurchase_time != null and params.beginPurchase_time != '' and params.endPurchase_time != null and params.endPurchase_time != ''"> and purchase_time between #{params.beginPurchase_time} and #{params.endPurchase_time}</if>
        </where>
    </select>
    
    <select id="selectAfmsInventoryFeedPurchaseById" parameterType="Integer" resultMap="AfmsInventoryFeedPurchaseResult">
        <include refid="selectAfmsInventoryFeedPurchaseVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsInventoryFeedPurchase" parameterType="AfmsInventoryFeedPurchase" useGeneratedKeys="true" keyProperty="id">
        insert into afms_inventory_feed_purchase
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="feed_id != null">feed_id,</if>
            <if test="purchase_time != null">purchase_time,</if>
            <if test="weight != null">weight,</if>
            <if test="unit_price != null">unit_price,</if>
            <if test="total_price != null">total_price,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="feed_id != null">#{feed_id},</if>
            <if test="purchase_time != null">#{purchase_time},</if>
            <if test="weight != null">#{weight},</if>
            <if test="unit_price != null">#{unit_price},</if>
            <if test="total_price != null">#{total_price},</if>
         </trim>
    </insert>

    <update id="updateAfmsInventoryFeedPurchase" parameterType="AfmsInventoryFeedPurchase">
        update afms_inventory_feed_purchase
        <trim prefix="SET" suffixOverrides=",">
            <if test="feed_id != null">feed_id = #{feed_id},</if>
            <if test="purchase_time != null">purchase_time = #{purchase_time},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="unit_price != null">unit_price = #{unit_price},</if>
            <if test="total_price != null">total_price = #{total_price},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsInventoryFeedPurchaseById" parameterType="Integer">
        delete from afms_inventory_feed_purchase where id = #{id}
    </delete>

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