- 在评论数据对象中新增 childCommentTotal 和 heat 字段 - 扩展 CommentDOMapper 支持批量更新评论热度值 - 新增 CommentHeatBO 类用于封装评论热度信息 - 实现基于点赞数和回复数的热度值计算工具类 HeatCalculator - 添加 RocketMQ 消费者异步处理评论热度更新消息 - 引入 buffer-trigger依赖实现消息聚合发送 - 扩展 JsonUtils 工具类支持 Set 类型反序列化 - 新增 MQ 常量 TOPIC_COMMENT_HEAT_UPDATE用于热度更新主题 - 修改 SQL 脚本增加 heat 字段并设置默认值- 更新测试接口请求参数内容以适配新逻辑
85 lines
3.7 KiB
XML
85 lines
3.7 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.hanserwei.hannote.comment.biz.domain.mapper.CommentDOMapper">
|
|
<resultMap id="BaseResultMap" type="com.hanserwei.hannote.comment.biz.domain.dataobject.CommentDO">
|
|
<!--@mbg.generated-->
|
|
<!--@Table t_comment-->
|
|
<id column="id" jdbcType="BIGINT" property="id" />
|
|
<result column="note_id" jdbcType="BIGINT" property="noteId" />
|
|
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
|
<result column="content_uuid" jdbcType="VARCHAR" property="contentUuid" />
|
|
<result column="is_content_empty" jdbcType="BIT" property="isContentEmpty" />
|
|
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
|
|
<result column="level" jdbcType="TINYINT" property="level" />
|
|
<result column="reply_total" jdbcType="BIGINT" property="replyTotal" />
|
|
<result column="like_total" jdbcType="BIGINT" property="likeTotal" />
|
|
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
|
|
<result column="reply_comment_id" jdbcType="BIGINT" property="replyCommentId" />
|
|
<result column="reply_user_id" jdbcType="BIGINT" property="replyUserId" />
|
|
<result column="is_top" jdbcType="TINYINT" property="isTop" />
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
<result column="child_comment_total" jdbcType="BIGINT" property="childCommentTotal"/>
|
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
|
<!--@mbg.generated-->
|
|
id,
|
|
note_id,
|
|
user_id,
|
|
content_uuid,
|
|
is_content_empty,
|
|
image_url,
|
|
`level`,
|
|
reply_total,
|
|
like_total,
|
|
parent_id,
|
|
reply_comment_id,
|
|
reply_user_id,
|
|
is_top,
|
|
create_time,
|
|
update_time,
|
|
child_comment_total
|
|
</sql>
|
|
|
|
<select id="selectByCommentIds" resultMap="BaseResultMap" parameterType="list">
|
|
select id,
|
|
level,
|
|
parent_id,
|
|
user_id,
|
|
child_comment_total,
|
|
like_total
|
|
from t_comment
|
|
where id in
|
|
<foreach collection="commentIds" open="(" separator="," close=")" item="commentId">
|
|
#{commentId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<insert id="batchInsert" parameterType="list">
|
|
insert IGNORE into t_comment (id, note_id, user_id,
|
|
content_uuid, is_content_empty, image_url,
|
|
`level`, reply_total, like_total,
|
|
parent_id, reply_comment_id, reply_user_id,
|
|
is_top, create_time, update_time)
|
|
values
|
|
<foreach collection="comments" item="comment" separator=",">
|
|
( #{comment.id}, #{comment.noteId}, #{comment.userId}, #{comment.contentUuid}, #{comment.isContentEmpty}
|
|
, #{comment.imageUrl}, #{comment.level}, #{comment.replyTotal}, #{comment.likeTotal}, #{comment.parentId}
|
|
, #{comment.replyCommentId}, #{comment.replyUserId}, #{comment.isTop}, #{comment.createTime}
|
|
, #{comment.updateTime})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="batchUpdateHeatByCommentIds" parameterType="map">
|
|
UPDATE t_comment
|
|
SET heat = CASE id
|
|
<foreach collection="commentHeatBOS" item="bo" separator="">
|
|
WHEN #{bo.id} THEN #{bo.heat}
|
|
</foreach>
|
|
ELSE heat END
|
|
WHERE id IN
|
|
<foreach collection="commentIds" item="commentId" open="(" close=")" separator=",">
|
|
#{commentId}
|
|
</foreach>
|
|
</update>
|
|
</mapper> |