|
@@ -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)
|
|
|
}
|
|
|
|