From e636396c6c16f56931edc8b57b8efb6b9a165786 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期五, 29 八月 2025 17:59:09 +0800
Subject: [PATCH] 评论

---
 buyer-api/src/main/java/cn/lili/controller/lmk/VideoCommentController.java |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoCommentController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoCommentController.java
index d43fea6..cbc5261 100644
--- a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoCommentController.java
+++ b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoCommentController.java
@@ -3,11 +3,18 @@
 import cn.lili.group.Update;
 import cn.lili.group.Add;
 import cn.lili.modules.lmk.domain.form.ThumbsUpRecordForm;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.security.access.prepost.PreAuthorize;
 import lombok.RequiredArgsConstructor;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import org.springframework.validation.annotation.Validated;
+
+import javax.servlet.http.HttpServletRequest;
 import javax.validation.constraints.NotEmpty;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -32,7 +39,8 @@
 public class VideoCommentController {
 
     private final VideoCommentService videoCommentService;
-
+    // Jackson 瀹炰緥锛堢敤浜庢墜鍔ㄨВ鏋� JSON锛�
+    private final ObjectMapper objectMapper = new ObjectMapper();
     @PostMapping("/thumbs_up")
     @ApiOperation(value = "鐐硅禐璇勮", notes = "鐐硅禐璇勮")
     public Result thumbsUp(@RequestBody @Validated(Add.class) ThumbsUpRecordForm form) {
@@ -45,9 +53,34 @@
         return videoCommentService.cancelThumbsUp(form);
     }
 
+//    @PostMapping("/comment")
+//    @ApiOperation(value = "璇勮", notes = "璇勮")
+//    public Result comment(@RequestBody @Validated(Add.class) VideoCommentForm form) {
+//        System.out.println("鎵撳嵃鍑猴細" + form.getCommentContent());
+//        String content = EmojiParser.parseToAliases(form.getCommentContent());
+//        System.out.println("瑙f瀽鍚�:" + content);
+//        return videoCommentService.comment(form);
+//    }
+
     @PostMapping("/comment")
     @ApiOperation(value = "璇勮", notes = "璇勮")
-    public Result comment(@RequestBody @Validated(Add.class) VideoCommentForm form) {
+    public Result comment(HttpServletRequest request)throws IOException {
+        BufferedReader reader = request.getReader();
+        StringBuilder jsonStr = new StringBuilder();
+        String line;
+        while ((line = reader.readLine()) != null) {
+            jsonStr.append(line);
+        }
+        String requestBody = jsonStr.toString();
+        System.out.println("鍚庣鎺ユ敹鐨� JSON 瀛楃涓诧細" + requestBody);
+        // 姝e父杈撳嚭锛歿"commentContent":"鎴慭uD83E\uDD26\u200D\u2642\uFE0F...",...}
+
+        // 2. 鎵嬪姩瑙f瀽 JSON 瀛楃涓诧紙鏄惧紡浣跨敤 UTF-8 缂栫爜锛�
+        VideoCommentForm form = objectMapper.readValue(
+                requestBody.getBytes(StandardCharsets.UTF_8), // 杞负 UTF-8 瀛楄妭鏁扮粍
+                VideoCommentForm.class // 鐩爣瀹炰綋绫�
+        );
+
         return videoCommentService.comment(form);
     }
 

--
Gitblit v1.8.0