This commit is contained in:
laodaming
2023-09-05 16:35:02 +08:00
parent fe270ed8e3
commit 4fbbbb27df
4 changed files with 57 additions and 7 deletions

View File

@@ -104,7 +104,17 @@ func (m *FsResourceModel) Trans(ctx context.Context, fn func(ctx context.Context
// return err
}
func (m *FsResourceModel) FindAllByResourceIds(ctx context.Context, resourceIds []string, fields ...string) (resp []FsResource, err error) {
if len(resourceIds) == 0 {
return
}
db := m.db.WithContext(ctx).Model(&FsResource{}).Where("resource_id in (?)", resourceIds)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Find(&resp).Error
return resp, err
}
func (m *FsResourceModel) TableName() string {
return m.name
}