<?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.willalp.control.mapper.HsControlDeviceInfoMapper">

    <resultMap type="com.willalp.control.domain.HsControlDeviceInfo" id="HsControlDeviceInfoResult">
        <result property="id" column="id"/>
        <result property="deviceId" column="device_id"/>
        <result property="deviceUseNo" column="device_use_no"/>
        <result property="deviceName" column="device_name"/>
        <result property="dosage" column="dosage"/>
        <result property="statTime" column="stat_time"/>
        <result property="dosageUnit" column="dosage_unit"/>
        <result property="dosagePct" column="dosage_pct"/>
        <result property="deviceIcon" column="device_icon"/>
        <result property="pageBgkcolor" column="page_bgkcolor"/>
        <result property="runningStatus" column="running_status"/>
        <result property="lastOpenTime" column="last_open_time"/>
        <result property="lastCloseTime" column="last_close_time"/>
        <result property="isDelete" column="is_delete"/>
        <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="selectHsControlDeviceInfoVo">
        select id,
               device_id,
               device_name,
               device_use_no,
               dosage,
               dosage_unit,
               dosage_pct,
               device_icon,
               page_bgkcolor,
               running_status,
               last_open_time,
               last_close_time,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_control_device_info
    </sql>

    <select id="selectHsControlDeviceInfoList" parameterType="HsControlDeviceInfo"
            resultMap="HsControlDeviceInfoResult">
        <include refid="selectHsControlDeviceInfoVo"/>
        <where>
            is_delete = 0
            <if test="deviceId != null ">
                  and device_id = #{deviceId}
            </if>
            <if test="deviceName != null  and deviceName != ''">
                  and device_name like concat('%', #{deviceName}, '%')
            </if>
            <if test="dosage != null  and dosage != ''">
                  and dosage = #{dosage}
            </if>
            <if test="dosageUnit != null  and dosageUnit != ''">
                  and dosage_unit = #{dosageUnit}
            </if>
            <if test="dosagePct != null ">
                  and dosage_pct = #{dosagePct}
            </if>
            <if test="deviceIcon != null  and deviceIcon != ''">
                  and device_icon = #{deviceIcon}
            </if>
            <if test="pageBgkcolor != null  and pageBgkcolor != ''">
                  and page_bgkcolor = #{pageBgkcolor}
            </if>
            <if test="runningStatus != null ">
                  and running_status = #{runningStatus}
            </if>
            <if test="lastOpenTime != null ">
                  and last_open_time = #{lastOpenTime}
            </if>
            <if test="lastCloseTime != null ">
                  and last_close_time = #{lastCloseTime}
            </if>
        </where>
    </select>
</mapper>
