feat: implement task group actions
- allow sorting specifc task groups - duplicate task group - delete all tasks in task group
This commit is contained in:
@ -19,6 +19,7 @@ type Querier interface {
|
||||
CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (RefreshToken, error)
|
||||
CreateSystemOption(ctx context.Context, arg CreateSystemOptionParams) (SystemOption, error)
|
||||
CreateTask(ctx context.Context, arg CreateTaskParams) (Task, error)
|
||||
CreateTaskAll(ctx context.Context, arg CreateTaskAllParams) (Task, error)
|
||||
CreateTaskAssigned(ctx context.Context, arg CreateTaskAssignedParams) (TaskAssigned, error)
|
||||
CreateTaskChecklist(ctx context.Context, arg CreateTaskChecklistParams) (TaskChecklist, error)
|
||||
CreateTaskChecklistItem(ctx context.Context, arg CreateTaskChecklistItemParams) (TaskChecklistItem, error)
|
||||
@ -111,6 +112,7 @@ type Querier interface {
|
||||
UpdateTaskGroupLocation(ctx context.Context, arg UpdateTaskGroupLocationParams) (TaskGroup, error)
|
||||
UpdateTaskLocation(ctx context.Context, arg UpdateTaskLocationParams) (Task, error)
|
||||
UpdateTaskName(ctx context.Context, arg UpdateTaskNameParams) (Task, error)
|
||||
UpdateTaskPosition(ctx context.Context, arg UpdateTaskPositionParams) (Task, error)
|
||||
UpdateTeamMemberRole(ctx context.Context, arg UpdateTeamMemberRoleParams) (TeamMember, error)
|
||||
UpdateUserAccountProfileAvatarURL(ctx context.Context, arg UpdateUserAccountProfileAvatarURLParams) (UserAccount, error)
|
||||
UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) (UserAccount, error)
|
||||
|
@ -2,6 +2,10 @@
|
||||
INSERT INTO task (task_group_id, created_at, name, position)
|
||||
VALUES($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: CreateTaskAll :one
|
||||
INSERT INTO task (task_group_id, created_at, name, position, description, complete, due_date)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *;
|
||||
|
||||
-- name: UpdateTaskDescription :one
|
||||
UPDATE task SET description = $2 WHERE task_id = $1 RETURNING *;
|
||||
|
||||
@ -17,6 +21,9 @@ SELECT * FROM task;
|
||||
-- name: UpdateTaskLocation :one
|
||||
UPDATE task SET task_group_id = $2, position = $3 WHERE task_id = $1 RETURNING *;
|
||||
|
||||
-- name: UpdateTaskPosition :one
|
||||
UPDATE task SET position = $2 WHERE task_id = $1 RETURNING *;
|
||||
|
||||
-- name: DeleteTaskByID :exec
|
||||
DELETE FROM task WHERE task_id = $1;
|
||||
|
||||
|
@ -45,6 +45,46 @@ func (q *Queries) CreateTask(ctx context.Context, arg CreateTaskParams) (Task, e
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createTaskAll = `-- name: CreateTaskAll :one
|
||||
INSERT INTO task (task_group_id, created_at, name, position, description, complete, due_date)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING task_id, task_group_id, created_at, name, position, description, due_date, complete, completed_at
|
||||
`
|
||||
|
||||
type CreateTaskAllParams struct {
|
||||
TaskGroupID uuid.UUID `json:"task_group_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
Description sql.NullString `json:"description"`
|
||||
Complete bool `json:"complete"`
|
||||
DueDate sql.NullTime `json:"due_date"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskAll(ctx context.Context, arg CreateTaskAllParams) (Task, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskAll,
|
||||
arg.TaskGroupID,
|
||||
arg.CreatedAt,
|
||||
arg.Name,
|
||||
arg.Position,
|
||||
arg.Description,
|
||||
arg.Complete,
|
||||
arg.DueDate,
|
||||
)
|
||||
var i Task
|
||||
err := row.Scan(
|
||||
&i.TaskID,
|
||||
&i.TaskGroupID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.Description,
|
||||
&i.DueDate,
|
||||
&i.Complete,
|
||||
&i.CompletedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTaskByID = `-- name: DeleteTaskByID :exec
|
||||
DELETE FROM task WHERE task_id = $1
|
||||
`
|
||||
@ -305,3 +345,29 @@ func (q *Queries) UpdateTaskName(ctx context.Context, arg UpdateTaskNameParams)
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskPosition = `-- name: UpdateTaskPosition :one
|
||||
UPDATE task SET position = $2 WHERE task_id = $1 RETURNING task_id, task_group_id, created_at, name, position, description, due_date, complete, completed_at
|
||||
`
|
||||
|
||||
type UpdateTaskPositionParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskPosition(ctx context.Context, arg UpdateTaskPositionParams) (Task, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskPosition, arg.TaskID, arg.Position)
|
||||
var i Task
|
||||
err := row.Scan(
|
||||
&i.TaskID,
|
||||
&i.TaskGroupID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.Description,
|
||||
&i.DueDate,
|
||||
&i.Complete,
|
||||
&i.CompletedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user