<?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="net.ferrum.business.mapper.QsSpecAttributeValuesMapper">

    <resultMap type="net.ferrum.business.domain.QsSpecAttributeValues" id="QsSpecAttributeValuesResult">
        <result property="valueId" column="value_id"/>
        <result property="typeId" column="type_id"/>
        <result property="value" column="value"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="delFlag" column="del_flag"/>
        <association property="specType" column="type_id" javaType="net.ferrum.business.domain.QsSpecAttributeTypes" resultMap="QsSpecAttributeTypesResult"/>
    </resultMap>

    <resultMap id="QsSpecAttributeTypesResult" type="net.ferrum.business.domain.QsSpecAttributeTypes">
        <result property="typeId" column="type_id"/>
        <result property="typeName" column="type_name"/>
    </resultMap>

    <select id="selectSpecAttributeValuesList" resultMap="QsSpecAttributeValuesResult">
        select a.type_id, a.value_id, a.value,
                a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag, b.type_name
        from qs_spec_attribute_values a
            left join qs_spec_attribute_types b on a.type_id = b.type_id
            ${ew.getCustomSqlSegment}
        order by a.type_id, a.value_id
    </select>

    <select id="selectPageSpecAttributeValuesList" resultMap="QsSpecAttributeValuesResult">
        select a.type_id, a.value_id, a.value,
               a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag, b.type_name
        from qs_spec_attribute_values a
              left join qs_spec_attribute_types b on a.type_id = b.type_id
              ${ew.getCustomSqlSegment}
        order by a.type_id, a.value_id
    </select>

    <select id="selectSpecAttributeValuesByTypesId"
            resultType="net.ferrum.business.domain.QsSpecAttributeValues">
        select a.value_id, a.value, a.type_id, b.type_name
        from qs_spec_attribute_values a, qs_spec_attribute_types b
        where a.type_id = b.type_id
        and a.del_flag != '2'
        and a.type_id = #{typeId}
        order by a.type_id, a.value_id
    </select>

</mapper>
