<?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.base.mapper.BasSheepTypeMapper">
    
    <resultMap type="BasSheepType" id="BasSheepTypeResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
    </resultMap>

    <sql id="selectBasSheepTypeVo">
        select id, name from bas_sheep_type
    </sql>

    <select id="selectBasSheepTypeList" parameterType="BasSheepType" resultMap="BasSheepTypeResult">
        <include refid="selectBasSheepTypeVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name = #{name}</if>
        </where>
    </select>
    
    <select id="selectBasSheepTypeById" parameterType="Integer" resultMap="BasSheepTypeResult">
        <include refid="selectBasSheepTypeVo"/>
        where id = #{id}
    </select>

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

    <update id="updateBasSheepType" parameterType="BasSheepType">
        update bas_sheep_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBasSheepTypeById" parameterType="Integer">
        delete from bas_sheep_type where id = #{id}
    </delete>

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