AfmsBasicSpeciesMapper.xml 4.4 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.AfmsBasicSpeciesMapper">
    
    <resultMap type="AfmsBasicSpecies" id="AfmsBasicSpeciesResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="water_type"    column="water_type"    />
        <result property="weight_unit"    column="weight_unit"    />
        <result property="quantity_unit"    column="quantity_unit"    />
        <result property="specification_unit"    column="specification_unit"    />
        <result property="create_time"    column="create_time"    />
    </resultMap>

    <sql id="selectAfmsBasicSpeciesVo">
        select `id`, `name`, `water_type`, `weight_unit`, `quantity_unit`, `specification_unit`, `create_time` from afms_basic_species
    </sql>

    <select id="selectAfmsBasicSpeciesList" parameterType="AfmsBasicSpecies" resultMap="AfmsBasicSpeciesResult">
        <include refid="selectAfmsBasicSpeciesVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="water_type != null "> and water_type = #{water_type}</if>
            <if test="weight_unit != null "> and weight_unit = #{weight_unit}</if>
            <if test="quantity_unit != null "> and quantity_unit = #{quantity_unit}</if>
            <if test="specification_unit != null  and specification_unit != ''"> and specification_unit like concat('%', #{specification_unit}, '%')</if>
            <if test="params.beginCreate_time != null and params.beginCreate_time != '' and params.endCreate_time != null and params.endCreate_time != ''"> and create_time between #{params.beginCreate_time} and #{params.endCreate_time}</if>
        </where>
    </select>
    
    <select id="selectAfmsBasicSpeciesById" parameterType="Integer" resultMap="AfmsBasicSpeciesResult">
        <include refid="selectAfmsBasicSpeciesVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsBasicSpecies" parameterType="AfmsBasicSpecies" useGeneratedKeys="true" keyProperty="id">
        insert into afms_basic_species
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="water_type != null">water_type,</if>
            <if test="weight_unit != null">weight_unit,</if>
            <if test="quantity_unit != null">quantity_unit,</if>
            <if test="specification_unit != null and specification_unit != ''">specification_unit,</if>
            <if test="create_time != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="water_type != null">#{water_type},</if>
            <if test="weight_unit != null">#{weight_unit},</if>
            <if test="quantity_unit != null">#{quantity_unit},</if>
            <if test="specification_unit != null and specification_unit != ''">#{specification_unit},</if>
            <if test="create_time != null">#{create_time},</if>
         </trim>
    </insert>

    <update id="updateAfmsBasicSpecies" parameterType="AfmsBasicSpecies">
        update afms_basic_species
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="water_type != null">water_type = #{water_type},</if>
            <if test="weight_unit != null">weight_unit = #{weight_unit},</if>
            <if test="quantity_unit != null">quantity_unit = #{quantity_unit},</if>
            <if test="specification_unit != null and specification_unit != ''">specification_unit = #{specification_unit},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsBasicSpeciesById" parameterType="Integer">
        delete from afms_basic_species where id = #{id}
    </delete>

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