<?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.xueyi.system.digitalmans.mapper.DmManDeviceMapper">

    <resultMap type="DmManDevicePo" id="DmManDeviceResult">
        <result property="id"      column="id"       />
        <result property="tenantName"      column="tenant_name"       />
        <result property="deviceId"      column="device_id"       />
        <result property="manCode"      column="man_code"       />
        <result property="activateTime"      column="activate_time"       />
        <result property="softwareVersion"      column="software_version"       />
        <result property="onlineStatus"      column="online_status"       />
        <result property="status"      column="status"       />
        <result property="tId"      column="t_id"       />
        <result property="setupStatus"      column="setup_status"       />
        <result property="apkVersion"      column="apk_version"       />
    </resultMap>




    <select id="selectListByManual" parameterType="DmManDevicePo" resultMap="DmManDeviceResult">
        select * from dm_man_device as s
        <where>
            <if test="id != null ">and id = #{id}</if>
            <if test="tenantName != null  and tenantName != '' ">and tenant_name = #{tenantName} </if>
            <if test="deviceId != null and deviceId != '' " >and device_id = #{deviceId}</if>
            <if test="manCode != null and manCode != ''" >and man_code = #{manCode}</if>
            <if test="activateTime != null ">and activate_time = #{activateTime}</if>
            <if test="softwareVersion != null">and software_version = #{softwareVersion}</if>
            <if test="onlineStatus != null ">and online_status = #{onlineStatus}</if>
            <if test="status != null ">and status = #{status}</if>
            <if test="tId != null  and tId != '' ">and t_id = #{tId}</if>
        </where>
    </select>

    <select id="selectListByManualDeviceIdNotNullByTenantId" resultMap="DmManDeviceResult">
        select * from dm_man_device as s
        where t_id = #{tenantId} and device_id is not null
    </select>

    <select id="getOne" parameterType="String" resultType="DmManDevicePo">
        select * from dm_man_device where device_id = #{devId} Limit 1
    </select>

    <select id="selectInfoByDevId" parameterType="String" resultMap="DmManDeviceResult">
        select * from dm_man_device as s
        where device_id = #{devId} limit 1
    </select>
    <select id="selectInfoBySecret" parameterType="String" resultMap="DmManDeviceResult">
        select * from dm_man_device as s
        where man_code = #{manCode} limit 1
    </select>

    <update id="updateInfoByManual" parameterType="DmManDevicePo">
        update dm_man_device
        <set>
            <if test="tenantName != null  ">tenant_name = #{tenantName},</if>
            <if test="tId != null  ">t_id = #{tId},</if>
            <if test="deviceId != null  ">device_id = #{deviceId},</if>
            <if test="manCode != null  ">man_code = #{manCode},</if>
            <if test="activateTime != null  ">activate_time = #{activateTime},</if>
            <if test="softwareVersion != null  ">software_version = #{softwareVersion},</if>
            <if test="onlineStatus != null  ">online_status = #{onlineStatus},</if>
            <if test="setupStatus != null  ">setup_status = #{setupStatus},</if>
            <if test="apkVersion != null  ">apk_version = #{apkVersion},</if>
        </set>
        where man_code = #{manCode}
    </update>


</mapper>