From 66c803bc7a0bafcf507be0e2f80b1eccbce9661a Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期一, 01 九月 2025 17:00:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java | 2 ++
buyer-api/src/main/java/cn/lili/controller/lmk/VideoCommentController.java | 37 +++++++++++++++++++++++++++++++++++--
2 files changed, 37 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);
}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java
index bdff64b..1be4cde 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java
@@ -78,6 +78,8 @@
*/
@Override
public Result comment(VideoCommentForm form) {
+ System.out.println("鎵撳嵃璇勮:"+form);
+
// 鐩戞祴鍐呭鏄惁鍖呭惈鏁忔劅璇�
if (SensitiveWordsFilter.includeSentenceWord(form.getCommentContent())) {
return Result.error("璇勮鍚晱鎰熷唴瀹�");
--
Gitblit v1.8.0