fusenapi/model/gmodel/fs_map_library_logic.go

28 lines
886 B
Go
Raw Normal View History

2023-06-16 06:52:45 +00:00
package gmodel
import "context"
2023-06-20 03:52:26 +00:00
func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context, fields string) (resp []FsMapLibrary, err error) {
db := ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 0)
if fields != "" {
db = db.Select(fields)
}
err = db.Find(&resp).Error
2023-06-16 06:52:45 +00:00
if err != nil {
return nil, err
}
return
}
2023-06-20 03:52:26 +00:00
func (ml *FsMapLibraryModel) Create(ctx context.Context, data *FsMapLibrary) error {
return ml.db.WithContext(ctx).Create(data).Error
}
func (ml *FsMapLibraryModel) Update(ctx context.Context, id int64, data *FsMapLibrary) error {
return ml.db.WithContext(ctx).Where("`id` = ? ", id).Updates(data).Error
}
func (ml *FsMapLibraryModel) ChangeStatusByIds(ctx context.Context, ids []int64, status int64) error {
if len(ids) == 0 {
return nil
}
return ml.db.WithContext(ctx).Where("`id` in (?) ", ids).Update("status", 0).Error
}