Prechádzať zdrojové kódy

Merge branch 'batch' of http://124.70.149.18:10880/waibao_2025/hangzhou_mat_manage into batch

491520313@qq.com 1 deň pred
rodič
commit
ce39e55617

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

@@ -25,7 +25,10 @@ func AddFassiImage(imgId primitive.ObjectID, url string) error {
 	}
 
 	// 发送POST请求
+	fmt.Println("add vector=", payload)
 	resp, err := http.Post(api, "application/json", bytes.NewBuffer(jsonData))
+	fmt.Println("add vector back!!!")
+
 	if err != nil {
 		fmt.Println("请求失败:", err)
 		return err
@@ -124,6 +127,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 +143,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

+ 9 - 11
sku3d/sku3d/api/a-service-img.go

@@ -142,26 +142,24 @@ func UpdateImage(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	if !found {
 		return nil, NewError("未找到数据")
 	}
-	// 未更改图片
-	if matImage.RawImage == nil || searchMat.RawImage == nil || matImage.RawImage.Url == searchMat.RawImage.Url {
-		return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, matImage.Id.Hex(), &matImage)
-	}
+	fmt.Println("updateing ==============")
+	fmt.Println(matImage.RawImage, searchMat.RawImage)
+
 	// 更新了面料原图 对应更新fassi 特征数据
-	if searchMat.RawImage.Url != matImage.RawImage.Url {
+	if matImage.RawImage != nil && (searchMat.RawImage == nil || 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)
+			fmt.Println("更新时添加fassi image 错误:", err)
 			return nil, errors.New("更新图片搜索特征错误,请重试!")
 		}
+		fmt.Println("更新fassi image ", matImage.Id.Hex(), err)
 	}
-
+	fmt.Println("33333")
 	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, matImage.Id.Hex(), &matImage)
 }