AfmsDataLossMapper.xml 5.0 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.AfmsDataLossMapper">
    
    <resultMap type="AfmsDataLoss" id="AfmsDataLossResult">
        <result property="id"    column="id"    />
        <result property="loss_record_time"    column="loss_record_time"    />
        <result property="pond_id"    column="pond_id"    />
        <result property="species"    column="species"    />
        <result property="loss_count"    column="loss_count"    />
        <result property="loss_weight"    column="loss_weight"    />
        <result property="loss_specification"    column="loss_specification"    />
        <result property="estimated_reason"    column="estimated_reason"    />
        <result property="image_path"    column="image_path"    />
    </resultMap>

    <sql id="selectAfmsDataLossVo">
        select `id`, `loss_record_time`, `pond_id`, `species`, `loss_count`, `loss_weight`, `loss_specification`, `estimated_reason`, `image_path` from afms_data_loss
    </sql>

    <select id="selectAfmsDataLossList" parameterType="AfmsDataLoss" resultMap="AfmsDataLossResult">
        <include refid="selectAfmsDataLossVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="params.beginLoss_record_time != null and params.beginLoss_record_time != '' and params.endLoss_record_time != null and params.endLoss_record_time != ''"> and loss_record_time between #{params.beginLoss_record_time} and #{params.endLoss_record_time}</if>
            <if test="pond_id != null "> and pond_id = #{pond_id}</if>
            <if test="species != null  and species != ''"> and species like concat('%', #{species}, '%')</if>
            <if test="loss_count != null "> and loss_count = #{loss_count}</if>
            <if test="estimated_reason != null  and estimated_reason != ''"> and estimated_reason like concat('%', #{estimated_reason}, '%')</if>
            <if test="image_path != null  and image_path != ''"> and image_path like concat('%', #{image_path}, '%')</if>
        </where>
    </select>
    
    <select id="selectAfmsDataLossById" parameterType="Integer" resultMap="AfmsDataLossResult">
        <include refid="selectAfmsDataLossVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsDataLoss" parameterType="AfmsDataLoss" useGeneratedKeys="true" keyProperty="id">
        insert into afms_data_loss
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="loss_record_time != null">loss_record_time,</if>
            <if test="pond_id != null">pond_id,</if>
            <if test="species != null and species != ''">species,</if>
            <if test="loss_count != null">loss_count,</if>
            <if test="loss_weight != null">loss_weight,</if>
            <if test="loss_specification != null">loss_specification,</if>
            <if test="estimated_reason != null and estimated_reason != ''">estimated_reason,</if>
            <if test="image_path != null">image_path,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="loss_record_time != null">#{loss_record_time},</if>
            <if test="pond_id != null">#{pond_id},</if>
            <if test="species != null and species != ''">#{species},</if>
            <if test="loss_count != null">#{loss_count},</if>
            <if test="loss_weight != null">#{loss_weight},</if>
            <if test="loss_specification != null">#{loss_specification},</if>
            <if test="estimated_reason != null and estimated_reason != ''">#{estimated_reason},</if>
            <if test="image_path != null">#{image_path},</if>
         </trim>
    </insert>

    <update id="updateAfmsDataLoss" parameterType="AfmsDataLoss">
        update afms_data_loss
        <trim prefix="SET" suffixOverrides=",">
            <if test="loss_record_time != null">loss_record_time = #{loss_record_time},</if>
            <if test="pond_id != null">pond_id = #{pond_id},</if>
            <if test="species != null and species != ''">species = #{species},</if>
            <if test="loss_count != null">loss_count = #{loss_count},</if>
            <if test="loss_weight != null">loss_weight = #{loss_weight},</if>
            <if test="loss_specification != null">loss_specification = #{loss_specification},</if>
            <if test="estimated_reason != null and estimated_reason != ''">estimated_reason = #{estimated_reason},</if>
            <if test="image_path != null">image_path = #{image_path},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsDataLossById" parameterType="Integer">
        delete from afms_data_loss where id = #{id}
    </delete>

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