2022-10-26 09:15:14 -05:00
|
|
|
package folder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
GeneralFolderUID = "general"
|
|
|
|
MaxNestedFolderDepth = 8
|
|
|
|
)
|
|
|
|
|
|
|
|
type Folder struct {
|
|
|
|
ID int64
|
|
|
|
OrgID int64
|
|
|
|
UID string
|
|
|
|
ParentUID string
|
|
|
|
Title string
|
|
|
|
Description string
|
|
|
|
|
|
|
|
Created time.Time
|
|
|
|
Updated time.Time
|
|
|
|
|
2022-10-28 07:23:39 -05:00
|
|
|
// TODO: validate if this field is required/relevant to folders.
|
2022-10-26 09:15:14 -05:00
|
|
|
UpdatedBy int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewFolder tales a title and returns a Folder with the Created and Updated
|
|
|
|
// fields set to the current time.
|
|
|
|
func NewFolder(title string, description string) *Folder {
|
|
|
|
return &Folder{
|
|
|
|
Title: title,
|
|
|
|
Description: description,
|
|
|
|
Created: time.Now(),
|
|
|
|
Updated: time.Now(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateFolderCommand captures the information required by the folder service
|
|
|
|
// to create a folder.
|
|
|
|
type CreateFolderCommand struct {
|
|
|
|
UID string `json:"uid"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
ParentUID string `json:"parent_uid"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateFolderCommand captures the information required by the folder service
|
|
|
|
// to update a folder. Use Move to update a folder's parent folder.
|
|
|
|
type UpdateFolderCommand struct {
|
|
|
|
Folder *Folder `json:"folder"` // The extant folder
|
|
|
|
NewUID *string `json:"uid"`
|
|
|
|
NewTitle *string `json:"title"`
|
|
|
|
NewDescription *string `json:"description"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// MoveFolderCommand captures the information required by the folder service
|
|
|
|
// to move a folder.
|
|
|
|
type MoveFolderCommand struct {
|
|
|
|
UID string `json:"uid"`
|
|
|
|
NewParentUID string `json:"new_parent_uid"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteFolderCommand captures the information required by the folder service
|
|
|
|
// to delete a folder.
|
|
|
|
type DeleteFolderCommand struct {
|
|
|
|
UID string `json:"uid"`
|
|
|
|
}
|
|
|
|
|
2022-10-26 10:52:01 -05:00
|
|
|
// GetFolderQuery is used for all folder Get requests. Only one of UID, ID, or
|
2022-10-26 09:15:14 -05:00
|
|
|
// Title should be set; if multilpe fields are set by the caller the dashboard
|
|
|
|
// service will select the field with the most specificity, in order: ID, UID,
|
|
|
|
// Title.
|
2022-10-26 10:52:01 -05:00
|
|
|
type GetFolderQuery struct {
|
2022-10-26 09:15:14 -05:00
|
|
|
UID *string
|
|
|
|
ID *int
|
|
|
|
Title *string
|
|
|
|
}
|
|
|
|
|
2022-10-26 10:52:01 -05:00
|
|
|
// GetParentsQuery captures the information required by the folder service to
|
2022-10-26 09:15:14 -05:00
|
|
|
// return a list of all parent folders of a given folder.
|
2022-10-26 10:52:01 -05:00
|
|
|
type GetParentsQuery struct {
|
2022-10-26 09:15:14 -05:00
|
|
|
UID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTreeCommand captures the information required by the folder service to
|
|
|
|
// return a list of child folders of the given folder.
|
|
|
|
|
2022-10-26 10:52:01 -05:00
|
|
|
type GetTreeQuery struct {
|
2022-10-26 09:15:14 -05:00
|
|
|
UID string
|
|
|
|
Depth int64
|
|
|
|
|
|
|
|
// Pagination options
|
|
|
|
Limit int64
|
|
|
|
Page int64
|
|
|
|
}
|