|
@@ -29,10 +29,10 @@ func ProductAdd(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
if err != nil {
|
|
|
return nil, errors.New("参数错误!")
|
|
|
}
|
|
|
- ctx := apictx.CreateRepoCtx()
|
|
|
- if form.SupplyId.Hex() == "" {
|
|
|
- return nil, errors.New("供应链id不能为空")
|
|
|
- }
|
|
|
+ _userId := apictx.User.ID
|
|
|
+ userId, _ := primitive.ObjectIDFromHex(_userId)
|
|
|
+ // 供应链端 供应id就算当前用户id
|
|
|
+ form.SupplyId = userId
|
|
|
if form.Name == "" {
|
|
|
return nil, errors.New("产品名不能为空")
|
|
|
}
|
|
@@ -42,7 +42,7 @@ func ProductAdd(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
form.Status = -1
|
|
|
}
|
|
|
|
|
|
- result, err := repo.RepoAddDoc(ctx, repo.CollectionProduct, &form)
|
|
|
+ result, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionProduct, &form)
|
|
|
return result, err
|
|
|
|
|
|
}
|
|
@@ -66,10 +66,8 @@ func ProductUpdate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
return nil, errors.New("该商品不存在")
|
|
|
}
|
|
|
|
|
|
- _userId := apictx.User.ID
|
|
|
- userId, _ := primitive.ObjectIDFromHex(_userId)
|
|
|
// 不是自己的商品
|
|
|
- if product.SupplyId != userId {
|
|
|
+ if product.SupplyId.Hex() != apictx.User.ID {
|
|
|
return nil, errors.New("非法操作")
|
|
|
}
|
|
|
form.UpdateTime = time.Now()
|