<?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.agri.system.mapper.SysAgriLimitBakMapper">
    
    <resultMap type="SysAgriLimitBak" id="SysAgriLimitBakResult">
        <result property="id"    column="id"    />
        <result property="agriId"    column="agri_id"    />
        <result property="agriName"    column="agri_name"    />
        <result property="imei"    column="imei"    />
        <result property="roller"    column="roller"    />
        <result property="funcLimit"    column="func_limit"    />
        <result property="remark"    column="remark"    />
        <result property="version"    column="version"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
   </resultMap>

    <sql id="selectSysAgriLimitBakVo">
        select id, agri_id, agri_name, imei, roller, func_limit, remark, version, create_by, create_time, update_by, update_time from sys_agri_limit_bak
    </sql>

    <select id="selectSysAgriLimitBakList" parameterType="SysAgriLimitBak" resultMap="SysAgriLimitBakResult">
        <include refid="selectSysAgriLimitBakVo"/>
        <where>  
            <if test="agriName != null  and agriName != ''"> and agri_name like concat('%', #{agriName}, '%')</if>
            <if test="imei != null  and imei != ''"> and imei = #{imei}</if>
            <if test="roller != null  and roller != ''"> and roller = #{roller}</if>
        </where>
    </select>
    
    <select id="selectSysAgriLimitBakById" parameterType="String" resultMap="SysAgriLimitBakResult">
        <include refid="selectSysAgriLimitBakVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysAgriLimitBak" parameterType="SysAgriLimitBak" useGeneratedKeys="true" keyProperty="id">
        insert into sys_agri_limit_bak
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="agriId != null">agri_id,</if>
            <if test="agriName != null">agri_name,</if>
            <if test="imei != null and imei != ''">imei,</if>
            <if test="roller != null and roller != ''">roller,</if>
            <if test="funcLimit != null and funcLimit != ''">func_limit,</if>
            <if test="remark != null">remark,</if>
            <if test="version != null">version,</if>
    create_by,
    create_time,
    update_by,
    update_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="agriId != null">#{agriId},</if>
            <if test="agriName != null">#{agriName},</if>
            <if test="imei != null and imei != ''">#{imei},</if>
            <if test="roller != null and roller != ''">#{roller},</if>
            <if test="funcLimit != null and funcLimit != ''">#{funcLimit},</if>
            <if test="remark != null">#{remark},</if>
            <if test="version != null">#{version},</if>
        #{createBy},
        #{createTime},
        #{updateBy},
        #{updateTime}
         </trim>
    </insert>

    <update id="updateSysAgriLimitBak" parameterType="SysAgriLimitBak">
        update sys_agri_limit_bak
        <trim prefix="SET" suffixOverrides=",">
            <if test="agriId != null">agri_id = #{agriId},</if>
            <if test="agriName != null">agri_name = #{agriName},</if>
            <if test="imei != null and imei != ''">imei = #{imei},</if>
            <if test="roller != null and roller != ''">roller = #{roller},</if>
            <if test="funcLimit != null and funcLimit != ''">func_limit = #{funcLimit},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="version != null">version = #{version},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysAgriLimitBakById" parameterType="String">
        delete from sys_agri_limit_bak where id = #{id}
    </delete>

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