|
@@ -33,37 +33,37 @@ func UpdateImage(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
if matImage.Id.IsZero() {
|
|
|
return nil, errors.New("id错误")
|
|
|
}
|
|
|
- searchMat := &model.MatImage{}
|
|
|
- // 如果更新的是面料图
|
|
|
- found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
- CollectName: repo.CollectionMatImages,
|
|
|
- Query: repo.Map{"_id": matImage.Id},
|
|
|
- Project: []string{"rawImage"},
|
|
|
- }, &searchMat)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- // 没有找到面料数据
|
|
|
- if !found {
|
|
|
- return nil, NewError("未找到数据")
|
|
|
- }
|
|
|
- // 未更改图片
|
|
|
- if matImage.RawImage == nil {
|
|
|
- return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, matImage.Id.Hex(), &matImage)
|
|
|
- }
|
|
|
- // 更新了面料原图 对应更新fassi 特征数据
|
|
|
- if searchMat.RawImage.Url != matImage.RawImage.Url {
|
|
|
- // 先删除
|
|
|
- _, err := RomoveFassiImage(matImage.Id.Hex())
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- // 再新增
|
|
|
- err = AddFassiImage(matImage.Id, matImage.RawImage.Url)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- }
|
|
|
+ // searchMat := &model.MatImage{}
|
|
|
+ // // 如果更新的是面料图
|
|
|
+ // found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
+ // CollectName: repo.CollectionMatImages,
|
|
|
+ // Query: repo.Map{"_id": matImage.Id},
|
|
|
+ // Project: []string{"rawImage"},
|
|
|
+ // }, &searchMat)
|
|
|
+ // if err != nil {
|
|
|
+ // return nil, err
|
|
|
+ // }
|
|
|
+ // // 没有找到面料数据
|
|
|
+ // if !found {
|
|
|
+ // return nil, NewError("未找到数据")
|
|
|
+ // }
|
|
|
+ // // 未更改图片
|
|
|
+ // if matImage.RawImage == nil {
|
|
|
+ // return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, matImage.Id.Hex(), &matImage)
|
|
|
+ // }
|
|
|
+ // // 更新了面料原图 对应更新fassi 特征数据
|
|
|
+ // if searchMat.RawImage.Url != matImage.RawImage.Url {
|
|
|
+ // // 先删除
|
|
|
+ // _, err := RomoveFassiImage(matImage.Id.Hex())
|
|
|
+ // if err != nil {
|
|
|
+ // return nil, err
|
|
|
+ // }
|
|
|
+ // // 再新增
|
|
|
+ // err = AddFassiImage(matImage.Id, matImage.RawImage.Url)
|
|
|
+ // if err != nil {
|
|
|
+ // return nil, err
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, matImage.Id.Hex(), &matImage)
|
|
|
}
|