This commit is contained in:
laodaming
2023-06-20 11:52:26 +08:00
parent b9e00a72d0
commit e71fb08bd4
7 changed files with 356 additions and 6 deletions

View File

@@ -2,10 +2,26 @@ package gmodel
import "context"
func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context) (resp []FsMapLibrary, err error) {
err = ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 0).Find(&resp).Error
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
if err != nil {
return nil, err
}
return
}
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
}