|
@@ -2,6 +2,9 @@ package shop.alien.store.controller;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -15,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import shop.alien.entity.result.R;
|
|
import shop.alien.entity.result.R;
|
|
|
|
|
+import shop.alien.entity.store.CommonRating;
|
|
|
|
|
+import shop.alien.store.service.CommonRatingService;
|
|
|
import shop.alien.store.util.ai.AiAuthTokenUtil;
|
|
import shop.alien.store.util.ai.AiAuthTokenUtil;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -43,6 +48,7 @@ public class AiTagsController {
|
|
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
private final RestTemplate restTemplate;
|
|
|
private final AiAuthTokenUtil aiAuthTokenUtil;
|
|
private final AiAuthTokenUtil aiAuthTokenUtil;
|
|
|
|
|
+ private final CommonRatingService commonRatingService;
|
|
|
/**
|
|
/**
|
|
|
* 获取店铺标签
|
|
* 获取店铺标签
|
|
|
*
|
|
*
|
|
@@ -140,9 +146,21 @@ public class AiTagsController {
|
|
|
if(jsonArray.isEmpty()){
|
|
if(jsonArray.isEmpty()){
|
|
|
throw new Exception("ai接口失败");
|
|
throw new Exception("ai接口失败");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ // 2. 提取list中的数值(这里list是数值数组,而非对象数组)
|
|
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
+ // 直接获取数值并转为Long类型
|
|
|
|
|
+ Object value = jsonArray.get(i);
|
|
|
|
|
+ if (value instanceof Number) {
|
|
|
|
|
+ idList.add(((Number) value).longValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<CommonRating> page1 = new Page<>(page, pageNum);
|
|
|
|
|
+ QueryWrapper<CommonRating> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.in("id",idList);
|
|
|
|
|
+ IPage<CommonRating> page2 = commonRatingService.page(page1, wrapper);
|
|
|
// 保持和原有接口一致的返回格式:将data节点重新封装(可根据实际需求调整)
|
|
// 保持和原有接口一致的返回格式:将data节点重新封装(可根据实际需求调整)
|
|
|
- return R.data(jsonArray);
|
|
|
|
|
|
|
+ return commonRatingService.doListBusinessWithType(page2, 1, null, null);
|
|
|
} else {
|
|
} else {
|
|
|
return R.fail("获取店铺评价失败:" + exchange.getStatusCode());
|
|
return R.fail("获取店铺评价失败:" + exchange.getStatusCode());
|
|
|
}
|
|
}
|