26 lines
979 B
Go
Executable File
26 lines
979 B
Go
Executable File
package gmodel
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
func (c *FsCanteenProductModel) GetAllByCanteenTypeId(ctx context.Context, typeId int64) (resp []FsCanteenProduct, err error) {
|
|
err = c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`canteen_type` = ? and `status` = ?", typeId, 1).Find(&resp).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
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
|
|
}
|
|
func (c *FsCanteenProductModel) UpdateByIdArr(ctx context.Context, ids []int64, data *FsCanteenProduct) error {
|
|
if len(ids) == 0 {
|
|
return nil
|
|
}
|
|
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` in (?) ", ids).Updates(&data).Error
|
|
}
|
|
func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProduct) error {
|
|
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Create(data).Error
|
|
}
|