<?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.SysAgriLimitMapper">
    
    <resultMap type="SysAgriLimit" id="SysAgriLimitResult">
        <result property="id"    column="id"    />
        <result property="agriId"    column="agri_id"    />
        <result property="agriName"    column="agri_name"    />
        <result property="imei"    column="imei"    />
        <result property="jbkLimit"    column="jbk_limit"    />
        <result property="jbgLimit"    column="jbg_limit"    />
        <result property="jlkLimit"    column="jlk_limit"    />
        <result property="jlgLimit"    column="jlg_limit"    />
        <result property="jm1kLimit"    column="jm1k_limit"    />
        <result property="jm1gLimit"    column="jm1g_limit"    />
        <result property="jm2kLimit"    column="jm2k_limit"    />
        <result property="jm2gLimit"    column="jm2g_limit"    />
        <result property="jm3kLimit"    column="jm3k_limit"    />
        <result property="jm3gLimit"    column="jm3g_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"    />
        <result property="deleted"    column="deleted"    />
        <result property="deleteTime"    column="delete_time"    />
    </resultMap>

    <sql id="selectSysAgriLimitVo">
        select id, agri_id, agri_name, imei, jbk_limit, jbg_limit, jlk_limit, jlg_limit, jm1k_limit, jm1g_limit, jm2k_limit, jm2g_limit, jm3k_limit, jm3g_limit, remark, version, create_by, create_time, update_by, update_time, deleted, delete_time from sys_agri_limit
    </sql>

    <select id="selectSysAgriLimitList" parameterType="SysAgriLimit" resultMap="SysAgriLimitResult">
        <include refid="selectSysAgriLimitVo"/>
        <where>  
            <if test="agriId != null "> and agri_id = #{agriId}</if>
            <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="jbkLimit != null  and jbkLimit != ''"> and jbk_limit = #{jbkLimit}</if>
            <if test="jbgLimit != null  and jbgLimit != ''"> and jbg_limit = #{jbgLimit}</if>
            <if test="jlkLimit != null  and jlkLimit != ''"> and jlk_limit = #{jlkLimit}</if>
            <if test="jlgLimit != null  and jlgLimit != ''"> and jlg_limit = #{jlgLimit}</if>
            <if test="jm1kLimit != null  and jm1kLimit != ''"> and jm1k_limit = #{jm1kLimit}</if>
            <if test="jm1gLimit != null  and jm1gLimit != ''"> and jm1g_limit = #{jm1gLimit}</if>
            <if test="jm2kLimit != null  and jm2kLimit != ''"> and jm2k_limit = #{jm2kLimit}</if>
            <if test="jm2gLimit != null  and jm2gLimit != ''"> and jm2g_limit = #{jm2gLimit}</if>
            <if test="jm3kLimit != null  and jm3kLimit != ''"> and jm3k_limit = #{jm3kLimit}</if>
            <if test="jm3gLimit != null  and jm3gLimit != ''"> and jm3g_limit = #{jm3gLimit}</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="deleted != null  and deleted != ''"> and deleted = #{deleted}</if>
            <if test="deleteTime != null "> and delete_time = #{deleteTime}</if>
        </where>
    </select>
    
    <select id="selectSysAgriLimitById" parameterType="String" resultMap="SysAgriLimitResult">
        <include refid="selectSysAgriLimitVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysAgriLimit" parameterType="SysAgriLimit" useGeneratedKeys="true" keyProperty="id">
        insert into sys_agri_limit
        <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="jbkLimit != null">jbk_limit,</if>
            <if test="jbgLimit != null">jbg_limit,</if>
            <if test="jlkLimit != null">jlk_limit,</if>
            <if test="jlgLimit != null">jlg_limit,</if>
            <if test="jm1kLimit != null">jm1k_limit,</if>
            <if test="jm1gLimit != null">jm1g_limit,</if>
            <if test="jm2kLimit != null">jm2k_limit,</if>
            <if test="jm2gLimit != null">jm2g_limit,</if>
            <if test="jm3kLimit != null">jm3k_limit,</if>
            <if test="jm3gLimit != null">jm3g_limit,</if>
            <if test="remark != null">remark,</if>
            <if test="version != null">version,</if>
            create_by,
            create_time,
            update_by,
            update_time,
            <if test="deleted != null">deleted,</if>
            <if test="deleteTime != null">delete_time,</if>
        </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="jbkLimit != null">#{jbkLimit},</if>
            <if test="jbgLimit != null">#{jbgLimit},</if>
            <if test="jlkLimit != null">#{jlkLimit},</if>
            <if test="jlgLimit != null">#{jlgLimit},</if>
            <if test="jm1kLimit != null">#{jm1kLimit},</if>
            <if test="jm1gLimit != null">#{jm1gLimit},</if>
            <if test="jm2kLimit != null">#{jm2kLimit},</if>
            <if test="jm2gLimit != null">#{jm2gLimit},</if>
            <if test="jm3kLimit != null">#{jm3kLimit},</if>
            <if test="jm3gLimit != null">#{jm3gLimit},</if>
            <if test="remark != null">#{remark},</if>
            <if test="version != null">#{version},</if>
            #{createBy},
            #{createTime},
            #{updateBy},
            #{updateTime},
            <if test="deleted != null">#{deleted},</if>
            <if test="deleteTime != null">#{deleteTime},</if>
         </trim>
    </insert>

    <update id="updateSysAgriLimit" parameterType="SysAgriLimit">
        update sys_agri_limit
        <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="jbkLimit != null">jbk_limit = #{jbkLimit},</if>
            <if test="jbgLimit != null">jbg_limit = #{jbgLimit},</if>
            <if test="jlkLimit != null">jlk_limit = #{jlkLimit},</if>
            <if test="jlgLimit != null">jlg_limit = #{jlgLimit},</if>
            <if test="jm1kLimit != null">jm1k_limit = #{jm1kLimit},</if>
            <if test="jm1gLimit != null">jm1g_limit = #{jm1gLimit},</if>
            <if test="jm2kLimit != null">jm2k_limit = #{jm2kLimit},</if>
            <if test="jm2gLimit != null">jm2g_limit = #{jm2gLimit},</if>
            <if test="jm3kLimit != null">jm3k_limit = #{jm3kLimit},</if>
            <if test="jm3gLimit != null">jm3g_limit = #{jm3gLimit},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="version != null">version = #{version},</if>
            <if test="createBy != null and createBy != ''">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>
            <if test="deleted != null">deleted = #{deleted},</if>
            <if test="deleteTime != null">delete_time = #{deleteTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysAgriLimitById" parameterType="String">
        delete from sys_agri_limit where id = #{id}
    </delete>

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


</mapper>