You've already forked FrameTour-BE
feat(video): 新增视频评价功能及购买状态查询
- 移除TaskController上的@Deprecated注解 - 在VideoController中新增/checkBuyStatus接口用于查询视频购买状态 - 新增VideoReviewController控制器,提供评价管理功能 - 新增MapTypeHandler用于处理Map类型与JSON字段的转换 - 在VideoMapper中增加countBuyRecordByVideoId方法查询视频购买记录 - 新增视频评价相关实体类、DTO及Mapper接口 - 实现VideoReviewService服务类,支持评价新增、分页查询、统计分析和Excel导出 - 在VideoServiceImpl中实现checkVideoBuyStatus方法 - 修改VideoMapper.xml,关联task表并查询task_params字段 - 新增VideoReviewMapper.xml配置文件,实现评价相关SQL查询
This commit is contained in:
@@ -77,9 +77,11 @@
|
||||
</delete>
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
|
||||
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
|
||||
t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl
|
||||
t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl,
|
||||
tk.task_params taskParams
|
||||
from video v
|
||||
left join template t on v.template_id = t.id
|
||||
left join task tk on v.task_id = tk.id
|
||||
<where>
|
||||
<if test="scenicId!= null">and v.scenic_id = #{scenicId} </if>
|
||||
<if test="templateId!= null">and template_id = #{templateId} </if>
|
||||
@@ -98,9 +100,11 @@
|
||||
<select id="getById" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
|
||||
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
|
||||
t.name templateName,t.price templatePrice, t.cover_url templateCoverUrl, t.slash_price slashPrice,
|
||||
v.height, v.width, v.duration
|
||||
v.height, v.width, v.duration,
|
||||
tk.task_params taskParams
|
||||
from video v
|
||||
left join template t on v.template_id = t.id
|
||||
left join task tk on v.task_id = tk.id
|
||||
where v.id = #{id}
|
||||
</select>
|
||||
<select id="findByTaskId" resultType="com.ycwl.basic.model.pc.video.entity.VideoEntity">
|
||||
@@ -108,10 +112,12 @@
|
||||
</select>
|
||||
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
|
||||
select v.id, mv.scenic_id, v.template_id, mv.task_id, mv.face_id, worker_id, video_url, v.create_time, v.update_time,
|
||||
t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl, mv.is_buy
|
||||
t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl, mv.is_buy,
|
||||
tk.task_params taskParams
|
||||
from member_video mv
|
||||
left join video v on mv.video_id = v.id
|
||||
left join template t on mv.template_id = t.id
|
||||
left join task tk on mv.task_id = tk.id
|
||||
<where>
|
||||
<if test="scenicId!= null">and mv.scenic_id = #{scenicId} </if>
|
||||
<if test="memberId!= null">and mv.member_id = #{memberId} </if>
|
||||
@@ -175,4 +181,11 @@
|
||||
set member_id = #{memberId}
|
||||
where face_id = #{faceId}
|
||||
</update>
|
||||
|
||||
<!-- 查询指定视频是否存在已购买记录 -->
|
||||
<select id="countBuyRecordByVideoId" resultType="int">
|
||||
select count(*)
|
||||
from member_video
|
||||
where video_id = #{videoId} and is_buy = 1
|
||||
</select>
|
||||
</mapper>
|
||||
145
src/main/resources/mapper/VideoReviewMapper.xml
Normal file
145
src/main/resources/mapper/VideoReviewMapper.xml
Normal file
@@ -0,0 +1,145 @@
|
||||
<?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.ycwl.basic.mapper.VideoReviewMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="VideoReviewRespMap" type="com.ycwl.basic.model.pc.videoreview.dto.VideoReviewRespDTO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="videoId" column="video_id"/>
|
||||
<result property="videoUrl" column="video_url"/>
|
||||
<result property="scenicId" column="scenic_id"/>
|
||||
<result property="scenicName" column="scenic_name"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="creatorName" column="creator_name"/>
|
||||
<result property="rating" column="rating"/>
|
||||
<result property="content" column="content"/>
|
||||
<result property="cameraPositionRating" column="camera_position_rating"
|
||||
typeHandler="com.ycwl.basic.handler.MapTypeHandler"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询评价列表 -->
|
||||
<select id="selectReviewList" parameterType="com.ycwl.basic.model.pc.videoreview.dto.VideoReviewListReqDTO"
|
||||
resultMap="VideoReviewRespMap">
|
||||
SELECT
|
||||
vr.id,
|
||||
vr.video_id,
|
||||
vr.scenic_id,
|
||||
vr.creator,
|
||||
vr.rating,
|
||||
vr.content,
|
||||
vr.camera_position_rating,
|
||||
vr.create_time,
|
||||
vr.update_time,
|
||||
v.video_url,
|
||||
s.name AS scenic_name,
|
||||
u.name AS creator_name
|
||||
FROM video_review vr
|
||||
LEFT JOIN video v ON vr.video_id = v.id
|
||||
LEFT JOIN scenic s ON vr.scenic_id = s.id
|
||||
LEFT JOIN sys_user u ON vr.creator = u.id
|
||||
<where>
|
||||
<if test="videoId != null">
|
||||
AND vr.video_id = #{videoId}
|
||||
</if>
|
||||
<if test="scenicId != null">
|
||||
AND vr.scenic_id = #{scenicId}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
AND vr.creator = #{creator}
|
||||
</if>
|
||||
<if test="rating != null">
|
||||
AND vr.rating = #{rating}
|
||||
</if>
|
||||
<if test="minRating != null">
|
||||
AND vr.rating >= #{minRating}
|
||||
</if>
|
||||
<if test="maxRating != null">
|
||||
AND vr.rating <= #{maxRating}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND vr.create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND vr.create_time <= #{endTime}
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND vr.content LIKE CONCAT('%', #{keyword}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY
|
||||
<choose>
|
||||
<when test="orderBy == 'rating'">
|
||||
vr.rating
|
||||
</when>
|
||||
<when test="orderBy == 'update_time'">
|
||||
vr.update_time
|
||||
</when>
|
||||
<otherwise>
|
||||
vr.create_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="orderDirection == 'ASC'">
|
||||
ASC
|
||||
</when>
|
||||
<otherwise>
|
||||
DESC
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 统计总评价数 -->
|
||||
<select id="countTotal" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM video_review
|
||||
</select>
|
||||
|
||||
<!-- 计算平均评分 -->
|
||||
<select id="calculateAverageRating" resultType="java.lang.Double">
|
||||
SELECT AVG(rating) FROM video_review
|
||||
</select>
|
||||
|
||||
<!-- 统计评分分布 -->
|
||||
<select id="countRatingDistribution" resultType="java.util.Map">
|
||||
SELECT
|
||||
rating AS ratingValue,
|
||||
COUNT(*) AS count
|
||||
FROM video_review
|
||||
GROUP BY rating
|
||||
ORDER BY rating
|
||||
</select>
|
||||
|
||||
<!-- 统计最近N天的评价趋势 -->
|
||||
<select id="countRecentTrend" resultType="java.util.Map">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%Y-%m-%d') AS dateStr,
|
||||
COUNT(*) AS count
|
||||
FROM video_review
|
||||
WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL #{days} DAY)
|
||||
GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
|
||||
ORDER BY dateStr
|
||||
</select>
|
||||
|
||||
<!-- 统计景区评价排行 -->
|
||||
<select id="countScenicRank" resultType="com.ycwl.basic.model.pc.videoreview.dto.VideoReviewStatisticsRespDTO$ScenicReviewRank">
|
||||
SELECT
|
||||
vr.scenic_id AS scenicId,
|
||||
s.name AS scenicName,
|
||||
COUNT(*) AS reviewCount,
|
||||
AVG(vr.rating) AS averageRating
|
||||
FROM video_review vr
|
||||
LEFT JOIN scenic s ON vr.scenic_id = s.id
|
||||
GROUP BY vr.scenic_id, s.name
|
||||
ORDER BY reviewCount DESC, averageRating DESC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
<!-- 查询所有机位评价数据 -->
|
||||
<select id="selectAllCameraPositionRatings" resultType="java.util.Map">
|
||||
SELECT camera_position_rating
|
||||
FROM video_review
|
||||
WHERE camera_position_rating IS NOT NULL AND camera_position_rating != ''
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user