Documentation ¶
Index ¶
- Variables
- type Core
- func (c Core) Create(ctx context.Context, userID string, np NewProject, now time.Time) (Project, error)
- func (c Core) Delete(ctx context.Context, projectID string) error
- func (c Core) QueryByID(ctx context.Context, projectID string) (Project, error)
- func (c Core) QueryClientProjects(ctx context.Context, clientID string, pageNumber, rowsPerPage int) ([]Project, error)
- func (c Core) QueryUserProjects(ctx context.Context, userID string, pageNumber, rowsPerPage int) ([]Project, error)
- func (c Core) QueryWorkspaceProjects(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Project, error)
- func (c Core) Update(ctx context.Context, projectID string, up UpdateProject, now time.Time) error
- type NewProject
- type Project
- type UpdateProject
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) Create ¶
func (c Core) Create(ctx context.Context, userID string, np NewProject, now time.Time) (Project, error)
Create inserts a new project into the database.
func (Core) QueryClientProjects ¶
func (c Core) QueryClientProjects(ctx context.Context, clientID string, pageNumber, rowsPerPage int) ([]Project, error)
QueryClientProjects retrieves a list of existing projects from the database.
func (Core) QueryUserProjects ¶
func (c Core) QueryUserProjects(ctx context.Context, userID string, pageNumber, rowsPerPage int) ([]Project, error)
QueryUserProjects retrieves a list of existing projects from the database.
type NewProject ¶
type NewProject struct { Name string `json:"name" validate:"required"` Wid string `json:"wid"` Cid string `json:"cid"` Active bool `json:"active"` IsPrivate bool `json:"is_private"` AutoEstimates bool `json:"auto_estimates"` EstimatedHours time.Duration `json:"estimated_hours"` Billable bool `json:"billable"` Rate float32 `json:"rate"` HexColor string `json:"hex_color"` }
NewProject contains information needed to create a new project.
type Project ¶
type Project struct { ID string `json:"id"` Name string `json:"name"` Wid string `json:"wid"` Cid string `json:"cid"` Uid string `json:"uid"` Active bool `json:"active"` IsPrivate bool `json:"is_private"` Billable bool `json:"billable"` AutoEstimates bool `json:"auto_estimates"` EstimatedHours time.Duration `json:"estimated_hours"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` Rate float32 `json:"rate"` HexColor string `json:"hex_color"` }
Project represents an individual project.
type UpdateProject ¶
type UpdateProject struct { Name *string `json:"name"` Active *bool `json:"active"` IsPrivate *bool `json:"is_private"` AutoEstimates *bool `json:"auto_estimates"` EstimatedHours *time.Duration `json:"estimated_hours"` Billable *bool `json:"billable"` Rate *float32 `json:"rate"` HexColor *string `json:"hex_color"` }
UpdateProject defines what information may be provided to modify an existing project. All fields are optional so projects 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.