|
@@ -18,7 +18,7 @@ func Product(r *GinRouter) {
|
|
|
r.POSTJWT("/product/create", ProductAdd)
|
|
|
r.POSTJWT("/product/update", ProductUpdate)
|
|
|
r.GETJWT("/product/list", ProductList)
|
|
|
- r.POSTJWT("/product/onOrOffShelves", OnOrOffShelves)
|
|
|
+ r.POSTJWT("/product/onOrOffShelves/:id", OnOrOffShelves)
|
|
|
r.GETJWT("/product/detail/:id", ProductDetail)
|
|
|
r.POSTJWT("/product/delete/:id", ProductDelete)
|
|
|
|
|
@@ -122,11 +122,8 @@ func OnOrOffShelves(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("非法操作")
|
|
|
}
|
|
|
// 更新状态
|