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 +}