You've already forked FrameTour-BE
- 引入DeviceRepository用于批量查询机位名称 - 在导出逻辑中收集并排序机位ID,确保表头顺序一致 - 动态生成Excel表头,使用实际机位名称替代原始JSON字段 - 调整单元格样式以支持自动换行,提升可读性 - 更新mapper配置,关联template表获取模板名称 - 优化列宽自适应逻辑,为机位列设置最小宽度保障显示效果 - 日志记录中增加导出机位数量统计信息
151 lines
5.4 KiB
XML
151 lines
5.4 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.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="templateId" column="template_id"/>
|
|
<result property="templateName" column="template_name"/>
|
|
<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.NestedMapTypeHandler"/>
|
|
<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,
|
|
v.template_id,
|
|
t.name AS template_name,
|
|
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 template t ON v.template_id = t.id
|
|
LEFT JOIN scenic s ON vr.scenic_id = s.id
|
|
LEFT JOIN admin_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>
|