|
@@ -31,31 +31,31 @@ func Product(r *GinRouter) {
|
|
|
|
|
|
JWT: true,
|
|
|
OnUpdate: func(c *gin.Context, apictx *ApiSession, entity interface{}) {
|
|
|
- process := entity.(*model.Product)
|
|
|
- process.UpdateTime = time.Now()
|
|
|
+ product := entity.(*model.Product)
|
|
|
+ product.UpdateTime = time.Now()
|
|
|
},
|
|
|
SearchProject: []string{"name", "unit", "norm", "price", "category", "remark"},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
func ProductDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- processId := c.Param("id")
|
|
|
- id, err := primitive.ObjectIDFromHex(processId)
|
|
|
+ productId := c.Param("id")
|
|
|
+ id, err := primitive.ObjectIDFromHex(productId)
|
|
|
if err != nil {
|
|
|
return nil, errors.New("非法id")
|
|
|
}
|
|
|
- var process model.Product
|
|
|
+ var product model.Product
|
|
|
option := &repo.DocSearchOptions{
|
|
|
CollectName: repo.CollectionProduct,
|
|
|
Query: repo.Map{"_id": id},
|
|
|
}
|
|
|
|
|
|
- found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), option, &process)
|
|
|
+ found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), option, &product)
|
|
|
if !found || err != nil {
|
|
|
log.Info(err)
|
|
|
return nil, errors.New("数据未找到")
|
|
|
}
|
|
|
|
|
|
- return process, nil
|
|
|
+ return product, nil
|
|
|
|
|
|
}
|