<?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.DaRanchMapper">

    <resultMap type="DaRanch" id="DaRanchResult">
        <result property="id" column="id"/>
        <result property="ranch" column="ranch"/>
    </resultMap>

    <sql id="selectDaRanchVo">
        select id, ranch
        from da_ranch
    </sql>

    <select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult">
        <include refid="selectDaRanchVo"/>
        <where>
            <if test="ranch != null  and ranch != ''">and ranch = #{ranch}</if>
        </where>
    </select>

    <select id="selectDaRanchById" parameterType="Long" resultMap="DaRanchResult">
        <include refid="selectDaRanchVo"/>
        where id = #{id}
    </select>

    <insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id">
        insert into da_ranch
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ranch != null">ranch,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ranch != null">#{ranch},</if>
        </trim>
    </insert>

    <update id="updateDaRanch" parameterType="DaRanch">
        update da_ranch
        <trim prefix="SET" suffixOverrides=",">
            <if test="ranch != null">ranch = #{ranch},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDaRanchById" parameterType="Long">
        delete
        from da_ranch
        where id = #{id}
    </delete>

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