<?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.hzs.sale.product.mapper.BdProductSpecsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.sale.product.BdProductSpecs">
    <result column="DEL_FLAG" property="delFlag" />
    <result column="PK_COUNTRY" property="pkCountry" />
    <result column="PK_CREATOR" property="pkCreator" />
    <result column="CREATION_TIME" property="creationTime" />
    <result column="PK_MODIFIED" property="pkModified" />
    <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="PK_ID" property="pkId" />
        <result column="PK_PRODUCT" property="pkProduct" />
        <result column="PK_SPECS_TYPE" property="pkSpecsType" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        DEL_FLAG,
        PK_COUNTRY,
        PK_CREATOR,
        CREATION_TIME,
        PK_MODIFIED,
        MODIFIED_TIME,
        PK_ID, PK_PRODUCT, PK_SPECS_TYPE
    </sql>

    <select id="selectByList" resultType="com.hzs.sale.product.vo.ProductSpecsVo">
        select ps.*,st.TYPE_NAME typeName  from  BD_PRODUCT_SPECS ps
        left join  BD_SPECS_TYPE st on st.PK_ID = ps.PK_SPECS_TYPE
        WHERE ps.PK_PRODUCT = #{pkProduct} and ps.del_flag = 0 and st.del_flag = 0
    </select>

    <select id="findByPkSpecsType" resultType="com.hzs.sale.product.vo.BdProductSpecsInfo">
        select distinct bs.PK_ID pkSpecs,bs.SPECS_NAME name  from  BD_WARES_SPECS wl
        left join BD_SPECS bs on bs.pk_id = wl.PK_SPECS
        where
            wl.PK_SPECS_TYPE = #{pkSpecsType} and wl.DEL_FLAG = 0
    </select>

    <select id="queryListByProductId" resultType="com.hzs.sale.product.vo.ProductSpecsVo"  >
        select pbs.PK_PRODUCT pkProduct,
               pbs.PK_SPECS_TYPE pkSpecsType,
               st.PK_TRANSACTION_KEY pkTransactionKey,
               st.TYPE_NAME  typeName from bd_product_specs pbs
        left join bd_specs_type st on st.PK_ID = pbs.PK_SPECS_TYPE
        where pbs.PK_PRODUCT = #{pkProduct} and pbs.PK_COUNTRY = #{pkCountry} and pbs.del_flag = 0 and st.del_flag = 0
    </select>


</mapper>
