<?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.SysRollerAirMapper">
    
    <resultMap type="SysRollerAir" id="SysRollerAirResult">
        <result property="id"    column="id"    />
        <result property="imei"    column="imei"    />
        <result property="roller"    column="roller"    />
        <result property="opType"    column="op_type"    />
        <result property="payload"    column="payload"    />
        <result property="clientid"    column="clientid"    />
        <result property="opTime"    column="op_time"    />
        <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="selectSysRollerAirVo">
        select id, imei, roller, op_type, payload, clientid, op_time, create_by, create_time, update_by, update_time from sys_roller_air
    </sql>

    <select id="selectSysRollerAirList" parameterType="SysRollerAir" resultMap="SysRollerAirResult">
        <include refid="selectSysRollerAirVo"/>
        <where>  
            <if test="imei != null  and imei != ''"> and imei = #{imei}</if>
            <if test="roller != null  and roller != ''"> and roller = #{roller}</if>
            <if test="opType != null "> and op_type = #{opType}</if>
            <if test="payload != null  and payload != ''"> and payload = #{payload}</if>
            <if test="clientid != null  and clientid != ''"> and clientid = #{clientid}</if>
            <if test="opTime != null "> and op_time = #{opTime}</if>
        </where>
    </select>
    
    <select id="selectSysRollerAirById" parameterType="Long" resultMap="SysRollerAirResult">
        <include refid="selectSysRollerAirVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysRollerAir" parameterType="SysRollerAir" useGeneratedKeys="true" keyProperty="id">
        insert into sys_roller_air
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="imei != null and imei != ''">imei,</if>
            <if test="roller != null and roller != ''">roller,</if>
            <if test="opType != null">op_type,</if>
            <if test="payload != null">payload,</if>
            <if test="clientid != null">clientid,</if>
            <if test="opTime != null">op_time,</if>
    create_by,
    create_time,
    update_by,
    update_time,
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="imei != null and imei != ''">#{imei},</if>
            <if test="roller != null and roller != ''">#{roller},</if>
            <if test="opType != null">#{opType},</if>
            <if test="payload != null">#{payload},</if>
            <if test="clientid != null">#{clientid},</if>
            <if test="opTime != null">#{opTime},</if>
        #{createBy},
        #{createTime},
        #{updateBy},
        #{updateTime},
         </trim>
    </insert>

    <update id="updateSysRollerAir" parameterType="SysRollerAir">
        update sys_roller_air
        <trim prefix="SET" suffixOverrides=",">
            <if test="imei != null and imei != ''">imei = #{imei},</if>
            <if test="roller != null and roller != ''">roller = #{roller},</if>
            <if test="opType != null">op_type = #{opType},</if>
            <if test="payload != null">payload = #{payload},</if>
            <if test="clientid != null">clientid = #{clientid},</if>
            <if test="opTime != null">op_time = #{opTime},</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="deleteSysRollerAirById" parameterType="Long">
        delete from sys_roller_air where id = #{id}
    </delete>

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