<?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.casic.missiles.modular.system.dao.DeviceTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.modular.system.model.DeviceType">
        <id column="ID" property="id"/>
        <result column="TYPE_NAME" property="typeName"/>
        <result column="TYPE_DESCRIPTION" property="typeDescription"/>
        <result column="VALID" property="valid"/>
        <result column="WATCH_TYPE" property="watchType"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID AS id, TYPE_NAME AS "typeName", TYPE_DESCRIPTION AS "typeDescription", VALID AS valid, WATCH_TYPE AS "watchType"
    </sql>

    <select id="countDeviceByType" resultType="java.lang.Integer">
        select count(*)
        from bus_device
        where DEVICE_TYPE = #{typeId}
    </select>


    <select id="getlistPage" resultType="MAP">
        select ID AS "id",WATCH_TYPE "watchType",ALARM_RULE_TYPE AS "alarmRuleType",
        VALID AS valid,ALARM_RULE_LOWVALUE AS "alarmRuleLowvalue",
        ALARM_RULE_HIGHVALUE AS "alarmRuleHighvalue",IS_NO_CONCENT AS "isNoConcent",
        TYPE_NAME AS "typeName",TYPE_DESCRIPTION AS "typeDescription",DATA_CONFIG AS "dataConfig"
        from base_device_type
        WHERE 1=1
        <if test="typeName != null and typeName !=''">
            AND TYPE_NAME= #{typeName}
        </if>
        <if test="isValid != null and isValid !=''">
            AND VALID = #{isValid}
        </if>
    </select>

</mapper>
