Documentation ¶
Overview ¶
Package project_user provides an example of a core business API. Right now these calls are just wrapping the data/data layer. But at some point you will want auditing or something that isn't specific to the data/store layer.
Index ¶
- Variables
- type Core
- func (c Core) Create(ctx context.Context, npu NewProjectUser, now time.Time) ([]ProjectUser, error)
- func (c Core) Delete(ctx context.Context, projectUserID string) error
- func (c Core) QueryByID(ctx context.Context, projectUserID string) (ProjectUser, error)
- func (c Core) QueryWorkspaceProjectUsers(ctx context.Context, WorkspaceID string, pageNumber, rowsPerPage int) ([]ProjectUser, error)
- func (c Core) Update(ctx context.Context, projectUserID string, upu UpdateProjectUser, ...) error
- type NewProjectUser
- type ProjectUser
- type UpdateProjectUser
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, npu NewProjectUser, now time.Time) ([]ProjectUser, error)
Create inserts a new project user into the database.
func (Core) QueryWorkspaceProjectUsers ¶
func (c Core) QueryWorkspaceProjectUsers(ctx context.Context, WorkspaceID string, pageNumber, rowsPerPage int) ([]ProjectUser, error)
QueryWorkspaceProjectUsers retrieves a list of existing project user from the database.
type NewProjectUser ¶
type NewProjectUser struct { Pid string `json:"pid" validate:"required"` Uid string `json:"uid" validate:"required"` Wid string `json:"wid"` Manager bool `json:"manager"` Rate float64 `json:"rate"` Puis string `json:"puis"` }
NewProjectUser contains information needed to create a new ProjectUser.
type ProjectUser ¶
type ProjectUser struct { ID string `json:"project_user_id"` Pid string `json:"pid"` Uid string `json:"uid"` Wid string `json:"wid"` Manager bool `json:"manager"` Rate float64 `json:"rate"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` }
ProjectUser represents an individual ProjectUser.
type UpdateProjectUser ¶
UpdateProjectUser defines what information may be provided to modify an existing project user. All fields are optional so project users 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.