<?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.fzm.mall.server.front.goods.mapper.GoodCommentMapper">
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.front.goods.model.vo.CommentVo">
        <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
        <result column="head_url" jdbcType="INTEGER" property="headUrl" />
        <result column="sku_id" jdbcType="VARCHAR" property="skuId"/>
        <result column="evaluate" jdbcType="INTEGER" property="evaluate"/>
        <result column="content" jdbcType="VARCHAR" property="content"/>
        <result column="images_json" jdbcType="VARCHAR" property="imagesJson"/>
        <result column="video" jdbcType="VARCHAR" property="video"/>
        <result column="business_evaluate" jdbcType="DECIMAL" property="businessEvaluate"/>
        <result column="like_num" jdbcType="INTEGER" property="likeNum"/>
        <result column="tip_off_num" jdbcType="INTEGER" property="tipOffNum"/>
        <result column="views" jdbcType="INTEGER" property="views"/>
        <result column="is_append" jdbcType="INTEGER" property="isAppend"/>
        <result column="anonymous" jdbcType="INTEGER" property="anonymous"/>
        <result column="comment_id" jdbcType="INTEGER" property="commentId"/>
        <result column="create_time" jdbcType="BIGINT" property="createTime"/>
        <result column="update_time" jdbcType="BIGINT" property="updateTime"/>
        <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <result column="amount" jdbcType="DECIMAL" property="price"/>
        <result column="number" jdbcType="INTEGER" property="number"/>
        <result column="thumb" jdbcType="VARCHAR" property="goodsUrl"/>
        <result column="name" jdbcType="INTEGER" property="goodsName"/>
        <result column="reply_content" jdbcType="VARCHAR" property="replyContent"/>
        <result column="merchant_id" jdbcType="VARCHAR" property="merchantId"/>
        <result column="goods_id" jdbcType="VARCHAR" property="goodsId"/>
        <!--一对多，方式一-->
        <collection property="list" ofType="com.fzm.mall.server.front.goods.model.SkuProp" >
            <result column="prop_key" jdbcType="VARCHAR" property="propKey" />
            <result column="prop_val" jdbcType="VARCHAR" property="propVal" />
        </collection>
    </resultMap>
    <select id="getByGoodsId" resultMap="BaseResultMap">
        select e.thumb,f.name,d.amount,d.number, b.user_id ,a.*,prop_key,prop_val,b.nick_name,b.head_url from (select * from goods_comment where goods_id = #{goodsId} and is_valid = 1 order by create_time desc limit ${start} , ${end}) a left join goods_sku_prop c   on c.sku_id = a.sku_id left join user b on a.uid = b.uid left join order_detail d on d.oid = a.oid and d.sku_id = a.sku_id left join goods_sku e on a.sku_id = e.sku_id left join goods_spu f on e.goods_id = f.goods_id;
    </select>
    <select id="getByGoodsIdByCommentId" resultMap="BaseResultMap">
        select e.goods_id,e.thumb,f.name,d.amount,d.number, b.user_id ,a.*,prop_key,prop_val,b.nick_name,b.head_url from (select * from goods_comment where comment_id = #{commentId} and is_valid = 1 ) a left join goods_sku_prop c   on c.sku_id = a.sku_id left join user b on a.uid = b.uid left join order_detail d on d.oid = a.oid and d.sku_id = a.sku_id left join goods_sku e on a.sku_id = e.sku_id left join goods_spu f on e.goods_id = f.goods_id;
    </select>
</mapper>


