<?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.usky.iot.mapper.DmpProductInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.usky.iot.domain.DmpProductInfo">
        <id column="id" property="id" />
        <result column="product_name" property="productName" />
        <result column="access_mode" property="accessMode" />
        <result column="network_type" property="networkType" />
        <result column="device_type" property="deviceType" />
        <result column="com_protocol" property="comProtocol" />
        <result column="auth_mode" property="authMode" />
        <result column="device_model" property="deviceModel" />
        <result column="product_describe" property="productDescribe" />
        <result column="factory_name" property="factoryName" />
        <result column="factory_person" property="factoryPerson" />
        <result column="factory_phone" property="factoryPhone" />
        <result column="certificate_url1" property="certificateUrl1" />
        <result column="certificate_url2" property="certificateUrl2" />
        <result column="certificate_url3" property="certificateUrl3" />
        <result column="agreement_url" property="agreementUrl" />
        <result column="delete_flag" property="deleteFlag" />
        <result column="created_by" property="createdBy" />
        <result column="created_time" property="createdTime" />
        <result column="updated_by" property="updatedBy" />
        <result column="updated_time" property="updatedTime" />
        <result column="tenant_id" property="tenantId" />
    </resultMap>
    <select id="selectCollect" resultType="java.util.Map">
        select product_name as productName,count(*) as totalCount
        from dmp_product as dp
        inner join dmp_device as dd
        on dp.id = dd.product_id
        <where>
            <if test="tenantId != null">
                and dp.tenant_id = #{tenantId}
            </if>
            <if test="1 == 1">
                and dp.delete_flag = 0
            </if>
        </where>
        group by product_name
    </select>

</mapper>
