infish2018 17 hours ago
parent
commit
02cdb56d28
2 changed files with 6 additions and 7 deletions
  1. 3 3
      sku3d/sku3d/api/a-service-fassi.go
  2. 3 4
      sku3d/sku3d/api/a-service-img.go

+ 3 - 3
sku3d/sku3d/api/a-service-fassi.go

@@ -124,6 +124,8 @@ func RomoveFassiImage(id string) (bool, error) {
 	}
 	defer resp.Body.Close()
 	if resp.StatusCode != http.StatusOK {
+		body, _ := io.ReadAll(resp.Body) // 读取响应体
+		fmt.Println("请求失败,状态码:", resp.StatusCode, "响应体:", string(body))
 		return false, NewError("fassi 删除失败")
 	}
 
@@ -138,9 +140,7 @@ func RomoveFassiImage(id string) (bool, error) {
 		fmt.Println("JSON解析失败:", err)
 		return false, err
 	}
-	if len(out["product_id"]) < 1 {
-		return false, NewError("删除fassi 失败")
-	}
+
 	// 打印JSON响应
 	fmt.Println("返回的JSON数据:", out)
 	return true, nil

+ 3 - 4
sku3d/sku3d/api/a-service-img.go

@@ -150,16 +150,15 @@ func UpdateImage(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	if searchMat.RawImage.Url != matImage.RawImage.Url {
 		// 先删除
 		// 这里原本可能没有图片特征
-		_, err := RomoveFassiImage(matImage.Id.Hex())
-		if err != nil {
-			log.Error("更新时删除fassi image 错误:", err)
-		}
+		RomoveFassiImage(matImage.Id.Hex())
+
 		// 再新增
 		err = AddFassiImage(matImage.Id, matImage.RawImage.Url)
 		if err != nil {
 			log.Error("更新时添加fassi image 错误:", err)
 			return nil, errors.New("更新图片搜索特征错误,请重试!")
 		}
+		fmt.Println("更新fassi image ", matImage.Id.Hex())
 	}
 
 	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, matImage.Id.Hex(), &matImage)