<?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.zhyc.module.biosafety.mapper.SwUnitMapper">
    
    <resultMap type="SwUnit" id="SwUnitResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="unit"    column="unit"    />
    </resultMap>

    <sql id="selectSwUnitVo">
        select id, name,unit from sw_unit
    </sql>

    <select id="selectSwUnitList" parameterType="SwUnit" resultMap="SwUnitResult">
        <include refid="selectSwUnitVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectSwUnitById" parameterType="Long" resultMap="SwUnitResult">
        <include refid="selectSwUnitVo"/>
        where id = #{id}
    </select>

    <insert id="insertSwUnit" parameterType="SwUnit" useGeneratedKeys="true" keyProperty="id">
        insert into sw_unit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="unit != null">unit,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="unit != null">#{unit},</if>
         </trim>
    </insert>

    <update id="updateSwUnit" parameterType="SwUnit">
        update sw_unit
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="unit != null">unit = #{unit},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSwUnitById" parameterType="Long">
        delete from sw_unit where id = #{id}
    </delete>

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