AfmsRevenueHarvestMapper.xml 4.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.AfmsRevenueHarvestMapper">
    
    <resultMap type="AfmsRevenueHarvest" id="AfmsRevenueHarvestResult">
        <result property="id"    column="id"    />
        <result property="harvest_date"    column="harvest_date"    />
        <result property="pond_id"    column="pond_id"    />
        <result property="species_id"    column="species_id"    />
        <result property="customer"    column="customer"    />
        <result property="total_weight"    column="total_weight"    />
        <result property="total_price"    column="total_price"    />
        <result property="labor_cost"    column="labor_cost"    />
        <result property="transportation_cost"    column="transportation_cost"    />
    </resultMap>

    <sql id="selectAfmsRevenueHarvestVo">
        select `id`, `harvest_date`, `pond_id`, `species_id`, `customer`, `total_weight`, `total_price`, `labor_cost`, `transportation_cost` from afms_revenue_harvest
    </sql>

    <select id="selectAfmsRevenueHarvestList" parameterType="AfmsRevenueHarvest" resultMap="AfmsRevenueHarvestResult">
        <include refid="selectAfmsRevenueHarvestVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="params.beginHarvest_date != null and params.beginHarvest_date != '' and params.endHarvest_date != null and params.endHarvest_date != ''"> and harvest_date between #{params.beginHarvest_date} and #{params.endHarvest_date}</if>
            <if test="pond_id != null "> and pond_id = #{pond_id}</if>
            <if test="species_id != null "> and species_id = #{species_id}</if>
            <if test="customer != null  and customer != ''"> and customer like concat('%', #{customer}, '%')</if>
        </where>
    </select>
    
    <select id="selectAfmsRevenueHarvestById" parameterType="Integer" resultMap="AfmsRevenueHarvestResult">
        <include refid="selectAfmsRevenueHarvestVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsRevenueHarvest" parameterType="AfmsRevenueHarvest" useGeneratedKeys="true" keyProperty="id">
        insert into afms_revenue_harvest
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="harvest_date != null">harvest_date,</if>
            <if test="pond_id != null">pond_id,</if>
            <if test="species_id != null">species_id,</if>
            <if test="customer != null and customer != ''">customer,</if>
            <if test="total_weight != null">total_weight,</if>
            <if test="total_price != null">total_price,</if>
            <if test="labor_cost != null">labor_cost,</if>
            <if test="transportation_cost != null">transportation_cost,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="harvest_date != null">#{harvest_date},</if>
            <if test="pond_id != null">#{pond_id},</if>
            <if test="species_id != null">#{species_id},</if>
            <if test="customer != null and customer != ''">#{customer},</if>
            <if test="total_weight != null">#{total_weight},</if>
            <if test="total_price != null">#{total_price},</if>
            <if test="labor_cost != null">#{labor_cost},</if>
            <if test="transportation_cost != null">#{transportation_cost},</if>
         </trim>
    </insert>

    <update id="updateAfmsRevenueHarvest" parameterType="AfmsRevenueHarvest">
        update afms_revenue_harvest
        <trim prefix="SET" suffixOverrides=",">
            <if test="harvest_date != null">harvest_date = #{harvest_date},</if>
            <if test="pond_id != null">pond_id = #{pond_id},</if>
            <if test="species_id != null">species_id = #{species_id},</if>
            <if test="customer != null and customer != ''">customer = #{customer},</if>
            <if test="total_weight != null">total_weight = #{total_weight},</if>
            <if test="total_price != null">total_price = #{total_price},</if>
            <if test="labor_cost != null">labor_cost = #{labor_cost},</if>
            <if test="transportation_cost != null">transportation_cost = #{transportation_cost},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsRevenueHarvestById" parameterType="Integer">
        delete from afms_revenue_harvest where id = #{id}
    </delete>

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