|
@@ -8,11 +8,16 @@ import com.cdf.common.ResultData;
|
|
|
import com.cdf.entity.FdkkUser;
|
|
|
import com.cdf.entity.HotRelation;
|
|
|
import com.cdf.exception.BusinessException;
|
|
|
+import com.cdf.httpClient.client.CdfClient;
|
|
|
import com.cdf.httpClient.client.FdkkClient;
|
|
|
import com.cdf.httpClient.request.FdkkHotData;
|
|
|
import com.cdf.httpClient.request.FdkkHotRequest;
|
|
|
import com.cdf.httpClient.request.FdkkUploadRequest;
|
|
|
+import com.cdf.httpClient.request.SceneRequest;
|
|
|
import com.cdf.httpClient.response.FdkkResponse;
|
|
|
+import com.cdf.httpClient.response.cdf.CdfProduct;
|
|
|
+import com.cdf.httpClient.response.cdf.CdfProductListRequest;
|
|
|
+import com.cdf.httpClient.response.cdf.CdfProductListResponse;
|
|
|
import com.cdf.service.IFdkkUserService;
|
|
|
import com.cdf.service.IHotRelationService;
|
|
|
import com.cdf.util.JwtUtil;
|
|
@@ -20,6 +25,7 @@ import com.dtflys.forest.annotation.JSONBody;
|
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import jdk.nashorn.internal.parser.Token;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -39,12 +45,14 @@ public class FdkkSceneEditController {
|
|
|
|
|
|
@Resource
|
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
- @Value("${oss.bucket}")
|
|
|
+ @Value("${upload.bucket}")
|
|
|
private String bucket;
|
|
|
@Value("${fdkk.hot-path}")
|
|
|
private String hotPath;
|
|
|
@Resource
|
|
|
private FdkkClient fdkkClient;
|
|
|
+ @Resource
|
|
|
+ private CdfClient cdfClient;
|
|
|
@Autowired
|
|
|
private IFdkkUserService fdkkUserService;
|
|
|
@Autowired
|
|
@@ -61,7 +69,7 @@ public class FdkkSceneEditController {
|
|
|
}
|
|
|
List<FdkkHotData> hotDataList = fdkkHotRequest.getHotDataList();
|
|
|
for (FdkkHotData fdkkHotData : hotDataList) {
|
|
|
- List<Integer> relationIds = fdkkHotData.getRelationIds();
|
|
|
+ List<String> relationIds = fdkkHotData.getRelationIds();
|
|
|
String sid = fdkkHotData.getSid();
|
|
|
Integer type = fdkkHotData.getHotType();
|
|
|
HotRelation hotRelation = new HotRelation();
|
|
@@ -92,21 +100,26 @@ public class FdkkSceneEditController {
|
|
|
public ResultData list (@RequestParam(required = false) String num,@RequestHeader String token){
|
|
|
Integer userId = JwtUtil.getId(token);
|
|
|
FdkkUser fdkkUser = fdkkUserService.getById(userId);
|
|
|
- FdkkResponse fdkkResponse = fdkkClient.hotList(num, fdkkUser.getToken());
|
|
|
+ FdkkResponse fdkkResponse = fdkkClient.hotList(new SceneRequest(num), fdkkUser.getToken());
|
|
|
if(fdkkResponse.getCode() !=0){
|
|
|
throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());
|
|
|
}
|
|
|
- JSONArray tags = JSONObject.parseObject(JSONObject.toJSONString(fdkkResponse.getData())).getJSONArray("tags");
|
|
|
- for (Object obj : tags) {
|
|
|
- JSONObject tag = (JSONObject) obj;
|
|
|
- String sid = tag.getString("sid");
|
|
|
- HotRelation hotRelation = hotRelationService.getById(sid);
|
|
|
- String relationIds = hotRelation.getRelationIds();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(fdkkResponse.getData()));
|
|
|
+ JSONArray tags =jsonObject.getJSONArray("tags");
|
|
|
+ jsonObject.put("tags",getProductByJsonObj(tags));
|
|
|
+ return ResultData.ok(jsonObject);
|
|
|
+ }
|
|
|
+ @PostMapping("/tag/getHotJs")
|
|
|
+ public ResultData getHotJs (@RequestParam(required = false) String num,@RequestHeader String token){
|
|
|
+ String data = uploadToOssUtil.getObjectContent(bucket, String.format(hotPath, num));
|
|
|
+ if(StringUtils.isBlank(data)){
|
|
|
+ throw new BusinessException(ResultCode.NOT_RECORD);
|
|
|
}
|
|
|
-
|
|
|
- return ResultData.ok();
|
|
|
+ JSONArray tags = JSONObject.parseArray(data);
|
|
|
+ return ResultData.ok(getProductByJsonObj(tags));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@PostMapping("publicScene")
|
|
|
public ResultData scenePublicScene(@RequestBody FdkkHotRequest fdkkHotRequest ,@RequestHeader String token){
|
|
|
Integer userId = JwtUtil.getId(token);
|
|
@@ -150,4 +163,33 @@ public class FdkkSceneEditController {
|
|
|
return ResultData.ok(fdkkResponse.getMsg(),fdkkResponse.getData());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private JSONArray getProductByJsonObj(JSONArray tags){
|
|
|
+ for (Object obj : tags) {
|
|
|
+ JSONObject tag = (JSONObject) obj;
|
|
|
+ String sid = tag.getString("sid");
|
|
|
+ HotRelation hotRelation = hotRelationService.getById(sid);
|
|
|
+ if(hotRelation == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String relationIds = hotRelation.getRelationIds();
|
|
|
+ JSONArray jsonArray = JSONObject.parseArray(relationIds);
|
|
|
+ List<CdfProduct> products = new ArrayList<>();
|
|
|
+ for (Object o : jsonArray) {
|
|
|
+ String productId = (String) o;
|
|
|
+ CdfProductListRequest param = new CdfProductListRequest();
|
|
|
+ param.setKeyword(productId);
|
|
|
+ CdfProductListResponse productList = cdfClient.getProductList(param);
|
|
|
+ if(productList.getSearchResult().getType() == 0 && productList.getList().size() >0){
|
|
|
+ CdfProduct cdfProduct = productList.getList().get(0);
|
|
|
+ products.add(cdfProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(products.size() >0){
|
|
|
+ tag.put("products",products);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tags;
|
|
|
+ }
|
|
|
}
|