<?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.BdSpecsTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.sale.classify.BdSpecsType">
        <id column="PK_ID" property="pkId"/>
        <result column="TYPE_NAME" property="typeName"/>
        <result column="PK_TRANSACTION_KEY" property="pkTransactionKey"/>
        <result column="PK_CLASSIFY" property="pkClassify"/>
        <result column="ENABLE_STATE" property="enableState"/>
        <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="DEL_FLAG" property="delFlag"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="SORT" property="sort"/>
    </resultMap>

    <resultMap id="SelectResultMap" type="com.hzs.sale.product.vo.SpecsTypeVo">
        <id column="PK_ID" property="pkId"/>
        <result column="TYPE_NAME" property="typeName"/>
        <result column="PK_CLASSIFY" property="pkClassify"/>
        <result column="SORT" property="sort"/>
        <result column="classifyName" property="classifyName"/>
    </resultMap>

    <select id="selectSpecsTypeList" resultMap="SelectResultMap">
        select st.* ,bc.NAME classifyName from BD_SPECS_TYPE st
        left join BD_CLASSIFY bc on bc.PK_ID = st.PK_CLASSIFY
        where st.DEL_FLAG = '0'
        <if test="typeName != null and typeName !='' ">
            AND st.TYPE_NAME like #{typeName}||'%'
        </if>
        <if test="pkClassify != null and pkClassify !='' ">
            AND st.PK_CLASSIFY = #{pkClassify}
        </if>
        <if test="pkCountry != null">
            and st.PK_COUNTRY = #{pkCountry}
        </if>
        order by st.sort
    </select>

</mapper>
