<?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.bonus.canteen.device.mapper.DeviceInfoMapper">
    <resultMap type="com.bonus.canteen.device.domain.DeviceInfo" id="DeviceInfoResult">
        <result property="deviceId"    column="device_id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="effId"    column="eff_id"    />
        <result property="onlineState"    column="online_state"    />
        <result property="versionCode"    column="version_code"    />
        <result property="versionName"    column="version_name"    />
        <result property="consumMode"    column="consum_mode"    />
        <result property="commMode"    column="comm_mode"    />
        <result property="deviceIp"    column="device_ip"    />
        <result property="deviceMask"    column="device_mask"    />
        <result property="deviceMac"    column="device_mac"    />
        <result property="deviceGateway"    column="device_gateway"    />
        <result property="firstDns"    column="first_dns"    />
        <result property="nextDns"    column="next_dns"    />
        <result property="deviceSn"    column="device_sn"    />
        <result property="deviceName"    column="device_name"    />
        <result property="deviceNum"    column="device_num"    />
        <result property="deviceModel"    column="device_model"    />
        <result property="deviceType"    column="device_type"    />
        <result property="devicePwd"    column="device_pwd"    />
        <result property="deviceAddr"    column="device_addr"    />
        <result property="deviceKey"    column="device_key"    />
        <result property="deviceParentId"    column="device_parent_id"    />
        <result property="deviceParentType"    column="device_parent_type"    />
        <result property="deviceServiceIp"    column="device_service_ip"    />
        <result property="deviceServicePort"    column="device_service_port"    />
        <result property="ifQuotaLimit"    column="if_quota_limit"    />
        <result property="ifDiscount"    column="if_discount"    />
        <result property="ifTimeLimit"    column="if_time_limit"    />
        <result property="ifUseCallNum"    column="if_use_call_num"    />
        <result property="ifEnable"    column="if_enable"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="amountNotify"    column="amount_notify"    />
        <result property="bindingValidTime"    column="binding_valid_time"    />
        <result property="ordAutomaticPay"    column="ord_automatic_pay"    />
        <result property="ifOffLinePay"    column="if_off_line_pay"    />
        <result property="alarmTime"    column="alarm_time"    />
        <result property="spoonWeight"    column="spoon_weight"    />
        <result property="weightRemAlarm"    column="weight_rem_alarm"    />
        <result property="heartBeatTime"    column="heart_beat_time"    />
        <result property="carouselTime"    column="carousel_time"    />
        <result property="titleSlogan"    column="title_slogan"    />
        <result property="fontSize"    column="font_size"    />
        <result property="imageMap"    column="image_map"    />
        <result property="guiStyle"    column="gui_style"    />
        <result property="fontColor"    column="font_color"    />
        <result property="lineNum"    column="line_num"    />
        <result property="oncePayAmount"    column="once_pay_amount"    />
        <result property="dataStatus"    column="data_status"    />
        <result property="ordOpenLimit"    column="ord_open_limit"    />
        <result property="detailNumLimit"    column="detail_num_limit"    />
        <result property="terminalSn"    column="terminal_sn"    />
        <result property="terminalKey"    column="terminal_key"    />
        <result property="priStatus"    column="pri_status"    />
        <result property="priKey"    column="pri_key"    />
        <result property="gateDefaultAmount"    column="gate_default_amount"    />
        <result property="deviceState"    column="device_state"    />
        <result property="deviceAgreement"    column="device_agreement"    />
        <result property="revision"    column="revision"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectDeviceInfoVo">
        select device_id, tenant_id, eff_id, online_state, version_code, version_name, consum_mode, comm_mode, device_ip, device_mask, device_mac, device_gateway, first_dns, next_dns, device_sn, device_name, device_num, device_model, device_type, device_pwd, device_addr, device_key, device_parent_id, device_parent_type, device_service_ip, device_service_port, if_quota_limit, if_discount, if_time_limit, if_use_call_num, if_enable, img_url, amount_notify, binding_valid_time, ord_automatic_pay, if_off_line_pay, alarm_time, spoon_weight, weight_rem_alarm, heart_beat_time, carousel_time, title_slogan, font_size, image_map, gui_style, font_color, line_num, once_pay_amount, data_status, ord_open_limit, detail_num_limit, terminal_sn, terminal_key, pri_status, pri_key, gate_default_amount, device_state, device_agreement, revision, create_by, create_time, update_by, update_time, remark from device_info
    </sql>

    <select id="selectDeviceInfoList" parameterType="com.bonus.canteen.device.domain.DeviceInfo" resultMap="DeviceInfoResult">
        <include refid="selectDeviceInfoVo"/>
        <where>  
            <if test="effId != null "> and eff_id = #{effId}</if>
            <if test="onlineState != null "> and online_state = #{onlineState}</if>
            <if test="versionCode != null "> and version_code = #{versionCode}</if>
            <if test="versionName != null  and versionName != ''"> and version_name like concat('%', #{versionName}, '%')</if>
            <if test="consumMode != null "> and consum_mode = #{consumMode}</if>
            <if test="commMode != null "> and comm_mode = #{commMode}</if>
            <if test="deviceIp != null  and deviceIp != ''"> and device_ip = #{deviceIp}</if>
            <if test="deviceMask != null  and deviceMask != ''"> and device_mask = #{deviceMask}</if>
            <if test="deviceMac != null  and deviceMac != ''"> and device_mac = #{deviceMac}</if>
            <if test="deviceGateway != null  and deviceGateway != ''"> and device_gateway = #{deviceGateway}</if>
            <if test="firstDns != null  and firstDns != ''"> and first_dns = #{firstDns}</if>
            <if test="nextDns != null  and nextDns != ''"> and next_dns = #{nextDns}</if>
            <if test="deviceSn != null  and deviceSn != ''"> and device_sn = #{deviceSn}</if>
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
            <if test="deviceNum != null  and deviceNum != ''"> and device_num = #{deviceNum}</if>
            <if test="deviceModel != null  and deviceModel != ''"> and device_model = #{deviceModel}</if>
            <if test="deviceType != null "> and device_type = #{deviceType}</if>
            <if test="devicePwd != null  and devicePwd != ''"> and device_pwd = #{devicePwd}</if>
            <if test="deviceAddr != null  and deviceAddr != ''"> and device_addr = #{deviceAddr}</if>
            <if test="deviceKey != null  and deviceKey != ''"> and device_key = #{deviceKey}</if>
            <if test="deviceParentId != null "> and device_parent_id = #{deviceParentId}</if>
            <if test="deviceParentType != null  and deviceParentType != ''"> and device_parent_type = #{deviceParentType}</if>
            <if test="deviceServiceIp != null  and deviceServiceIp != ''"> and device_service_ip = #{deviceServiceIp}</if>
            <if test="deviceServicePort != null  and deviceServicePort != ''"> and device_service_port = #{deviceServicePort}</if>
            <if test="ifQuotaLimit != null "> and if_quota_limit = #{ifQuotaLimit}</if>
            <if test="ifDiscount != null "> and if_discount = #{ifDiscount}</if>
            <if test="ifTimeLimit != null "> and if_time_limit = #{ifTimeLimit}</if>
            <if test="ifUseCallNum != null "> and if_use_call_num = #{ifUseCallNum}</if>
            <if test="ifEnable != null "> and if_enable = #{ifEnable}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="amountNotify != null "> and amount_notify = #{amountNotify}</if>
            <if test="bindingValidTime != null "> and binding_valid_time = #{bindingValidTime}</if>
            <if test="ordAutomaticPay != null "> and ord_automatic_pay = #{ordAutomaticPay}</if>
            <if test="ifOffLinePay != null "> and if_off_line_pay = #{ifOffLinePay}</if>
            <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
            <if test="spoonWeight != null "> and spoon_weight = #{spoonWeight}</if>
            <if test="weightRemAlarm != null "> and weight_rem_alarm = #{weightRemAlarm}</if>
            <if test="heartBeatTime != null "> and heart_beat_time = #{heartBeatTime}</if>
            <if test="carouselTime != null "> and carousel_time = #{carouselTime}</if>
            <if test="titleSlogan != null  and titleSlogan != ''"> and title_slogan = #{titleSlogan}</if>
            <if test="fontSize != null "> and font_size = #{fontSize}</if>
            <if test="imageMap != null  and imageMap != ''"> and image_map = #{imageMap}</if>
            <if test="guiStyle != null "> and gui_style = #{guiStyle}</if>
            <if test="fontColor != null  and fontColor != ''"> and font_color = #{fontColor}</if>
            <if test="lineNum != null "> and line_num = #{lineNum}</if>
            <if test="oncePayAmount != null "> and once_pay_amount = #{oncePayAmount}</if>
            <if test="dataStatus != null "> and data_status = #{dataStatus}</if>
            <if test="ordOpenLimit != null "> and ord_open_limit = #{ordOpenLimit}</if>
            <if test="detailNumLimit != null "> and detail_num_limit = #{detailNumLimit}</if>
            <if test="terminalSn != null  and terminalSn != ''"> and terminal_sn = #{terminalSn}</if>
            <if test="terminalKey != null  and terminalKey != ''"> and terminal_key = #{terminalKey}</if>
            <if test="priStatus != null "> and pri_status = #{priStatus}</if>
            <if test="priKey != null  and priKey != ''"> and pri_key = #{priKey}</if>
            <if test="gateDefaultAmount != null "> and gate_default_amount = #{gateDefaultAmount}</if>
            <if test="deviceState != null "> and device_state = #{deviceState}</if>
            <if test="deviceAgreement != null "> and device_agreement = #{deviceAgreement}</if>
            <if test="revision != null "> and revision = #{revision}</if>
        </where>
    </select>
    
    <select id="selectDeviceInfoByDeviceId" parameterType="Long" resultMap="DeviceInfoResult">
        <include refid="selectDeviceInfoVo"/>
        where device_id = #{deviceId}
    </select>
        
    <insert id="insertDeviceInfo" parameterType="com.bonus.canteen.device.domain.DeviceInfo">
        insert into device_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceId != null">device_id,</if>
            <if test="tenantId != null">tenant_id,</if>
            <if test="effId != null">eff_id,</if>
            <if test="onlineState != null">online_state,</if>
            <if test="versionCode != null">version_code,</if>
            <if test="versionName != null">version_name,</if>
            <if test="consumMode != null">consum_mode,</if>
            <if test="commMode != null">comm_mode,</if>
            <if test="deviceIp != null and deviceIp != ''">device_ip,</if>
            <if test="deviceMask != null and deviceMask != ''">device_mask,</if>
            <if test="deviceMac != null and deviceMac != ''">device_mac,</if>
            <if test="deviceGateway != null and deviceGateway != ''">device_gateway,</if>
            <if test="firstDns != null and firstDns != ''">first_dns,</if>
            <if test="nextDns != null and nextDns != ''">next_dns,</if>
            <if test="deviceSn != null">device_sn,</if>
            <if test="deviceName != null and deviceName != ''">device_name,</if>
            <if test="deviceNum != null and deviceNum != ''">device_num,</if>
            <if test="deviceModel != null and deviceModel != ''">device_model,</if>
            <if test="deviceType != null">device_type,</if>
            <if test="devicePwd != null">device_pwd,</if>
            <if test="deviceAddr != null">device_addr,</if>
            <if test="deviceKey != null">device_key,</if>
            <if test="deviceParentId != null">device_parent_id,</if>
            <if test="deviceParentType != null">device_parent_type,</if>
            <if test="deviceServiceIp != null">device_service_ip,</if>
            <if test="deviceServicePort != null">device_service_port,</if>
            <if test="ifQuotaLimit != null">if_quota_limit,</if>
            <if test="ifDiscount != null">if_discount,</if>
            <if test="ifTimeLimit != null">if_time_limit,</if>
            <if test="ifUseCallNum != null">if_use_call_num,</if>
            <if test="ifEnable != null">if_enable,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="amountNotify != null">amount_notify,</if>
            <if test="bindingValidTime != null">binding_valid_time,</if>
            <if test="ordAutomaticPay != null">ord_automatic_pay,</if>
            <if test="ifOffLinePay != null">if_off_line_pay,</if>
            <if test="alarmTime != null">alarm_time,</if>
            <if test="spoonWeight != null">spoon_weight,</if>
            <if test="weightRemAlarm != null">weight_rem_alarm,</if>
            <if test="heartBeatTime != null">heart_beat_time,</if>
            <if test="carouselTime != null">carousel_time,</if>
            <if test="titleSlogan != null">title_slogan,</if>
            <if test="fontSize != null">font_size,</if>
            <if test="imageMap != null">image_map,</if>
            <if test="guiStyle != null">gui_style,</if>
            <if test="fontColor != null">font_color,</if>
            <if test="lineNum != null">line_num,</if>
            <if test="oncePayAmount != null">once_pay_amount,</if>
            <if test="dataStatus != null">data_status,</if>
            <if test="ordOpenLimit != null">ord_open_limit,</if>
            <if test="detailNumLimit != null">detail_num_limit,</if>
            <if test="terminalSn != null">terminal_sn,</if>
            <if test="terminalKey != null">terminal_key,</if>
            <if test="priStatus != null">pri_status,</if>
            <if test="priKey != null">pri_key,</if>
            <if test="gateDefaultAmount != null">gate_default_amount,</if>
            <if test="deviceState != null">device_state,</if>
            <if test="deviceAgreement != null">device_agreement,</if>
            <if test="revision != null">revision,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceId != null">#{deviceId},</if>
            <if test="tenantId != null">#{tenantId},</if>
            <if test="effId != null">#{effId},</if>
            <if test="onlineState != null">#{onlineState},</if>
            <if test="versionCode != null">#{versionCode},</if>
            <if test="versionName != null">#{versionName},</if>
            <if test="consumMode != null">#{consumMode},</if>
            <if test="commMode != null">#{commMode},</if>
            <if test="deviceIp != null and deviceIp != ''">#{deviceIp},</if>
            <if test="deviceMask != null and deviceMask != ''">#{deviceMask},</if>
            <if test="deviceMac != null and deviceMac != ''">#{deviceMac},</if>
            <if test="deviceGateway != null and deviceGateway != ''">#{deviceGateway},</if>
            <if test="firstDns != null and firstDns != ''">#{firstDns},</if>
            <if test="nextDns != null and nextDns != ''">#{nextDns},</if>
            <if test="deviceSn != null">#{deviceSn},</if>
            <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
            <if test="deviceNum != null and deviceNum != ''">#{deviceNum},</if>
            <if test="deviceModel != null and deviceModel != ''">#{deviceModel},</if>
            <if test="deviceType != null">#{deviceType},</if>
            <if test="devicePwd != null">#{devicePwd},</if>
            <if test="deviceAddr != null">#{deviceAddr},</if>
            <if test="deviceKey != null">#{deviceKey},</if>
            <if test="deviceParentId != null">#{deviceParentId},</if>
            <if test="deviceParentType != null">#{deviceParentType},</if>
            <if test="deviceServiceIp != null">#{deviceServiceIp},</if>
            <if test="deviceServicePort != null">#{deviceServicePort},</if>
            <if test="ifQuotaLimit != null">#{ifQuotaLimit},</if>
            <if test="ifDiscount != null">#{ifDiscount},</if>
            <if test="ifTimeLimit != null">#{ifTimeLimit},</if>
            <if test="ifUseCallNum != null">#{ifUseCallNum},</if>
            <if test="ifEnable != null">#{ifEnable},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="amountNotify != null">#{amountNotify},</if>
            <if test="bindingValidTime != null">#{bindingValidTime},</if>
            <if test="ordAutomaticPay != null">#{ordAutomaticPay},</if>
            <if test="ifOffLinePay != null">#{ifOffLinePay},</if>
            <if test="alarmTime != null">#{alarmTime},</if>
            <if test="spoonWeight != null">#{spoonWeight},</if>
            <if test="weightRemAlarm != null">#{weightRemAlarm},</if>
            <if test="heartBeatTime != null">#{heartBeatTime},</if>
            <if test="carouselTime != null">#{carouselTime},</if>
            <if test="titleSlogan != null">#{titleSlogan},</if>
            <if test="fontSize != null">#{fontSize},</if>
            <if test="imageMap != null">#{imageMap},</if>
            <if test="guiStyle != null">#{guiStyle},</if>
            <if test="fontColor != null">#{fontColor},</if>
            <if test="lineNum != null">#{lineNum},</if>
            <if test="oncePayAmount != null">#{oncePayAmount},</if>
            <if test="dataStatus != null">#{dataStatus},</if>
            <if test="ordOpenLimit != null">#{ordOpenLimit},</if>
            <if test="detailNumLimit != null">#{detailNumLimit},</if>
            <if test="terminalSn != null">#{terminalSn},</if>
            <if test="terminalKey != null">#{terminalKey},</if>
            <if test="priStatus != null">#{priStatus},</if>
            <if test="priKey != null">#{priKey},</if>
            <if test="gateDefaultAmount != null">#{gateDefaultAmount},</if>
            <if test="deviceState != null">#{deviceState},</if>
            <if test="deviceAgreement != null">#{deviceAgreement},</if>
            <if test="revision != null">#{revision},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateDeviceInfo" parameterType="com.bonus.canteen.device.domain.DeviceInfo">
        update device_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="effId != null">eff_id = #{effId},</if>
            <if test="onlineState != null">online_state = #{onlineState},</if>
            <if test="versionCode != null">version_code = #{versionCode},</if>
            <if test="versionName != null">version_name = #{versionName},</if>
            <if test="consumMode != null">consum_mode = #{consumMode},</if>
            <if test="commMode != null">comm_mode = #{commMode},</if>
            <if test="deviceIp != null and deviceIp != ''">device_ip = #{deviceIp},</if>
            <if test="deviceMask != null and deviceMask != ''">device_mask = #{deviceMask},</if>
            <if test="deviceMac != null and deviceMac != ''">device_mac = #{deviceMac},</if>
            <if test="deviceGateway != null and deviceGateway != ''">device_gateway = #{deviceGateway},</if>
            <if test="firstDns != null and firstDns != ''">first_dns = #{firstDns},</if>
            <if test="nextDns != null and nextDns != ''">next_dns = #{nextDns},</if>
            <if test="deviceSn != null">device_sn = #{deviceSn},</if>
            <if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
            <if test="deviceNum != null and deviceNum != ''">device_num = #{deviceNum},</if>
            <if test="deviceModel != null and deviceModel != ''">device_model = #{deviceModel},</if>
            <if test="deviceType != null">device_type = #{deviceType},</if>
            <if test="devicePwd != null">device_pwd = #{devicePwd},</if>
            <if test="deviceAddr != null">device_addr = #{deviceAddr},</if>
            <if test="deviceKey != null">device_key = #{deviceKey},</if>
            <if test="deviceParentId != null">device_parent_id = #{deviceParentId},</if>
            <if test="deviceParentType != null">device_parent_type = #{deviceParentType},</if>
            <if test="deviceServiceIp != null">device_service_ip = #{deviceServiceIp},</if>
            <if test="deviceServicePort != null">device_service_port = #{deviceServicePort},</if>
            <if test="ifQuotaLimit != null">if_quota_limit = #{ifQuotaLimit},</if>
            <if test="ifDiscount != null">if_discount = #{ifDiscount},</if>
            <if test="ifTimeLimit != null">if_time_limit = #{ifTimeLimit},</if>
            <if test="ifUseCallNum != null">if_use_call_num = #{ifUseCallNum},</if>
            <if test="ifEnable != null">if_enable = #{ifEnable},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="amountNotify != null">amount_notify = #{amountNotify},</if>
            <if test="bindingValidTime != null">binding_valid_time = #{bindingValidTime},</if>
            <if test="ordAutomaticPay != null">ord_automatic_pay = #{ordAutomaticPay},</if>
            <if test="ifOffLinePay != null">if_off_line_pay = #{ifOffLinePay},</if>
            <if test="alarmTime != null">alarm_time = #{alarmTime},</if>
            <if test="spoonWeight != null">spoon_weight = #{spoonWeight},</if>
            <if test="weightRemAlarm != null">weight_rem_alarm = #{weightRemAlarm},</if>
            <if test="heartBeatTime != null">heart_beat_time = #{heartBeatTime},</if>
            <if test="carouselTime != null">carousel_time = #{carouselTime},</if>
            <if test="titleSlogan != null">title_slogan = #{titleSlogan},</if>
            <if test="fontSize != null">font_size = #{fontSize},</if>
            <if test="imageMap != null">image_map = #{imageMap},</if>
            <if test="guiStyle != null">gui_style = #{guiStyle},</if>
            <if test="fontColor != null">font_color = #{fontColor},</if>
            <if test="lineNum != null">line_num = #{lineNum},</if>
            <if test="oncePayAmount != null">once_pay_amount = #{oncePayAmount},</if>
            <if test="dataStatus != null">data_status = #{dataStatus},</if>
            <if test="ordOpenLimit != null">ord_open_limit = #{ordOpenLimit},</if>
            <if test="detailNumLimit != null">detail_num_limit = #{detailNumLimit},</if>
            <if test="terminalSn != null">terminal_sn = #{terminalSn},</if>
            <if test="terminalKey != null">terminal_key = #{terminalKey},</if>
            <if test="priStatus != null">pri_status = #{priStatus},</if>
            <if test="priKey != null">pri_key = #{priKey},</if>
            <if test="gateDefaultAmount != null">gate_default_amount = #{gateDefaultAmount},</if>
            <if test="deviceState != null">device_state = #{deviceState},</if>
            <if test="deviceAgreement != null">device_agreement = #{deviceAgreement},</if>
            <if test="revision != null">revision = #{revision},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where device_id = #{deviceId}
    </update>

    <delete id="deleteDeviceInfoByDeviceId" parameterType="Long">
        delete from device_info where device_id = #{deviceId}
    </delete>

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