Documentation ¶
Index ¶
- Variables
- type Core
- func (c Core) Create(ctx context.Context, userID string, nt NewTask, now time.Time) (Task, error)
- func (c Core) Delete(ctx context.Context, taskID string) error
- func (c Core) QueryByID(ctx context.Context, taskID string) (Task, error)
- func (c Core) QueryProjectTasks(ctx context.Context, projectID string, pageNumber, rowsPerPage int) ([]Task, error)
- func (c Core) QueryWorkspaceTasks(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Task, error)
- func (c Core) Update(ctx context.Context, taskID string, uc UpdateTask, now time.Time) error
- type NewTask
- type Task
- type UpdateTask
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("user not found") ErrInvalidID = errors.New("ID is not in its proper form") )
Set of error variables for CRUD operations.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for user access.
func NewCore ¶
func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB) Core
NewCore constructs a core for user api access.
func (Core) QueryProjectTasks ¶
func (c Core) QueryProjectTasks(ctx context.Context, projectID string, pageNumber, rowsPerPage int) ([]Task, error)
QueryProjectTasks retrieves a list of existing projects from the database.
type NewTask ¶
type NewTask struct { Name string `json:"name" validate:"required"` Pid string `json:"pid" validate:"required"` Wid string `json:"wid"` Uid string `json:"uid"` EstimatedSeconds time.Duration `json:"estimated_seconds"` TrackedSeconds time.Duration `json:"tracked_seconds"` }
NewTask contains information needed to create a new task.
type Task ¶
type Task struct { ID string `json:"id"` Name string `json:"name"` Pid string `json:"pid"` Wid string `json:"wid"` Uid string `json:"uid"` EstimatedSeconds time.Duration `json:"estimated_seconds"` Active bool `json:"active"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` TrackedSeconds time.Duration `json:"tracked_seconds"` }
Task represents an individual task.
type UpdateTask ¶
type UpdateTask struct { Name *string `json:"name"` EstimatedSeconds *time.Duration `json:"estimated_seconds"` Active *bool `json:"active"` TrackedSeconds *time.Duration `json:"tracked_seconds"` }
UpdateTask defines what information may be provided to modify an existing task. All fields are optional so tasks can send just the fields they want changed. It uses pointer fields ,so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types ,but we make exceptions around marshalling/unmarshalling.