AfmsRevenueHarvestDetailMapper.xml 4.1 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.AfmsRevenueHarvestDetailMapper">
    
    <resultMap type="AfmsRevenueHarvestDetail" id="AfmsRevenueHarvestDetailResult">
        <result property="id"    column="id"    />
        <result property="harvest_id"    column="harvest_id"    />
        <result property="specification_range"    column="specification_range"    />
        <result property="unit_price"    column="unit_price"    />
        <result property="weight"    column="weight"    />
        <result property="quantity"    column="quantity"    />
        <result property="harvest_value"    column="harvest_value"    />
    </resultMap>

    <sql id="selectAfmsRevenueHarvestDetailVo">
        select `id`, `harvest_id`, `specification_range`, `unit_price`, `weight`, `quantity`, `harvest_value` from afms_revenue_harvest_detail
    </sql>

    <select id="selectAfmsRevenueHarvestDetailList" parameterType="AfmsRevenueHarvestDetail" resultMap="AfmsRevenueHarvestDetailResult">
        <include refid="selectAfmsRevenueHarvestDetailVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="harvest_id != null "> and harvest_id = #{harvest_id}</if>
            <if test="specification_range != null  and specification_range != ''"> and specification_range like concat('%', #{specification_range}, '%')</if>
            <if test="quantity != null "> and quantity = #{quantity}</if>
        </where>
    </select>
    
    <select id="selectAfmsRevenueHarvestDetailById" parameterType="Integer" resultMap="AfmsRevenueHarvestDetailResult">
        <include refid="selectAfmsRevenueHarvestDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsRevenueHarvestDetail" parameterType="AfmsRevenueHarvestDetail" useGeneratedKeys="true" keyProperty="id">
        insert into afms_revenue_harvest_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="harvest_id != null">harvest_id,</if>
            <if test="specification_range != null and specification_range != ''">specification_range,</if>
            <if test="unit_price != null">unit_price,</if>
            <if test="weight != null">weight,</if>
            <if test="quantity != null">quantity,</if>
            <if test="harvest_value != null">harvest_value,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="harvest_id != null">#{harvest_id},</if>
            <if test="specification_range != null and specification_range != ''">#{specification_range},</if>
            <if test="unit_price != null">#{unit_price},</if>
            <if test="weight != null">#{weight},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="harvest_value != null">#{harvest_value},</if>
         </trim>
    </insert>

    <update id="updateAfmsRevenueHarvestDetail" parameterType="AfmsRevenueHarvestDetail">
        update afms_revenue_harvest_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="harvest_id != null">harvest_id = #{harvest_id},</if>
            <if test="specification_range != null and specification_range != ''">specification_range = #{specification_range},</if>
            <if test="unit_price != null">unit_price = #{unit_price},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="harvest_value != null">harvest_value = #{harvest_value},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsRevenueHarvestDetailById" parameterType="Integer">
        delete from afms_revenue_harvest_detail where id = #{id}
    </delete>

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