This commit is contained in:
Leo
2026-02-03 15:19:12 +08:00
parent 2b34ba6cdb
commit b8d3f9e9be
3 changed files with 34 additions and 0 deletions

View File

@@ -5,12 +5,15 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.jarvis.domain.Comment; import com.ruoyi.jarvis.domain.Comment;
import com.ruoyi.jarvis.domain.dto.CommentApiStatistics; import com.ruoyi.jarvis.domain.dto.CommentApiStatistics;
import com.ruoyi.jarvis.domain.dto.CommentStatistics; import com.ruoyi.jarvis.domain.dto.CommentStatistics;
import com.ruoyi.jarvis.service.ICommentService; import com.ruoyi.jarvis.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -28,6 +31,10 @@ public class CommentController extends BaseController {
@Autowired @Autowired
private ICommentService commentService; private ICommentService commentService;
/** 获取评论外部服务地址(后端转发,避免前端跨域) */
@Value("${jarvis.server.fetch-comments.base-url:http://192.168.8.60:5008}")
private String fetchCommentsBaseUrl;
/** /**
* 查询京东评论列表 * 查询京东评论列表
*/ */
@@ -133,5 +140,26 @@ public class CommentController extends BaseController {
Map<String, String> map = commentService.getTbProductTypeMap(); Map<String, String> map = commentService.getTbProductTypeMap();
return success(map); return success(map);
} }
/**
* 获取评论(后端转发到外部服务,避免前端跨域)
* 请求转发至GET {fetch-comments.base-url}/fetch_comments?product_id=xxx
*/
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
@Log(title = "评论管理", businessType = BusinessType.OTHER)
@GetMapping("/fetch-comments")
public AjaxResult fetchComments(@RequestParam("product_id") String productId) {
if (StringUtils.isBlank(productId)) {
return error("商品ID(product_id)不能为空");
}
try {
String url = fetchCommentsBaseUrl + "/fetch_comments";
String param = "product_id=" + java.net.URLEncoder.encode(productId.trim(), "UTF-8");
HttpUtils.sendGet(url, param);
return success();
} catch (Exception e) {
return error("调用获取评论接口失败: " + e.getMessage());
}
}
} }

View File

@@ -202,6 +202,9 @@ jarvis:
base-url: http://192.168.8.88:5001 base-url: http://192.168.8.88:5001
fetch-path: /fetch_logistics fetch-path: /fetch_logistics
health-path: /health health-path: /health
# 获取评论接口服务地址(后端转发,避免前端跨域)
fetch-comments:
base-url: http://192.168.8.60:5008
# 腾讯文档开放平台配置 # 腾讯文档开放平台配置
# 文档地址https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html # 文档地址https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html
tencent: tencent:

View File

@@ -202,6 +202,9 @@ jarvis:
base-url: http://127.0.0.1:5001 base-url: http://127.0.0.1:5001
fetch-path: /fetch_logistics fetch-path: /fetch_logistics
health-path: /health health-path: /health
# 获取评论接口服务地址(后端转发)
fetch-comments:
base-url: http://192.168.8.60:5008
# 腾讯文档开放平台配置 # 腾讯文档开放平台配置
# 文档地址https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html # 文档地址https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html
tencent: tencent: