UPDATE mini_stray_animal_note
SET comment_count = comment_count + 1
WHERE id = #{noteId}
UPDATE mini_stray_animal_note n
SET n.comment_count = (
SELECT COUNT(1)
FROM mini_stray_animal_note_comment c
WHERE c.note_id = n.id
AND c.flag = 0
)
WHERE 1 = 1
UPDATE mini_stray_animal_note n
INNER JOIN (
SELECT note_id, MAX(create_time) as last_comment_time
FROM mini_stray_animal_note_comment
WHERE create_time >= DATE_SUB(NOW(), INTERVAL 1 DAY)
GROUP BY note_id
) c ON n.id = c.note_id
SET n.comment_count = (
SELECT COUNT(1)
FROM mini_stray_animal_note_comment c2
WHERE c2.note_id = n.id AND c2.flag = 0
)
UPDATE mini_stray_animal_note_comment c
INNER JOIN mini_stray_animal_note n ON c.note_id = n.id
SET c.is_deleted = 1,
c.update_by = #{userId},
c.update_time = NOW(),
c.update_timestamp = UNIX_TIMESTAMP(NOW(3)) * 1000
WHERE n.uuid = #{noteUuid}
AND c.uuid = #{commentUuid}
AND c.is_deleted = 0
AND n.is_deleted = 0
AND (c.mini_user_id = #{userId} OR n.mini_user_id = #{userId})
UPDATE mini_stray_animal_note
SET comment_count = comment_count - 1
WHERE id = #{noteId}
AND comment_count > 0
UPDATE mini_stray_animal_note_comment
SET like_count = like_count + 1
WHERE id = #{commentId}
AND is_deleted = 0
UPDATE mini_stray_animal_note_comment
SET like_count = like_count - 1
WHERE id = #{commentId}
AND is_deleted = 0
AND like_count > 0