|
|
|
@ -423,8 +423,8 @@ func UpdateGoods(w *ResponseWriter, r *Request) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetGoodsList 查询商品列表
|
|
|
|
|
func GetGoodsList(w *ResponseWriter, r *Request) { |
|
|
|
|
// ListGoods 查询商品列表
|
|
|
|
|
func ListGoods(w *ResponseWriter, r *Request) { |
|
|
|
|
search := func(db *gorm.DB) *gorm.DB { |
|
|
|
|
return db. |
|
|
|
|
Model(&Goods{}). |
|
|
|
@ -448,7 +448,8 @@ func GetGoodsList(w *ResponseWriter, r *Request) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func GetGoodsPrices(w *ResponseWriter, r *Request) { |
|
|
|
|
// 查询价格列表
|
|
|
|
|
func ListPrices(w *ResponseWriter, r *Request) { |
|
|
|
|
id := uint(r.Uint64("id", 0)) |
|
|
|
|
var goods Goods |
|
|
|
|
if err := DB.Scopes(func(db *gorm.DB) *gorm.DB { |
|
|
|
@ -516,8 +517,8 @@ func RegisterRoutes(r chi.Router) { |
|
|
|
|
r.Group(func(r chi.Router) { |
|
|
|
|
r.Post("/goods", Handler(CreateGoods)) |
|
|
|
|
r.Patch("/goods/:id", Handler(UpdateGoods)) |
|
|
|
|
r.Get("/goods", Handler(GetGoodsList)) |
|
|
|
|
r.Get("/goods/:id/prices", Handler(GetGoodsPrices)) |
|
|
|
|
r.Get("/goods", Handler(ListGoods)) |
|
|
|
|
r.Get("/goods/:id/prices", Handler(ListPrices)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|