<?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.mall.product.mapper.CategoryBrandRelationMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.product.domain.entity.CategoryBrandRelationEntity">
        <id column="id" property="id"/>
        <id column="brand_id" property="brandId"/>
        <id column="catelog_id" property="catelogId"/>
        <id column="brand_name" property="brandName"/>
        <id column="catelog_name" property="catelogName"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,brand_id,catelog_id,brand_name,catelog_name
    </sql>

    <!-- 分页查询品牌分类关联内容 -->
    <select id="selectListByPage" resultType="com.mall.product.domain.vo.CategoryBrandRelationVo">
        select
        <include refid="Base_Column_List"/>
        from pms_category_brand_relation
        <where>
            <if test="dto.id != null and dto.id != ''">
                and id like CONCAT('%',#{dto.id},'%')
            </if>
            <if test="dto.brandId != null and dto.brandId != ''">
                and brand_id like CONCAT('%',#{dto.brandId},'%')
            </if>
            <if test="dto.catelogId != null and dto.catelogId != ''">
                and catelog_id like CONCAT('%',#{dto.catelogId},'%')
            </if>
            <if test="dto.brandName != null and dto.brandName != ''">
                and brand_name like CONCAT('%',#{dto.brandName},'%')
            </if>
            <if test="dto.catelogName != null and dto.catelogName != ''">
                and catelog_name like CONCAT('%',#{dto.catelogName},'%')
            </if>
        </where>
    </select>

</mapper>
