<?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="cn.pluss.platform.mapper.DeviceDetailMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.DeviceDetail">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="venderCode" property="venderCode"/>
        <result column="deviceLogo" property="deviceLogo"/>
        <result column="venderName" property="venderName"/>
        <result column="venderModel" property="venderModel"/>
        <result column="aisleModel" property="aisleModel"/>
        <result column="type" property="type"/>
        <result column="typeDesc" property="typeDesc"/>
        <result column="groupNo" property="groupNo"/>
        <result column="introDesc" property="introDesc"/>
        <result column="seq" property="seq"/>
        <result column="status" property="status"/>
        <result column="createDt" property="createDt"/>
        <result column="unitPrice" property="unitPrice"/>
        <result column="detail" property="detail"/>
    </resultMap>

    <select id="selectListWithStock" resultType="cn.pluss.platform.entity.DeviceDetail">
        SELECT dd.id, dd.code, dd.venderCode, dd.deviceLogo, dd.venderName, dd.venderModel,
            dd.aisleModel, dd.type, dd.groupNo, dd.size, dd.introDesc, dd.seq, dd.status, dd.createDt, dd.unitPrice,
            dd.wholesalePrice, dd.wholesaleMinNum, dd.detail, ds.specName typeDesc
        FROM tb_pluss_device_detail dd
        LEFT JOIN tb_pluss_device_spec ds ON dd.type = ds.spec AND dd.`code` = ds.`code`
        ${ew.customSqlSegment}
    </select>

    <select id="selectListWithStockWithNoDetail" resultType="cn.pluss.platform.entity.DeviceDetail">
        SELECT dd.id, dd.code, dd.venderCode, dd.deviceLogo, dd.venderName, dd.venderModel,
               dd.aisleModel, dd.type, dd.groupNo, dd.size, dd.seq, dd.status, dd.createDt, dd.unitPrice,
               dd.wholesalePrice, dd.wholesaleMinNum, dd.introDesc, ds.specName typeDesc
        FROM tb_pluss_device_detail dd
                 LEFT JOIN tb_pluss_device_spec ds ON dd.type = ds.spec AND dd.`code` = ds.`code`
            ${ew.customSqlSegment}
    </select>
<!--    <select id="selectListWithStockWithNoDetail" resultType="cn.pluss.platform.entity.DeviceDetail">-->
<!--        SELECT dd.id,-->
<!--               dd.code,-->
<!--               dd.venderCode,-->
<!--               dd.deviceLogo,-->
<!--               dd.venderName,-->
<!--               dd.venderModel,-->
<!--               dd.aisleModel,-->
<!--               dd.type,-->
<!--               dd.groupNo,-->
<!--               dd.size,-->
<!--               dd.seq,-->
<!--               dd.status,-->
<!--               dd.createDt,-->
<!--               dd.unitPrice,-->
<!--               dd.wholesalePrice,-->
<!--               dd.wholesaleMinNum,-->
<!--               dd.introDesc,-->
<!--               ds.specName typeDesc-->
<!--        FROM tb_pluss_device_detail dd-->
<!--                 LEFT JOIN tb_pluss_device_spec ds ON dd.`code` = ds.`code` GROUP BY dd.id-->
<!--            ${ew.customSqlSegment}-->
<!--    </select>-->
</mapper>
