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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.product.domain.entity.SpuCommentEntity">
        <id column="id" property="id"/>
        <id column="sku_id" property="skuId"/>
        <id column="spu_id" property="spuId"/>
        <id column="spu_name" property="spuName"/>
        <id column="member_nick_name" property="memberNickName"/>
        <id column="star" property="star"/>
        <id column="member_ip" property="memberIp"/>
        <id column="create_time" property="createTime"/>
        <id column="show_status" property="showStatus"/>
        <id column="spu_attributes" property="spuAttributes"/>
        <id column="likes_count" property="likesCount"/>
        <id column="reply_count" property="replyCount"/>
        <id column="resources" property="resources"/>
        <id column="content" property="content"/>
        <id column="member_icon" property="memberIcon"/>
        <id column="comment_type" property="commentType"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,sku_id,spu_id,spu_name,member_nick_name,star,member_ip,create_time,show_status,spu_attributes,likes_count,reply_count,resources,content,member_icon,comment_type
    </sql>

    <!-- 分页查询商品评价内容 -->
    <select id="selectListByPage" resultType="com.mall.product.domain.vo.SpuCommentVo">
        select
        <include refid="Base_Column_List"/>
        from pms_spu_comment
        <where>
            <if test="dto.id != null and dto.id != ''">
                and id like CONCAT('%',#{dto.id},'%')
            </if>
            <if test="dto.skuId != null and dto.skuId != ''">
                and sku_id like CONCAT('%',#{dto.skuId},'%')
            </if>
            <if test="dto.spuId != null and dto.spuId != ''">
                and spu_id like CONCAT('%',#{dto.spuId},'%')
            </if>
            <if test="dto.spuName != null and dto.spuName != ''">
                and spu_name like CONCAT('%',#{dto.spuName},'%')
            </if>
            <if test="dto.memberNickName != null and dto.memberNickName != ''">
                and member_nick_name like CONCAT('%',#{dto.memberNickName},'%')
            </if>
            <if test="dto.star != null and dto.star != ''">
                and star like CONCAT('%',#{dto.star},'%')
            </if>
            <if test="dto.memberIp != null and dto.memberIp != ''">
                and member_ip like CONCAT('%',#{dto.memberIp},'%')
            </if>
            <if test="dto.createTime != null and dto.createTime != ''">
                and create_time like CONCAT('%',#{dto.createTime},'%')
            </if>
            <if test="dto.showStatus != null and dto.showStatus != ''">
                and show_status like CONCAT('%',#{dto.showStatus},'%')
            </if>
            <if test="dto.spuAttributes != null and dto.spuAttributes != ''">
                and spu_attributes like CONCAT('%',#{dto.spuAttributes},'%')
            </if>
            <if test="dto.likesCount != null and dto.likesCount != ''">
                and likes_count like CONCAT('%',#{dto.likesCount},'%')
            </if>
            <if test="dto.replyCount != null and dto.replyCount != ''">
                and reply_count like CONCAT('%',#{dto.replyCount},'%')
            </if>
            <if test="dto.resources != null and dto.resources != ''">
                and resources like CONCAT('%',#{dto.resources},'%')
            </if>
            <if test="dto.content != null and dto.content != ''">
                and content like CONCAT('%',#{dto.content},'%')
            </if>
            <if test="dto.memberIcon != null and dto.memberIcon != ''">
                and member_icon like CONCAT('%',#{dto.memberIcon},'%')
            </if>
            <if test="dto.commentType != null and dto.commentType != ''">
                and comment_type like CONCAT('%',#{dto.commentType},'%')
            </if>
        </where>
    </select>

</mapper>
