From 150ae1df77494b1f67f0e849b9f11068941e82a1 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Sun, 25 Jun 2023 20:00:27 +0800 Subject: [PATCH] TODO: backend --- model/gmodel/fs_canteen_product_logic.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/model/gmodel/fs_canteen_product_logic.go b/model/gmodel/fs_canteen_product_logic.go index 6114dd23..0795284f 100755 --- a/model/gmodel/fs_canteen_product_logic.go +++ b/model/gmodel/fs_canteen_product_logic.go @@ -11,6 +11,7 @@ func (c *FsCanteenProductModel) GetAllByCanteenTypeId(ctx context.Context, typeI } return } + func (c *FsCanteenProductModel) UpdateById(ctx context.Context, id int64, data *FsCanteenProduct) error { return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` = ? ", id).Updates(&data).Error } @@ -23,3 +24,11 @@ func (c *FsCanteenProductModel) UpdateByIdArr(ctx context.Context, ids []int64, func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProduct) error { return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Create(data).Error } + +func (c *FsCanteenProductModel) GetAllByCanteenTypeIdOrderAsc(ctx context.Context, typeId int64) (resp []FsCanteenProduct, err error) { + err = c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`canteen_type` = ? and `status` = ?", typeId, 1).Order("sort asc").Find(&resp).Error + if err != nil { + return nil, err + } + return +}