AfmsDataSamplingMapper.xml 5.2 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.AfmsDataSamplingMapper">
    
    <resultMap type="AfmsDataSampling" id="AfmsDataSamplingResult">
        <result property="id"    column="id"    />
        <result property="sampling_time"    column="sampling_time"    />
        <result property="pond_id"    column="pond_id"    />
        <result property="species"    column="species"    />
        <result property="sample_count"    column="sample_count"    />
        <result property="sample_weight"    column="sample_weight"    />
        <result property="average_length"    column="average_length"    />
        <result property="average_specification"    column="average_specification"    />
        <result property="estimated_pond_weight"    column="estimated_pond_weight"    />
        <result property="image_path"    column="image_path"    />
    </resultMap>

    <sql id="selectAfmsDataSamplingVo">
        select `id`, `sampling_time`, `pond_id`, `species`, `sample_count`, `sample_weight`, `average_length`, `average_specification`, `estimated_pond_weight`, `image_path` from afms_data_sampling
    </sql>

    <select id="selectAfmsDataSamplingList" parameterType="AfmsDataSampling" resultMap="AfmsDataSamplingResult">
        <include refid="selectAfmsDataSamplingVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="params.beginSampling_time != null and params.beginSampling_time != '' and params.endSampling_time != null and params.endSampling_time != ''"> and sampling_time between #{params.beginSampling_time} and #{params.endSampling_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="sample_count != null "> and sample_count = #{sample_count}</if>
            <if test="image_path != null  and image_path != ''"> and image_path like concat('%', #{image_path}, '%')</if>
        </where>
    </select>
    
    <select id="selectAfmsDataSamplingById" parameterType="Integer" resultMap="AfmsDataSamplingResult">
        <include refid="selectAfmsDataSamplingVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsDataSampling" parameterType="AfmsDataSampling" useGeneratedKeys="true" keyProperty="id">
        insert into afms_data_sampling
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sampling_time != null">sampling_time,</if>
            <if test="pond_id != null">pond_id,</if>
            <if test="species != null and species != ''">species,</if>
            <if test="sample_count != null">sample_count,</if>
            <if test="sample_weight != null">sample_weight,</if>
            <if test="average_length != null">average_length,</if>
            <if test="average_specification != null">average_specification,</if>
            <if test="estimated_pond_weight != null">estimated_pond_weight,</if>
            <if test="image_path != null">image_path,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sampling_time != null">#{sampling_time},</if>
            <if test="pond_id != null">#{pond_id},</if>
            <if test="species != null and species != ''">#{species},</if>
            <if test="sample_count != null">#{sample_count},</if>
            <if test="sample_weight != null">#{sample_weight},</if>
            <if test="average_length != null">#{average_length},</if>
            <if test="average_specification != null">#{average_specification},</if>
            <if test="estimated_pond_weight != null">#{estimated_pond_weight},</if>
            <if test="image_path != null">#{image_path},</if>
         </trim>
    </insert>

    <update id="updateAfmsDataSampling" parameterType="AfmsDataSampling">
        update afms_data_sampling
        <trim prefix="SET" suffixOverrides=",">
            <if test="sampling_time != null">sampling_time = #{sampling_time},</if>
            <if test="pond_id != null">pond_id = #{pond_id},</if>
            <if test="species != null and species != ''">species = #{species},</if>
            <if test="sample_count != null">sample_count = #{sample_count},</if>
            <if test="sample_weight != null">sample_weight = #{sample_weight},</if>
            <if test="average_length != null">average_length = #{average_length},</if>
            <if test="average_specification != null">average_specification = #{average_specification},</if>
            <if test="estimated_pond_weight != null">estimated_pond_weight = #{estimated_pond_weight},</if>
            <if test="image_path != null">image_path = #{image_path},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsDataSamplingById" parameterType="Integer">
        delete from afms_data_sampling where id = #{id}
    </delete>

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