<?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.lframework.xingyun.basedata.mappers.ProductPropertyItemMapper">

    <resultMap id="ProductPropertyItem"
               type="com.lframework.xingyun.basedata.entity.ProductPropertyItem">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="name" property="name"/>
        <result column="property_id" property="propertyId"/>
        <result column="available" property="available"/>
        <result column="description" property="description"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="ProductPropertyItemDto_sql">
        SELECT
            id,
            code,
            name,
            property_id,
            available,
            description,
            create_by,
            create_time,
            update_by,
            update_time
        FROM base_data_product_property_item
    </sql>
    <select id="query" resultMap="ProductPropertyItem">
        <include refid="ProductPropertyItemDto_sql"/>
        <where>
            AND property_id = #{vo.propertyId}
            <if test="vo != null">
                <if test="vo.code != null and vo.code != ''">
                    AND code = #{vo.code}
                </if>
                <if test="vo.name != null and vo.name != ''">
                    AND name LIKE CONCAT('%', #{vo.name}, '%')
                </if>
                <if test="vo.available != null">
                    AND available = #{vo.available}
                </if>
            </if>
        </where>
        ORDER BY code
    </select>
    <select id="getByPropertyId" resultMap="ProductPropertyItem">
        <include refid="ProductPropertyItemDto_sql"/>
        ORDER BY code
    </select>
</mapper>
