From fa45b1d79967cf146250143851fbb834dbfb49ff Mon Sep 17 00:00:00 2001 From: hupeh Date: Wed, 4 Jan 2023 00:20:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/rts.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/rts.go b/app/rts.go index 0961e89..ace18b3 100644 --- a/app/rts.go +++ b/app/rts.go @@ -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)) }) }) }