54 lines
2.1 KiB
XML
54 lines
2.1 KiB
XML
<?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.nlshop.mapper.ReviewMapper">
|
|
<resultMap id="BaseResultMap" type="com.nlshop.entity.Review">
|
|
<id column="id" property="id"/>
|
|
<result column="user_id" property="userId"/>
|
|
<result column="order_id" property="orderId"/>
|
|
<result column="product_id" property="productId"/>
|
|
<result column="rating" property="rating"/>
|
|
<result column="content" property="content"/>
|
|
<result column="reply" property="reply"/>
|
|
<result column="create_time" property="createTime"/>
|
|
</resultMap>
|
|
|
|
<insert id="insert" parameterType="com.nlshop.entity.Review" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO review (user_id, order_id, product_id, rating, content)
|
|
VALUES (#{userId}, #{orderId}, #{productId}, #{rating}, #{content})
|
|
</insert>
|
|
|
|
<select id="selectByMerchantId" resultMap="BaseResultMap">
|
|
SELECT r.* FROM review r
|
|
INNER JOIN product p ON r.product_id = p.id
|
|
WHERE p.merchant_id = #{merchantId}
|
|
ORDER BY r.create_time DESC
|
|
</select>
|
|
|
|
<select id="selectByProductId" resultMap="BaseResultMap">
|
|
SELECT * FROM review WHERE product_id = #{productId} ORDER BY create_time DESC
|
|
</select>
|
|
|
|
<select id="selectById" resultMap="BaseResultMap">
|
|
SELECT * FROM review WHERE id = #{id}
|
|
</select>
|
|
|
|
<select id="selectByOrderId" resultMap="BaseResultMap">
|
|
SELECT * FROM review WHERE order_id = #{orderId} LIMIT 1
|
|
</select>
|
|
|
|
<select id="selectByOrderIdList" resultMap="BaseResultMap">
|
|
SELECT * FROM review WHERE order_id IN
|
|
<foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
|
|
#{orderId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<update id="update" parameterType="com.nlshop.entity.Review">
|
|
UPDATE review
|
|
<set>
|
|
<if test="reply != null">reply = #{reply},</if>
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
</mapper>
|