初始化2
This commit is contained in:
@@ -28,6 +28,17 @@ func (r *FolderRepository) FindByID(id uint64) (*model.Folder, error) {
|
||||
return &folder, nil
|
||||
}
|
||||
|
||||
// FindByBizID 根据业务ID查找文件夹
|
||||
func (r *FolderRepository) FindByBizID(bizID string, ownerID uint64) (*model.Folder, error) {
|
||||
var folder model.Folder
|
||||
err := config.DB.Where("biz_id = ? AND owner_id = ? AND status = 1", bizID, ownerID).
|
||||
First(&folder).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &folder, nil
|
||||
}
|
||||
|
||||
// ListByParent 查询子文件夹列表
|
||||
func (r *FolderRepository) ListByParent(parentID uint64, ownerID uint64) ([]model.Folder, error) {
|
||||
var folders []model.Folder
|
||||
@@ -36,6 +47,32 @@ func (r *FolderRepository) ListByParent(parentID uint64, ownerID uint64) ([]mode
|
||||
return folders, err
|
||||
}
|
||||
|
||||
// CountByParent 统计子文件夹数量
|
||||
func (r *FolderRepository) CountByParent(parentID uint64, ownerID uint64) (int64, error) {
|
||||
var count int64
|
||||
err := config.DB.Model(&model.Folder{}).
|
||||
Where("parent_id = ? AND owner_id = ? AND status = 1", parentID, ownerID).
|
||||
Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
// ListByParentAll 查询子文件夹列表(管理员模式, 不限owner)
|
||||
func (r *FolderRepository) ListByParentAll(parentID uint64) ([]model.Folder, error) {
|
||||
var folders []model.Folder
|
||||
err := config.DB.Where("parent_id = ? AND status = 1", parentID).
|
||||
Order("name ASC").Find(&folders).Error
|
||||
return folders, err
|
||||
}
|
||||
|
||||
// CountByParentAll 统计子文件夹数量(管理员模式, 不限owner)
|
||||
func (r *FolderRepository) CountByParentAll(parentID uint64) (int64, error) {
|
||||
var count int64
|
||||
err := config.DB.Model(&model.Folder{}).
|
||||
Where("parent_id = ? AND status = 1", parentID).
|
||||
Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
// FindByPath 根据路径查找文件夹
|
||||
func (r *FolderRepository) FindByPath(path string, ownerID uint64) (*model.Folder, error) {
|
||||
var folder model.Folder
|
||||
|
||||
Reference in New Issue
Block a user