taskcafe/api/pg/pg.go

91 lines
4.7 KiB
Go
Raw Normal View History

2020-04-10 04:40:22 +02:00
package pg
import (
"context"
"github.com/google/uuid"
"github.com/jmoiron/sqlx"
)
type Repository interface {
CreateTeam(ctx context.Context, arg CreateTeamParams) (Team, error)
DeleteTeamByID(ctx context.Context, teamID uuid.UUID) error
GetTeamByID(ctx context.Context, teamID uuid.UUID) (Team, error)
GetAllTeams(ctx context.Context) ([]Team, error)
2020-04-11 21:24:45 +02:00
2020-04-10 04:40:22 +02:00
CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error)
GetAllProjects(ctx context.Context) ([]Project, error)
GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error)
GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error)
2020-04-11 21:24:45 +02:00
2020-04-10 04:40:22 +02:00
CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error)
2020-04-11 21:24:45 +02:00
GetUserAccountByID(ctx context.Context, userID uuid.UUID) (UserAccount, error)
2020-04-10 04:40:22 +02:00
GetUserAccountByUsername(ctx context.Context, username string) (UserAccount, error)
2020-04-11 21:24:45 +02:00
GetAllUserAccounts(ctx context.Context) ([]UserAccount, error)
2020-05-31 06:11:19 +02:00
GetTaskLabelByID(ctx context.Context, taskLabelID uuid.UUID) (TaskLabel, error)
DeleteTaskLabelForTaskByProjectLabelID(ctx context.Context, arg DeleteTaskLabelForTaskByProjectLabelIDParams) error
GetTaskLabelForTaskByProjectLabelID(ctx context.Context, arg GetTaskLabelForTaskByProjectLabelIDParams) (TaskLabel, error)
UpdateProjectNameByID(ctx context.Context, arg UpdateProjectNameByIDParams) (Project, error)
DeleteTaskLabelByID(ctx context.Context, taskLabelID uuid.UUID) error
2020-04-21 01:04:27 +02:00
CreateProjectLabel(ctx context.Context, arg CreateProjectLabelParams) (ProjectLabel, error)
GetProjectLabelsForProject(ctx context.Context, projectID uuid.UUID) ([]ProjectLabel, error)
GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error)
DeleteProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) error
UpdateProjectLabelColor(ctx context.Context, arg UpdateProjectLabelColorParams) (ProjectLabel, error)
UpdateProjectLabelName(ctx context.Context, arg UpdateProjectLabelNameParams) (ProjectLabel, error)
UpdateProjectLabel(ctx context.Context, arg UpdateProjectLabelParams) (ProjectLabel, error)
2020-04-21 01:04:27 +02:00
2020-05-27 23:18:50 +02:00
GetLabelColors(ctx context.Context) ([]LabelColor, error)
CreateLabelColor(ctx context.Context, arg CreateLabelColorParams) (LabelColor, error)
2020-04-10 04:40:22 +02:00
CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (RefreshToken, error)
GetRefreshTokenByID(ctx context.Context, tokenID uuid.UUID) (RefreshToken, error)
DeleteRefreshTokenByID(ctx context.Context, tokenID uuid.UUID) error
DeleteRefreshTokenByUserID(ctx context.Context, userID uuid.UUID) error
2020-04-11 21:24:45 +02:00
DeleteTaskGroupByID(ctx context.Context, taskGroupID uuid.UUID) (int64, error)
DeleteTasksByTaskGroupID(ctx context.Context, taskGroupID uuid.UUID) (int64, error)
UpdateTaskGroupLocation(ctx context.Context, arg UpdateTaskGroupLocationParams) (TaskGroup, error)
2020-04-10 04:40:22 +02:00
CreateTaskGroup(ctx context.Context, arg CreateTaskGroupParams) (TaskGroup, error)
GetAllTaskGroups(ctx context.Context) ([]TaskGroup, error)
GetTaskGroupsForProject(ctx context.Context, projectID uuid.UUID) ([]TaskGroup, error)
GetTaskGroupByID(ctx context.Context, taskGroupID uuid.UUID) (TaskGroup, error)
2020-04-11 21:24:45 +02:00
GetAllOrganizations(ctx context.Context) ([]Organization, error)
2020-04-10 04:40:22 +02:00
CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error)
2020-04-11 21:24:45 +02:00
2020-04-10 04:40:22 +02:00
GetTeamsForOrganization(ctx context.Context, organizationID uuid.UUID) ([]Team, error)
2020-04-11 21:24:45 +02:00
2020-04-10 04:40:22 +02:00
CreateTask(ctx context.Context, arg CreateTaskParams) (Task, error)
2020-04-20 05:02:55 +02:00
GetTaskByID(ctx context.Context, taskID uuid.UUID) (Task, error)
2020-04-10 04:40:22 +02:00
GetAllTasks(ctx context.Context) ([]Task, error)
GetTasksForTaskGroupID(ctx context.Context, taskGroupID uuid.UUID) ([]Task, error)
UpdateTaskLocation(ctx context.Context, arg UpdateTaskLocationParams) (Task, error)
DeleteTaskByID(ctx context.Context, taskID uuid.UUID) error
UpdateTaskName(ctx context.Context, arg UpdateTaskNameParams) (Task, error)
2020-04-20 05:02:55 +02:00
UpdateTaskDescription(ctx context.Context, arg UpdateTaskDescriptionParams) (Task, error)
CreateTaskLabelForTask(ctx context.Context, arg CreateTaskLabelForTaskParams) (TaskLabel, error)
GetTaskLabelsForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskLabel, error)
GetLabelColorByID(ctx context.Context, labelColorID uuid.UUID) (LabelColor, error)
CreateTaskAssigned(ctx context.Context, arg CreateTaskAssignedParams) (TaskAssigned, error)
GetAssignedMembersForTask(ctx context.Context, taskID uuid.UUID) ([]TaskAssigned, error)
2020-04-21 01:04:27 +02:00
DeleteTaskAssignedByID(ctx context.Context, arg DeleteTaskAssignedByIDParams) (TaskAssigned, error)
2020-04-10 04:40:22 +02:00
}
type repoSvc struct {
*Queries
db *sqlx.DB
}
// NewRepository returns an implementation of the Repository interface.
func NewRepository(db *sqlx.DB) Repository {
return &repoSvc{
Queries: New(db.DB),
db: db,
}
}