fusenapi/model/gmodel/fs_map_library_logic.go
laodaming edeb2bb5f1 fix
2023-06-20 19:56:18 +08:00

28 lines
965 B
Go
Executable File

package gmodel
import "context"
func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context, fields ...string) (resp []FsMapLibrary, err error) {
db := ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Find(&resp).Error
if err != nil {
return nil, err
}
return
}
func (ml *FsMapLibraryModel) Create(ctx context.Context, data *FsMapLibrary) error {
return ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Create(data).Error
}
func (ml *FsMapLibraryModel) Update(ctx context.Context, id int64, data *FsMapLibrary) error {
return ml.db.WithContext(ctx).Model(&FsMapLibrary{}).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).Model(&FsMapLibrary{}).Where("`id` in (?) ", ids).Update("status", 0).Error
}