<?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.tofly.scada.mapper.AllocationMapper">

    <resultMap id="BaseResultMap" type="com.tofly.scada.entity.Allocation">
            <id property="id" column="ID" jdbcType="DECIMAL"/>
            <result property="deviceId" column="DEVICE_ID" jdbcType="DECIMAL"/>
            <result property="model" column="MODEL" jdbcType="VARCHAR"/>
            <result property="variableCode" column="VARIABLE_CODE" jdbcType="VARCHAR"/>
            <result property="variableName" column="VARIABLE_NAME" jdbcType="VARCHAR"/>
            <result property="displayName" column="DISPLAY_NAME" jdbcType="VARCHAR"/>
            <result property="unit" column="UNIT" jdbcType="VARCHAR"/>
            <result property="alarmUpperLimit" column="ALARM_UPPER_LIMIT" jdbcType="DECIMAL"/>
            <result property="alarmLowerLimit" column="ALARM_LOWER_LIMIT" jdbcType="DECIMAL"/>
            <result property="isAlarm" column="IS_ALARM" jdbcType="VARCHAR"/>
            <result property="sortNumber" column="SORT_NUMBER" jdbcType="VARCHAR"/>
            <result property="accuracy" column="ACCURACY" jdbcType="DECIMAL"/>
            <result property="archivesCode" column="ARCHIVES_CODE" jdbcType="VARCHAR"/>
            <result property="describe" column="DESCRIBE" jdbcType="VARCHAR"/>
            <result property="createUser" column="CREATE_USER" jdbcType="DECIMAL"/>
            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="type" column="TYPE" jdbcType="VARCHAR"/>
            <result property="isDisplay" column="IS_DISPLAY"/>
            <association property="isDisplayName" column="IS_DISPLAY"
                     select="getIsDisplayName"/>
    </resultMap>
    <select id="getIsDisplayName" resultType="string">
        SELECT decode(#{isDisplay},'0','否','1','是') as isDisplayName FROM dual
    </select>

    <sql id="Base_Column_List">
        ID,DEVICE_ID,MODEL,
        VARIABLE_CODE,VARIABLE_NAME,DISPLAY_NAME,
        UNIT,ALARM_UPPER_LIMIT,ALARM_LOWER_LIMIT,
        IS_ALARM,SORT_NUMBER,ACCURACY,
        ARCHIVES_CODE,DESCRIBE,CREATE_USER,
        CREATE_TIME,TYPE
    </sql>
</mapper>
