redesign
This commit is contained in:
@ -1,81 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: label_color.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createLabelColor = `-- name: CreateLabelColor :one
|
||||
INSERT INTO label_color (name, color_hex, position) VALUES ($1, $2, $3)
|
||||
RETURNING label_color_id, color_hex, position, name
|
||||
`
|
||||
|
||||
type CreateLabelColorParams struct {
|
||||
Name string `json:"name"`
|
||||
ColorHex string `json:"color_hex"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateLabelColor(ctx context.Context, arg CreateLabelColorParams) (LabelColor, error) {
|
||||
row := q.db.QueryRowContext(ctx, createLabelColor, arg.Name, arg.ColorHex, arg.Position)
|
||||
var i LabelColor
|
||||
err := row.Scan(
|
||||
&i.LabelColorID,
|
||||
&i.ColorHex,
|
||||
&i.Position,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getLabelColorByID = `-- name: GetLabelColorByID :one
|
||||
SELECT label_color_id, color_hex, position, name FROM label_color WHERE label_color_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetLabelColorByID(ctx context.Context, labelColorID uuid.UUID) (LabelColor, error) {
|
||||
row := q.db.QueryRowContext(ctx, getLabelColorByID, labelColorID)
|
||||
var i LabelColor
|
||||
err := row.Scan(
|
||||
&i.LabelColorID,
|
||||
&i.ColorHex,
|
||||
&i.Position,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getLabelColors = `-- name: GetLabelColors :many
|
||||
SELECT label_color_id, color_hex, position, name FROM label_color
|
||||
`
|
||||
|
||||
func (q *Queries) GetLabelColors(ctx context.Context) ([]LabelColor, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getLabelColors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []LabelColor
|
||||
for rows.Next() {
|
||||
var i LabelColor
|
||||
if err := rows.Scan(
|
||||
&i.LabelColorID,
|
||||
&i.ColorHex,
|
||||
&i.Position,
|
||||
&i.Name,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
@ -4,261 +4,24 @@ package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type AccountSetting struct {
|
||||
AccountSettingID string `json:"account_setting_id"`
|
||||
Constrained bool `json:"constrained"`
|
||||
DataType string `json:"data_type"`
|
||||
ConstrainedDefaultValue sql.NullString `json:"constrained_default_value"`
|
||||
UnconstrainedDefaultValue sql.NullString `json:"unconstrained_default_value"`
|
||||
}
|
||||
|
||||
type AccountSettingAllowedValue struct {
|
||||
AllowedValueID uuid.UUID `json:"allowed_value_id"`
|
||||
SettingID int32 `json:"setting_id"`
|
||||
ItemValue string `json:"item_value"`
|
||||
}
|
||||
|
||||
type AccountSettingDataType struct {
|
||||
DataTypeID string `json:"data_type_id"`
|
||||
}
|
||||
|
||||
type AccountSettingValue struct {
|
||||
AccountSettingID uuid.UUID `json:"account_setting_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
SettingID int32 `json:"setting_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
AllowedValueID uuid.UUID `json:"allowed_value_id"`
|
||||
UnconstrainedValue sql.NullString `json:"unconstrained_value"`
|
||||
}
|
||||
|
||||
type AuthToken struct {
|
||||
TokenID uuid.UUID `json:"token_id"`
|
||||
type AccessToken struct {
|
||||
Token string `json:"token"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
type LabelColor struct {
|
||||
LabelColorID uuid.UUID `json:"label_color_id"`
|
||||
ColorHex string `json:"color_hex"`
|
||||
Position float64 `json:"position"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Notification struct {
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
ActionType string `json:"action_type"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
}
|
||||
|
||||
type NotificationNotified struct {
|
||||
NotifiedID uuid.UUID `json:"notified_id"`
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Read bool `json:"read"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
}
|
||||
|
||||
type Organization struct {
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type PersonalProject struct {
|
||||
PersonalProjectID uuid.UUID `json:"personal_project_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
PublicOn sql.NullTime `json:"public_on"`
|
||||
ShortID string `json:"short_id"`
|
||||
}
|
||||
|
||||
type ProjectLabel struct {
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
LabelColorID uuid.UUID `json:"label_color_id"`
|
||||
CreatedDate time.Time `json:"created_date"`
|
||||
Name sql.NullString `json:"name"`
|
||||
}
|
||||
|
||||
type ProjectMember struct {
|
||||
ProjectMemberID uuid.UUID `json:"project_member_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
AddedAt time.Time `json:"added_at"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
type ProjectMemberInvited struct {
|
||||
ProjectMemberInvitedID uuid.UUID `json:"project_member_invited_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SystemOption struct {
|
||||
OptionID uuid.UUID `json:"option_id"`
|
||||
Key string `json:"key"`
|
||||
Value sql.NullString `json:"value"`
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
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"`
|
||||
DueDate sql.NullTime `json:"due_date"`
|
||||
Complete bool `json:"complete"`
|
||||
CompletedAt sql.NullTime `json:"completed_at"`
|
||||
HasTime bool `json:"has_time"`
|
||||
ShortID string `json:"short_id"`
|
||||
}
|
||||
|
||||
type TaskActivity struct {
|
||||
TaskActivityID uuid.UUID `json:"task_activity_id"`
|
||||
Active bool `json:"active"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
ActivityTypeID int32 `json:"activity_type_id"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
type TaskActivityType struct {
|
||||
TaskActivityTypeID int32 `json:"task_activity_type_id"`
|
||||
Code string `json:"code"`
|
||||
Template string `json:"template"`
|
||||
}
|
||||
|
||||
type TaskAssigned struct {
|
||||
TaskAssignedID uuid.UUID `json:"task_assigned_id"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
AssignedDate time.Time `json:"assigned_date"`
|
||||
}
|
||||
|
||||
type TaskChecklist struct {
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type TaskChecklistItem struct {
|
||||
TaskChecklistItemID uuid.UUID `json:"task_checklist_item_id"`
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Complete bool `json:"complete"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
DueDate sql.NullTime `json:"due_date"`
|
||||
}
|
||||
|
||||
type TaskComment struct {
|
||||
TaskCommentID uuid.UUID `json:"task_comment_id"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt sql.NullTime `json:"updated_at"`
|
||||
CreatedBy uuid.UUID `json:"created_by"`
|
||||
Pinned bool `json:"pinned"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type TaskDueDateReminder struct {
|
||||
DueDateReminderID uuid.UUID `json:"due_date_reminder_id"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
Period int32 `json:"period"`
|
||||
Duration string `json:"duration"`
|
||||
RemindAt time.Time `json:"remind_at"`
|
||||
}
|
||||
|
||||
type TaskDueDateReminderDuration struct {
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type TaskGroup struct {
|
||||
TaskGroupID uuid.UUID `json:"task_group_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type TaskLabel struct {
|
||||
TaskLabelID uuid.UUID `json:"task_label_id"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
AssignedDate time.Time `json:"assigned_date"`
|
||||
}
|
||||
|
||||
type TaskWatcher struct {
|
||||
TaskWatcherID uuid.UUID `json:"task_watcher_id"`
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
WatchedAt time.Time `json:"watched_at"`
|
||||
}
|
||||
|
||||
type Team struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
}
|
||||
|
||||
type TeamMember struct {
|
||||
TeamMemberID uuid.UUID `json:"team_member_id"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Addeddate time.Time `json:"addeddate"`
|
||||
RoleCode string `json:"role_code"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type UserAccount struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
ProfileBgColor string `json:"profile_bg_color"`
|
||||
FullName string `json:"full_name"`
|
||||
Initials string `json:"initials"`
|
||||
ProfileAvatarUrl sql.NullString `json:"profile_avatar_url"`
|
||||
RoleCode string `json:"role_code"`
|
||||
Bio string `json:"bio"`
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
type UserAccountConfirmToken struct {
|
||||
ConfirmTokenID uuid.UUID `json:"confirm_token_id"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type UserAccountInvited struct {
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invited_on"`
|
||||
HasJoined bool `json:"has_joined"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Fullname string `json:"fullname"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
AvatarUrl sql.NullString `json:"avatar_url"`
|
||||
}
|
||||
|
@ -1,383 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: notification.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
const createNotification = `-- name: CreateNotification :one
|
||||
INSERT INTO notification (caused_by, data, action_type, created_on)
|
||||
VALUES ($1, $2, $3, $4) RETURNING notification_id, caused_by, action_type, data, created_on
|
||||
`
|
||||
|
||||
type CreateNotificationParams struct {
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
ActionType string `json:"action_type"`
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateNotification(ctx context.Context, arg CreateNotificationParams) (Notification, error) {
|
||||
row := q.db.QueryRowContext(ctx, createNotification,
|
||||
arg.CausedBy,
|
||||
arg.Data,
|
||||
arg.ActionType,
|
||||
arg.CreatedOn,
|
||||
)
|
||||
var i Notification
|
||||
err := row.Scan(
|
||||
&i.NotificationID,
|
||||
&i.CausedBy,
|
||||
&i.ActionType,
|
||||
&i.Data,
|
||||
&i.CreatedOn,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createNotificationNotifed = `-- name: CreateNotificationNotifed :one
|
||||
INSERT INTO notification_notified (notification_id, user_id) VALUES ($1, $2) RETURNING notified_id, notification_id, user_id, read, read_at
|
||||
`
|
||||
|
||||
type CreateNotificationNotifedParams struct {
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateNotificationNotifed(ctx context.Context, arg CreateNotificationNotifedParams) (NotificationNotified, error) {
|
||||
row := q.db.QueryRowContext(ctx, createNotificationNotifed, arg.NotificationID, arg.UserID)
|
||||
var i NotificationNotified
|
||||
err := row.Scan(
|
||||
&i.NotifiedID,
|
||||
&i.NotificationID,
|
||||
&i.UserID,
|
||||
&i.Read,
|
||||
&i.ReadAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAllNotificationsForUserID = `-- name: GetAllNotificationsForUserID :many
|
||||
SELECT notified_id, nn.notification_id, user_id, read, read_at, n.notification_id, caused_by, action_type, data, created_on FROM notification_notified AS nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE nn.user_id = $1
|
||||
`
|
||||
|
||||
type GetAllNotificationsForUserIDRow struct {
|
||||
NotifiedID uuid.UUID `json:"notified_id"`
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Read bool `json:"read"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
NotificationID_2 uuid.UUID `json:"notification_id_2"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
ActionType string `json:"action_type"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetAllNotificationsForUserID(ctx context.Context, userID uuid.UUID) ([]GetAllNotificationsForUserIDRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllNotificationsForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetAllNotificationsForUserIDRow
|
||||
for rows.Next() {
|
||||
var i GetAllNotificationsForUserIDRow
|
||||
if err := rows.Scan(
|
||||
&i.NotifiedID,
|
||||
&i.NotificationID,
|
||||
&i.UserID,
|
||||
&i.Read,
|
||||
&i.ReadAt,
|
||||
&i.NotificationID_2,
|
||||
&i.CausedBy,
|
||||
&i.ActionType,
|
||||
&i.Data,
|
||||
&i.CreatedOn,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getNotificationByID = `-- name: GetNotificationByID :one
|
||||
SELECT notification_id, caused_by, action_type, data, created_on FROM notification WHERE notification_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetNotificationByID(ctx context.Context, notificationID uuid.UUID) (Notification, error) {
|
||||
row := q.db.QueryRowContext(ctx, getNotificationByID, notificationID)
|
||||
var i Notification
|
||||
err := row.Scan(
|
||||
&i.NotificationID,
|
||||
&i.CausedBy,
|
||||
&i.ActionType,
|
||||
&i.Data,
|
||||
&i.CreatedOn,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getNotificationsForUserIDCursor = `-- name: GetNotificationsForUserIDCursor :many
|
||||
SELECT n.notification_id, n.caused_by, n.action_type, n.data, n.created_on, nn.notified_id, nn.notification_id, nn.user_id, nn.read, nn.read_at FROM notification_notified AS nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE (n.created_on, n.notification_id) < ($1::timestamptz, $2::uuid)
|
||||
AND nn.user_id = $3::uuid
|
||||
AND ($4::boolean = false OR nn.read = false)
|
||||
AND ($5::boolean = false OR n.action_type = ANY($6::text[]))
|
||||
ORDER BY n.created_on DESC
|
||||
LIMIT $7::int
|
||||
`
|
||||
|
||||
type GetNotificationsForUserIDCursorParams struct {
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
EnableUnread bool `json:"enable_unread"`
|
||||
EnableActionType bool `json:"enable_action_type"`
|
||||
ActionType []string `json:"action_type"`
|
||||
LimitRows int32 `json:"limit_rows"`
|
||||
}
|
||||
|
||||
type GetNotificationsForUserIDCursorRow struct {
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
ActionType string `json:"action_type"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
NotifiedID uuid.UUID `json:"notified_id"`
|
||||
NotificationID_2 uuid.UUID `json:"notification_id_2"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Read bool `json:"read"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetNotificationsForUserIDCursor(ctx context.Context, arg GetNotificationsForUserIDCursorParams) ([]GetNotificationsForUserIDCursorRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getNotificationsForUserIDCursor,
|
||||
arg.CreatedOn,
|
||||
arg.NotificationID,
|
||||
arg.UserID,
|
||||
arg.EnableUnread,
|
||||
arg.EnableActionType,
|
||||
pq.Array(arg.ActionType),
|
||||
arg.LimitRows,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetNotificationsForUserIDCursorRow
|
||||
for rows.Next() {
|
||||
var i GetNotificationsForUserIDCursorRow
|
||||
if err := rows.Scan(
|
||||
&i.NotificationID,
|
||||
&i.CausedBy,
|
||||
&i.ActionType,
|
||||
&i.Data,
|
||||
&i.CreatedOn,
|
||||
&i.NotifiedID,
|
||||
&i.NotificationID_2,
|
||||
&i.UserID,
|
||||
&i.Read,
|
||||
&i.ReadAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getNotificationsForUserIDPaged = `-- name: GetNotificationsForUserIDPaged :many
|
||||
SELECT n.notification_id, n.caused_by, n.action_type, n.data, n.created_on, nn.notified_id, nn.notification_id, nn.user_id, nn.read, nn.read_at FROM notification_notified AS nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE nn.user_id = $1::uuid
|
||||
AND ($2::boolean = false OR nn.read = false)
|
||||
AND ($3::boolean = false OR n.action_type = ANY($4::text[]))
|
||||
ORDER BY n.created_on DESC
|
||||
LIMIT $5::int
|
||||
`
|
||||
|
||||
type GetNotificationsForUserIDPagedParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
EnableUnread bool `json:"enable_unread"`
|
||||
EnableActionType bool `json:"enable_action_type"`
|
||||
ActionType []string `json:"action_type"`
|
||||
LimitRows int32 `json:"limit_rows"`
|
||||
}
|
||||
|
||||
type GetNotificationsForUserIDPagedRow struct {
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
ActionType string `json:"action_type"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
NotifiedID uuid.UUID `json:"notified_id"`
|
||||
NotificationID_2 uuid.UUID `json:"notification_id_2"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Read bool `json:"read"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetNotificationsForUserIDPaged(ctx context.Context, arg GetNotificationsForUserIDPagedParams) ([]GetNotificationsForUserIDPagedRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getNotificationsForUserIDPaged,
|
||||
arg.UserID,
|
||||
arg.EnableUnread,
|
||||
arg.EnableActionType,
|
||||
pq.Array(arg.ActionType),
|
||||
arg.LimitRows,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetNotificationsForUserIDPagedRow
|
||||
for rows.Next() {
|
||||
var i GetNotificationsForUserIDPagedRow
|
||||
if err := rows.Scan(
|
||||
&i.NotificationID,
|
||||
&i.CausedBy,
|
||||
&i.ActionType,
|
||||
&i.Data,
|
||||
&i.CreatedOn,
|
||||
&i.NotifiedID,
|
||||
&i.NotificationID_2,
|
||||
&i.UserID,
|
||||
&i.Read,
|
||||
&i.ReadAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getNotifiedByID = `-- name: GetNotifiedByID :one
|
||||
SELECT notified_id, nn.notification_id, user_id, read, read_at, n.notification_id, caused_by, action_type, data, created_on FROM notification_notified as nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE notified_id = $1
|
||||
`
|
||||
|
||||
type GetNotifiedByIDRow struct {
|
||||
NotifiedID uuid.UUID `json:"notified_id"`
|
||||
NotificationID uuid.UUID `json:"notification_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Read bool `json:"read"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
NotificationID_2 uuid.UUID `json:"notification_id_2"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
ActionType string `json:"action_type"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
CreatedOn time.Time `json:"created_on"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetNotifiedByID(ctx context.Context, notifiedID uuid.UUID) (GetNotifiedByIDRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getNotifiedByID, notifiedID)
|
||||
var i GetNotifiedByIDRow
|
||||
err := row.Scan(
|
||||
&i.NotifiedID,
|
||||
&i.NotificationID,
|
||||
&i.UserID,
|
||||
&i.Read,
|
||||
&i.ReadAt,
|
||||
&i.NotificationID_2,
|
||||
&i.CausedBy,
|
||||
&i.ActionType,
|
||||
&i.Data,
|
||||
&i.CreatedOn,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getNotifiedByIDNoExtra = `-- name: GetNotifiedByIDNoExtra :one
|
||||
SELECT notified_id, notification_id, user_id, read, read_at FROM notification_notified as nn WHERE nn.notified_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetNotifiedByIDNoExtra(ctx context.Context, notifiedID uuid.UUID) (NotificationNotified, error) {
|
||||
row := q.db.QueryRowContext(ctx, getNotifiedByIDNoExtra, notifiedID)
|
||||
var i NotificationNotified
|
||||
err := row.Scan(
|
||||
&i.NotifiedID,
|
||||
&i.NotificationID,
|
||||
&i.UserID,
|
||||
&i.Read,
|
||||
&i.ReadAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const hasUnreadNotification = `-- name: HasUnreadNotification :one
|
||||
SELECT EXISTS (SELECT 1 FROM notification_notified WHERE read = false AND user_id = $1)
|
||||
`
|
||||
|
||||
func (q *Queries) HasUnreadNotification(ctx context.Context, userID uuid.UUID) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, hasUnreadNotification, userID)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const markAllNotificationsRead = `-- name: MarkAllNotificationsRead :exec
|
||||
UPDATE notification_notified SET read = true, read_at = $2 WHERE user_id = $1
|
||||
`
|
||||
|
||||
type MarkAllNotificationsReadParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) MarkAllNotificationsRead(ctx context.Context, arg MarkAllNotificationsReadParams) error {
|
||||
_, err := q.db.ExecContext(ctx, markAllNotificationsRead, arg.UserID, arg.ReadAt)
|
||||
return err
|
||||
}
|
||||
|
||||
const markNotificationAsRead = `-- name: MarkNotificationAsRead :exec
|
||||
UPDATE notification_notified SET read = $3, read_at = $2 WHERE user_id = $1 AND notified_id = $4
|
||||
`
|
||||
|
||||
type MarkNotificationAsReadParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ReadAt sql.NullTime `json:"read_at"`
|
||||
Read bool `json:"read"`
|
||||
NotifiedID uuid.UUID `json:"notified_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) MarkNotificationAsRead(ctx context.Context, arg MarkNotificationAsReadParams) error {
|
||||
_, err := q.db.ExecContext(ctx, markNotificationAsRead,
|
||||
arg.UserID,
|
||||
arg.ReadAt,
|
||||
arg.Read,
|
||||
arg.NotifiedID,
|
||||
)
|
||||
return err
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: organization.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const createOrganization = `-- name: CreateOrganization :one
|
||||
INSERT INTO organization (created_at, name) VALUES ($1, $2) RETURNING organization_id, created_at, name
|
||||
`
|
||||
|
||||
type CreateOrganizationParams struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error) {
|
||||
row := q.db.QueryRowContext(ctx, createOrganization, arg.CreatedAt, arg.Name)
|
||||
var i Organization
|
||||
err := row.Scan(&i.OrganizationID, &i.CreatedAt, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAllOrganizations = `-- name: GetAllOrganizations :many
|
||||
SELECT organization_id, created_at, name FROM organization
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllOrganizations(ctx context.Context) ([]Organization, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllOrganizations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Organization
|
||||
for rows.Next() {
|
||||
var i Organization
|
||||
if err := rows.Scan(&i.OrganizationID, &i.CreatedAt, &i.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
@ -1,577 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: project.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createPersonalProject = `-- name: CreatePersonalProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES (null, $1, $2) RETURNING project_id, team_id, created_at, name, public_on, short_id
|
||||
`
|
||||
|
||||
type CreatePersonalProjectParams struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreatePersonalProject(ctx context.Context, arg CreatePersonalProjectParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, createPersonalProject, arg.CreatedAt, arg.Name)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createPersonalProjectLink = `-- name: CreatePersonalProjectLink :one
|
||||
INSERT INTO personal_project (project_id, user_id) VALUES ($1, $2) RETURNING personal_project_id, project_id, user_id
|
||||
`
|
||||
|
||||
type CreatePersonalProjectLinkParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreatePersonalProjectLink(ctx context.Context, arg CreatePersonalProjectLinkParams) (PersonalProject, error) {
|
||||
row := q.db.QueryRowContext(ctx, createPersonalProjectLink, arg.ProjectID, arg.UserID)
|
||||
var i PersonalProject
|
||||
err := row.Scan(&i.PersonalProjectID, &i.ProjectID, &i.UserID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createProjectMember = `-- name: CreateProjectMember :one
|
||||
INSERT INTO project_member (project_id, user_id, role_code, added_at) VALUES ($1, $2, $3, $4)
|
||||
RETURNING project_member_id, project_id, user_id, added_at, role_code
|
||||
`
|
||||
|
||||
type CreateProjectMemberParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
AddedAt time.Time `json:"added_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateProjectMember(ctx context.Context, arg CreateProjectMemberParams) (ProjectMember, error) {
|
||||
row := q.db.QueryRowContext(ctx, createProjectMember,
|
||||
arg.ProjectID,
|
||||
arg.UserID,
|
||||
arg.RoleCode,
|
||||
arg.AddedAt,
|
||||
)
|
||||
var i ProjectMember
|
||||
err := row.Scan(
|
||||
&i.ProjectMemberID,
|
||||
&i.ProjectID,
|
||||
&i.UserID,
|
||||
&i.AddedAt,
|
||||
&i.RoleCode,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createTeamProject = `-- name: CreateTeamProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES ($1, $2, $3) RETURNING project_id, team_id, created_at, name, public_on, short_id
|
||||
`
|
||||
|
||||
type CreateTeamProjectParams struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTeamProject(ctx context.Context, arg CreateTeamProjectParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTeamProject, arg.TeamID, arg.CreatedAt, arg.Name)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteInvitedProjectMemberByID = `-- name: DeleteInvitedProjectMemberByID :exec
|
||||
DELETE FROM project_member_invited WHERE project_member_invited_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteInvitedProjectMemberByID(ctx context.Context, projectMemberInvitedID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteInvitedProjectMemberByID, projectMemberInvitedID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteProjectByID = `-- name: DeleteProjectByID :exec
|
||||
DELETE FROM project WHERE project_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteProjectByID(ctx context.Context, projectID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteProjectByID, projectID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteProjectMember = `-- name: DeleteProjectMember :exec
|
||||
DELETE FROM project_member WHERE user_id = $1 AND project_id = $2
|
||||
`
|
||||
|
||||
type DeleteProjectMemberParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteProjectMember(ctx context.Context, arg DeleteProjectMemberParams) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteProjectMember, arg.UserID, arg.ProjectID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllProjectsForTeam = `-- name: GetAllProjectsForTeam :many
|
||||
SELECT project_id, team_id, created_at, name, public_on, short_id FROM project WHERE team_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllProjectsForTeam, teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Project
|
||||
for rows.Next() {
|
||||
var i Project
|
||||
if err := rows.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAllTeamProjects = `-- name: GetAllTeamProjects :many
|
||||
SELECT project_id, team_id, created_at, name, public_on, short_id FROM project WHERE team_id IS NOT null
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllTeamProjects(ctx context.Context) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllTeamProjects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Project
|
||||
for rows.Next() {
|
||||
var i Project
|
||||
if err := rows.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAllVisibleProjectsForUserID = `-- name: GetAllVisibleProjectsForUserID :many
|
||||
SELECT project.project_id, project.team_id, project.created_at, project.name, project.public_on, project.short_id FROM project LEFT JOIN
|
||||
project_member ON project_member.project_id = project.project_id WHERE project_member.user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllVisibleProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllVisibleProjectsForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Project
|
||||
for rows.Next() {
|
||||
var i Project
|
||||
if err := rows.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getInvitedMembersForProjectID = `-- name: GetInvitedMembersForProjectID :many
|
||||
SELECT uai.user_account_invited_id, email, invited_on FROM project_member_invited AS pmi
|
||||
INNER JOIN user_account_invited AS uai
|
||||
ON uai.user_account_invited_id = pmi.user_account_invited_id
|
||||
WHERE project_id = $1
|
||||
`
|
||||
|
||||
type GetInvitedMembersForProjectIDRow struct {
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invited_on"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetInvitedMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]GetInvitedMembersForProjectIDRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getInvitedMembersForProjectID, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetInvitedMembersForProjectIDRow
|
||||
for rows.Next() {
|
||||
var i GetInvitedMembersForProjectIDRow
|
||||
if err := rows.Scan(&i.UserAccountInvitedID, &i.Email, &i.InvitedOn); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getMemberProjectIDsForUserID = `-- name: GetMemberProjectIDsForUserID :many
|
||||
SELECT project_id FROM project_member WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetMemberProjectIDsForUserID(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getMemberProjectIDsForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []uuid.UUID
|
||||
for rows.Next() {
|
||||
var project_id uuid.UUID
|
||||
if err := rows.Scan(&project_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, project_id)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getPersonalProjectsForUserID = `-- name: GetPersonalProjectsForUserID :many
|
||||
SELECT project.project_id, project.team_id, project.created_at, project.name, project.public_on, project.short_id FROM project
|
||||
LEFT JOIN personal_project ON personal_project.project_id = project.project_id
|
||||
WHERE personal_project.user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetPersonalProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getPersonalProjectsForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Project
|
||||
for rows.Next() {
|
||||
var i Project
|
||||
if err := rows.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectByID = `-- name: GetProjectByID :one
|
||||
SELECT project_id, team_id, created_at, name, public_on, short_id FROM project WHERE project_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectByID, projectID)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProjectIDByShortID = `-- name: GetProjectIDByShortID :one
|
||||
SELECT project_id FROM project WHERE short_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDByShortID(ctx context.Context, shortID string) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDByShortID, shortID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getProjectMemberInvitedIDByEmail = `-- name: GetProjectMemberInvitedIDByEmail :one
|
||||
SELECT email, invited_on, project_member_invited_id FROM user_account_invited AS uai
|
||||
inner join project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE email = $1
|
||||
`
|
||||
|
||||
type GetProjectMemberInvitedIDByEmailRow struct {
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invited_on"`
|
||||
ProjectMemberInvitedID uuid.UUID `json:"project_member_invited_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetProjectMemberInvitedIDByEmail(ctx context.Context, email string) (GetProjectMemberInvitedIDByEmailRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectMemberInvitedIDByEmail, email)
|
||||
var i GetProjectMemberInvitedIDByEmailRow
|
||||
err := row.Scan(&i.Email, &i.InvitedOn, &i.ProjectMemberInvitedID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProjectMembersForProjectID = `-- name: GetProjectMembersForProjectID :many
|
||||
SELECT project_member_id, project_id, user_id, added_at, role_code FROM project_member WHERE project_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectMember, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getProjectMembersForProjectID, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ProjectMember
|
||||
for rows.Next() {
|
||||
var i ProjectMember
|
||||
if err := rows.Scan(
|
||||
&i.ProjectMemberID,
|
||||
&i.ProjectID,
|
||||
&i.UserID,
|
||||
&i.AddedAt,
|
||||
&i.RoleCode,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectRolesForUserID = `-- name: GetProjectRolesForUserID :many
|
||||
SELECT project_id, role_code FROM project_member WHERE user_id = $1
|
||||
`
|
||||
|
||||
type GetProjectRolesForUserIDRow struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetProjectRolesForUserID(ctx context.Context, userID uuid.UUID) ([]GetProjectRolesForUserIDRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getProjectRolesForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetProjectRolesForUserIDRow
|
||||
for rows.Next() {
|
||||
var i GetProjectRolesForUserIDRow
|
||||
if err := rows.Scan(&i.ProjectID, &i.RoleCode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getPublicOn = `-- name: GetPublicOn :one
|
||||
SELECT public_on FROM project WHERE project_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetPublicOn(ctx context.Context, projectID uuid.UUID) (sql.NullTime, error) {
|
||||
row := q.db.QueryRowContext(ctx, getPublicOn, projectID)
|
||||
var public_on sql.NullTime
|
||||
err := row.Scan(&public_on)
|
||||
return public_on, err
|
||||
}
|
||||
|
||||
const getRoleForProjectMemberByUserID = `-- name: GetRoleForProjectMemberByUserID :one
|
||||
SELECT code, role.name FROM project_member INNER JOIN role ON role.code = project_member.role_code
|
||||
WHERE user_id = $1 AND project_id = $2
|
||||
`
|
||||
|
||||
type GetRoleForProjectMemberByUserIDParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetRoleForProjectMemberByUserID(ctx context.Context, arg GetRoleForProjectMemberByUserIDParams) (Role, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRoleForProjectMemberByUserID, arg.UserID, arg.ProjectID)
|
||||
var i Role
|
||||
err := row.Scan(&i.Code, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserRolesForProject = `-- name: GetUserRolesForProject :one
|
||||
SELECT p.team_id, COALESCE(tm.role_code, '') AS team_role, COALESCE(pm.role_code, '') AS project_role
|
||||
FROM project AS p
|
||||
LEFT JOIN project_member AS pm ON pm.project_id = p.project_id AND pm.user_id = $1
|
||||
LEFT JOIN team_member AS tm ON tm.team_id = p.team_id AND tm.user_id = $1
|
||||
WHERE p.project_id = $2
|
||||
`
|
||||
|
||||
type GetUserRolesForProjectParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
}
|
||||
|
||||
type GetUserRolesForProjectRow struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
TeamRole string `json:"team_role"`
|
||||
ProjectRole string `json:"project_role"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetUserRolesForProject(ctx context.Context, arg GetUserRolesForProjectParams) (GetUserRolesForProjectRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserRolesForProject, arg.UserID, arg.ProjectID)
|
||||
var i GetUserRolesForProjectRow
|
||||
err := row.Scan(&i.TeamID, &i.TeamRole, &i.ProjectRole)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const setPublicOn = `-- name: SetPublicOn :one
|
||||
UPDATE project SET public_on = $2 WHERE project_id = $1 RETURNING project_id, team_id, created_at, name, public_on, short_id
|
||||
`
|
||||
|
||||
type SetPublicOnParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
PublicOn sql.NullTime `json:"public_on"`
|
||||
}
|
||||
|
||||
func (q *Queries) SetPublicOn(ctx context.Context, arg SetPublicOnParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, setPublicOn, arg.ProjectID, arg.PublicOn)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateProjectMemberRole = `-- name: UpdateProjectMemberRole :one
|
||||
UPDATE project_member SET role_code = $3 WHERE project_id = $1 AND user_id = $2
|
||||
RETURNING project_member_id, project_id, user_id, added_at, role_code
|
||||
`
|
||||
|
||||
type UpdateProjectMemberRoleParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProjectMemberRole(ctx context.Context, arg UpdateProjectMemberRoleParams) (ProjectMember, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateProjectMemberRole, arg.ProjectID, arg.UserID, arg.RoleCode)
|
||||
var i ProjectMember
|
||||
err := row.Scan(
|
||||
&i.ProjectMemberID,
|
||||
&i.ProjectID,
|
||||
&i.UserID,
|
||||
&i.AddedAt,
|
||||
&i.RoleCode,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateProjectNameByID = `-- name: UpdateProjectNameByID :one
|
||||
UPDATE project SET name = $2 WHERE project_id = $1 RETURNING project_id, team_id, created_at, name, public_on, short_id
|
||||
`
|
||||
|
||||
type UpdateProjectNameByIDParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProjectNameByID(ctx context.Context, arg UpdateProjectNameByIDParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateProjectNameByID, arg.ProjectID, arg.Name)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.PublicOn,
|
||||
&i.ShortID,
|
||||
)
|
||||
return i, err
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: project_label.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createProjectLabel = `-- name: CreateProjectLabel :one
|
||||
INSERT INTO project_label (project_id, label_color_id, created_date, name)
|
||||
VALUES ($1, $2, $3, $4) RETURNING project_label_id, project_id, label_color_id, created_date, name
|
||||
`
|
||||
|
||||
type CreateProjectLabelParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
LabelColorID uuid.UUID `json:"label_color_id"`
|
||||
CreatedDate time.Time `json:"created_date"`
|
||||
Name sql.NullString `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateProjectLabel(ctx context.Context, arg CreateProjectLabelParams) (ProjectLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, createProjectLabel,
|
||||
arg.ProjectID,
|
||||
arg.LabelColorID,
|
||||
arg.CreatedDate,
|
||||
arg.Name,
|
||||
)
|
||||
var i ProjectLabel
|
||||
err := row.Scan(
|
||||
&i.ProjectLabelID,
|
||||
&i.ProjectID,
|
||||
&i.LabelColorID,
|
||||
&i.CreatedDate,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteProjectLabelByID = `-- name: DeleteProjectLabelByID :exec
|
||||
DELETE FROM project_label WHERE project_label_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteProjectLabelByID, projectLabelID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getProjectLabelByID = `-- name: GetProjectLabelByID :one
|
||||
SELECT project_label_id, project_id, label_color_id, created_date, name FROM project_label WHERE project_label_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectLabelByID, projectLabelID)
|
||||
var i ProjectLabel
|
||||
err := row.Scan(
|
||||
&i.ProjectLabelID,
|
||||
&i.ProjectID,
|
||||
&i.LabelColorID,
|
||||
&i.CreatedDate,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProjectLabelsForProject = `-- name: GetProjectLabelsForProject :many
|
||||
SELECT project_label_id, project_id, label_color_id, created_date, name FROM project_label WHERE project_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectLabelsForProject(ctx context.Context, projectID uuid.UUID) ([]ProjectLabel, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getProjectLabelsForProject, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ProjectLabel
|
||||
for rows.Next() {
|
||||
var i ProjectLabel
|
||||
if err := rows.Scan(
|
||||
&i.ProjectLabelID,
|
||||
&i.ProjectID,
|
||||
&i.LabelColorID,
|
||||
&i.CreatedDate,
|
||||
&i.Name,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateProjectLabel = `-- name: UpdateProjectLabel :one
|
||||
UPDATE project_label SET name = $2, label_color_id = $3 WHERE project_label_id = $1 RETURNING project_label_id, project_id, label_color_id, created_date, name
|
||||
`
|
||||
|
||||
type UpdateProjectLabelParams struct {
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
Name sql.NullString `json:"name"`
|
||||
LabelColorID uuid.UUID `json:"label_color_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProjectLabel(ctx context.Context, arg UpdateProjectLabelParams) (ProjectLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateProjectLabel, arg.ProjectLabelID, arg.Name, arg.LabelColorID)
|
||||
var i ProjectLabel
|
||||
err := row.Scan(
|
||||
&i.ProjectLabelID,
|
||||
&i.ProjectID,
|
||||
&i.LabelColorID,
|
||||
&i.CreatedDate,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateProjectLabelColor = `-- name: UpdateProjectLabelColor :one
|
||||
UPDATE project_label SET label_color_id = $2 WHERE project_label_id = $1 RETURNING project_label_id, project_id, label_color_id, created_date, name
|
||||
`
|
||||
|
||||
type UpdateProjectLabelColorParams struct {
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
LabelColorID uuid.UUID `json:"label_color_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProjectLabelColor(ctx context.Context, arg UpdateProjectLabelColorParams) (ProjectLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateProjectLabelColor, arg.ProjectLabelID, arg.LabelColorID)
|
||||
var i ProjectLabel
|
||||
err := row.Scan(
|
||||
&i.ProjectLabelID,
|
||||
&i.ProjectID,
|
||||
&i.LabelColorID,
|
||||
&i.CreatedDate,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateProjectLabelName = `-- name: UpdateProjectLabelName :one
|
||||
UPDATE project_label SET name = $2 WHERE project_label_id = $1 RETURNING project_label_id, project_id, label_color_id, created_date, name
|
||||
`
|
||||
|
||||
type UpdateProjectLabelNameParams struct {
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
Name sql.NullString `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProjectLabelName(ctx context.Context, arg UpdateProjectLabelNameParams) (ProjectLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateProjectLabelName, arg.ProjectLabelID, arg.Name)
|
||||
var i ProjectLabel
|
||||
err := row.Scan(
|
||||
&i.ProjectLabelID,
|
||||
&i.ProjectID,
|
||||
&i.LabelColorID,
|
||||
&i.CreatedDate,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
@ -4,185 +4,19 @@ package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
CreateAuthToken(ctx context.Context, arg CreateAuthTokenParams) (AuthToken, error)
|
||||
CreateConfirmToken(ctx context.Context, email string) (UserAccountConfirmToken, error)
|
||||
CreateDueDateReminder(ctx context.Context, arg CreateDueDateReminderParams) (TaskDueDateReminder, error)
|
||||
CreateInvitedProjectMember(ctx context.Context, arg CreateInvitedProjectMemberParams) (ProjectMemberInvited, error)
|
||||
CreateInvitedUser(ctx context.Context, email string) (UserAccountInvited, error)
|
||||
CreateLabelColor(ctx context.Context, arg CreateLabelColorParams) (LabelColor, error)
|
||||
CreateNotification(ctx context.Context, arg CreateNotificationParams) (Notification, error)
|
||||
CreateNotificationNotifed(ctx context.Context, arg CreateNotificationNotifedParams) (NotificationNotified, error)
|
||||
CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error)
|
||||
CreatePersonalProject(ctx context.Context, arg CreatePersonalProjectParams) (Project, error)
|
||||
CreatePersonalProjectLink(ctx context.Context, arg CreatePersonalProjectLinkParams) (PersonalProject, error)
|
||||
CreateProjectLabel(ctx context.Context, arg CreateProjectLabelParams) (ProjectLabel, error)
|
||||
CreateProjectMember(ctx context.Context, arg CreateProjectMemberParams) (ProjectMember, error)
|
||||
CreateSystemOption(ctx context.Context, arg CreateSystemOptionParams) (SystemOption, error)
|
||||
CreateTask(ctx context.Context, arg CreateTaskParams) (Task, error)
|
||||
CreateTaskActivity(ctx context.Context, arg CreateTaskActivityParams) (TaskActivity, 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)
|
||||
CreateTaskComment(ctx context.Context, arg CreateTaskCommentParams) (TaskComment, error)
|
||||
CreateTaskGroup(ctx context.Context, arg CreateTaskGroupParams) (TaskGroup, error)
|
||||
CreateTaskLabelForTask(ctx context.Context, arg CreateTaskLabelForTaskParams) (TaskLabel, error)
|
||||
CreateTaskWatcher(ctx context.Context, arg CreateTaskWatcherParams) (TaskWatcher, error)
|
||||
CreateTeam(ctx context.Context, arg CreateTeamParams) (Team, error)
|
||||
CreateTeamMember(ctx context.Context, arg CreateTeamMemberParams) (TeamMember, error)
|
||||
CreateTeamProject(ctx context.Context, arg CreateTeamProjectParams) (Project, error)
|
||||
CreateAccessToken(ctx context.Context, arg CreateAccessTokenParams) (AccessToken, error)
|
||||
CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error)
|
||||
DeleteAuthTokenByID(ctx context.Context, tokenID uuid.UUID) error
|
||||
DeleteAuthTokenByUserID(ctx context.Context, userID uuid.UUID) error
|
||||
DeleteConfirmTokenForEmail(ctx context.Context, email string) error
|
||||
DeleteDueDateReminder(ctx context.Context, dueDateReminderID uuid.UUID) error
|
||||
DeleteExpiredTokens(ctx context.Context) error
|
||||
DeleteInvitedProjectMemberByID(ctx context.Context, projectMemberInvitedID uuid.UUID) error
|
||||
DeleteInvitedUserAccount(ctx context.Context, userAccountInvitedID uuid.UUID) (UserAccountInvited, error)
|
||||
DeleteProjectByID(ctx context.Context, projectID uuid.UUID) error
|
||||
DeleteProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) error
|
||||
DeleteProjectMember(ctx context.Context, arg DeleteProjectMemberParams) error
|
||||
DeleteProjectMemberInvitedForEmail(ctx context.Context, email string) error
|
||||
DeleteTaskAssignedByID(ctx context.Context, arg DeleteTaskAssignedByIDParams) (TaskAssigned, error)
|
||||
DeleteTaskByID(ctx context.Context, taskID uuid.UUID) error
|
||||
DeleteTaskChecklistByID(ctx context.Context, taskChecklistID uuid.UUID) error
|
||||
DeleteTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) error
|
||||
DeleteTaskCommentByID(ctx context.Context, taskCommentID uuid.UUID) (TaskComment, error)
|
||||
DeleteTaskGroupByID(ctx context.Context, taskGroupID uuid.UUID) (int64, error)
|
||||
DeleteTaskLabelByID(ctx context.Context, taskLabelID uuid.UUID) error
|
||||
DeleteTaskLabelForTaskByProjectLabelID(ctx context.Context, arg DeleteTaskLabelForTaskByProjectLabelIDParams) error
|
||||
DeleteTaskWatcher(ctx context.Context, arg DeleteTaskWatcherParams) error
|
||||
DeleteTasksByTaskGroupID(ctx context.Context, taskGroupID uuid.UUID) (int64, error)
|
||||
DeleteTeamByID(ctx context.Context, teamID uuid.UUID) error
|
||||
DeleteTeamMember(ctx context.Context, arg DeleteTeamMemberParams) error
|
||||
DeleteUserAccountByID(ctx context.Context, userID uuid.UUID) error
|
||||
DeleteUserAccountInvitedForEmail(ctx context.Context, email string) error
|
||||
DoesUserExist(ctx context.Context, arg DoesUserExistParams) (bool, error)
|
||||
GetActivityForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskActivity, error)
|
||||
GetAllNotificationsForUserID(ctx context.Context, userID uuid.UUID) ([]GetAllNotificationsForUserIDRow, error)
|
||||
GetAllOrganizations(ctx context.Context) ([]Organization, error)
|
||||
GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error)
|
||||
GetAllTaskGroups(ctx context.Context) ([]TaskGroup, error)
|
||||
GetAllTasks(ctx context.Context) ([]Task, error)
|
||||
GetAllTeamProjects(ctx context.Context) ([]Project, error)
|
||||
GetAllTeams(ctx context.Context) ([]Team, error)
|
||||
GetAllUserAccounts(ctx context.Context) ([]UserAccount, error)
|
||||
GetAllVisibleProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error)
|
||||
GetAssignedMembersForTask(ctx context.Context, taskID uuid.UUID) ([]TaskAssigned, error)
|
||||
GetAssignedTasksDueDateForUserID(ctx context.Context, arg GetAssignedTasksDueDateForUserIDParams) ([]Task, error)
|
||||
GetAssignedTasksProjectForUserID(ctx context.Context, arg GetAssignedTasksProjectForUserIDParams) ([]Task, error)
|
||||
GetAuthTokenByID(ctx context.Context, tokenID uuid.UUID) (AuthToken, error)
|
||||
GetCommentCountForTask(ctx context.Context, taskID uuid.UUID) (int64, error)
|
||||
GetCommentsForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskComment, error)
|
||||
GetConfirmTokenByEmail(ctx context.Context, email string) (UserAccountConfirmToken, error)
|
||||
GetConfirmTokenByID(ctx context.Context, confirmTokenID uuid.UUID) (UserAccountConfirmToken, error)
|
||||
GetDueDateReminderByID(ctx context.Context, dueDateReminderID uuid.UUID) (TaskDueDateReminder, error)
|
||||
GetDueDateRemindersForDuration(ctx context.Context, startAt time.Time) ([]TaskDueDateReminder, error)
|
||||
GetDueDateRemindersForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskDueDateReminder, error)
|
||||
GetInvitedMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]GetInvitedMembersForProjectIDRow, error)
|
||||
GetInvitedUserAccounts(ctx context.Context) ([]UserAccountInvited, error)
|
||||
GetInvitedUserByEmail(ctx context.Context, email string) (UserAccountInvited, error)
|
||||
GetLabelColorByID(ctx context.Context, labelColorID uuid.UUID) (LabelColor, error)
|
||||
GetLabelColors(ctx context.Context) ([]LabelColor, error)
|
||||
GetLastMoveForTaskID(ctx context.Context, taskID uuid.UUID) (GetLastMoveForTaskIDRow, error)
|
||||
GetMemberData(ctx context.Context, projectID uuid.UUID) ([]UserAccount, error)
|
||||
GetMemberProjectIDsForUserID(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error)
|
||||
GetMemberTeamIDsForUserID(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error)
|
||||
GetNotificationByID(ctx context.Context, notificationID uuid.UUID) (Notification, error)
|
||||
GetNotificationsForUserIDCursor(ctx context.Context, arg GetNotificationsForUserIDCursorParams) ([]GetNotificationsForUserIDCursorRow, error)
|
||||
GetNotificationsForUserIDPaged(ctx context.Context, arg GetNotificationsForUserIDPagedParams) ([]GetNotificationsForUserIDPagedRow, error)
|
||||
GetNotifiedByID(ctx context.Context, notifiedID uuid.UUID) (GetNotifiedByIDRow, error)
|
||||
GetNotifiedByIDNoExtra(ctx context.Context, notifiedID uuid.UUID) (NotificationNotified, error)
|
||||
GetPersonalProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error)
|
||||
GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error)
|
||||
GetProjectIDByShortID(ctx context.Context, shortID string) (uuid.UUID, error)
|
||||
GetProjectIDForTask(ctx context.Context, taskID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIDForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIDForTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIDForTaskGroup(ctx context.Context, taskGroupID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIdMappings(ctx context.Context, dollar_1 []uuid.UUID) ([]GetProjectIdMappingsRow, error)
|
||||
GetProjectInfoForTask(ctx context.Context, taskID uuid.UUID) (GetProjectInfoForTaskRow, error)
|
||||
GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error)
|
||||
GetProjectLabelsForProject(ctx context.Context, projectID uuid.UUID) ([]ProjectLabel, error)
|
||||
GetProjectMemberInvitedIDByEmail(ctx context.Context, email string) (GetProjectMemberInvitedIDByEmailRow, error)
|
||||
GetProjectMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectMember, error)
|
||||
GetProjectRolesForUserID(ctx context.Context, userID uuid.UUID) ([]GetProjectRolesForUserIDRow, error)
|
||||
GetProjectsForInvitedMember(ctx context.Context, email string) ([]uuid.UUID, error)
|
||||
GetPublicOn(ctx context.Context, projectID uuid.UUID) (sql.NullTime, error)
|
||||
GetRecentlyAssignedTaskForUserID(ctx context.Context, arg GetRecentlyAssignedTaskForUserIDParams) ([]Task, error)
|
||||
GetRoleForProjectMemberByUserID(ctx context.Context, arg GetRoleForProjectMemberByUserIDParams) (Role, error)
|
||||
GetRoleForTeamMember(ctx context.Context, arg GetRoleForTeamMemberParams) (Role, error)
|
||||
GetRoleForUserID(ctx context.Context, userID uuid.UUID) (GetRoleForUserIDRow, error)
|
||||
GetSystemOptionByKey(ctx context.Context, key string) (GetSystemOptionByKeyRow, error)
|
||||
GetTaskByID(ctx context.Context, taskID uuid.UUID) (Task, error)
|
||||
GetTaskChecklistByID(ctx context.Context, taskChecklistID uuid.UUID) (TaskChecklist, error)
|
||||
GetTaskChecklistItemByID(ctx context.Context, taskChecklistItemID uuid.UUID) (TaskChecklistItem, error)
|
||||
GetTaskChecklistItemsForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) ([]TaskChecklistItem, error)
|
||||
GetTaskChecklistsForTask(ctx context.Context, taskID uuid.UUID) ([]TaskChecklist, error)
|
||||
GetTaskForDueDateReminder(ctx context.Context, dueDateReminderID uuid.UUID) (Task, error)
|
||||
GetTaskGroupByID(ctx context.Context, taskGroupID uuid.UUID) (TaskGroup, error)
|
||||
GetTaskGroupsForProject(ctx context.Context, projectID uuid.UUID) ([]TaskGroup, error)
|
||||
GetTaskIDByShortID(ctx context.Context, shortID string) (uuid.UUID, error)
|
||||
GetTaskLabelByID(ctx context.Context, taskLabelID uuid.UUID) (TaskLabel, error)
|
||||
GetTaskLabelForTaskByProjectLabelID(ctx context.Context, arg GetTaskLabelForTaskByProjectLabelIDParams) (TaskLabel, error)
|
||||
GetTaskLabelsForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskLabel, error)
|
||||
GetTaskWatcher(ctx context.Context, arg GetTaskWatcherParams) (TaskWatcher, error)
|
||||
GetTaskWatchersForTask(ctx context.Context, taskID uuid.UUID) ([]TaskWatcher, error)
|
||||
GetTasksForTaskGroupID(ctx context.Context, taskGroupID uuid.UUID) ([]Task, error)
|
||||
GetTeamByID(ctx context.Context, teamID uuid.UUID) (Team, error)
|
||||
GetTeamMemberByID(ctx context.Context, arg GetTeamMemberByIDParams) (TeamMember, error)
|
||||
GetTeamMembersForTeamID(ctx context.Context, teamID uuid.UUID) ([]TeamMember, error)
|
||||
GetTeamRoleForUserID(ctx context.Context, arg GetTeamRoleForUserIDParams) (GetTeamRoleForUserIDRow, error)
|
||||
GetTeamRolesForUserID(ctx context.Context, userID uuid.UUID) ([]GetTeamRolesForUserIDRow, error)
|
||||
GetTeamsForOrganization(ctx context.Context, organizationID uuid.UUID) ([]Team, error)
|
||||
GetTeamsForUserIDWhereAdmin(ctx context.Context, userID uuid.UUID) ([]Team, error)
|
||||
GetTemplateForActivityID(ctx context.Context, taskActivityTypeID int32) (string, error)
|
||||
GetUserAccountByEmail(ctx context.Context, email string) (UserAccount, error)
|
||||
DeleteAccessToken(ctx context.Context, token string) error
|
||||
GetAccessToken(ctx context.Context, token string) (AccessToken, error)
|
||||
GetUserAccountByID(ctx context.Context, userID uuid.UUID) (UserAccount, error)
|
||||
GetUserAccountByUsername(ctx context.Context, username string) (UserAccount, error)
|
||||
GetUserRolesForProject(ctx context.Context, arg GetUserRolesForProjectParams) (GetUserRolesForProjectRow, error)
|
||||
HasActiveUser(ctx context.Context) (bool, error)
|
||||
HasAnyUser(ctx context.Context) (bool, error)
|
||||
HasUnreadNotification(ctx context.Context, userID uuid.UUID) (bool, error)
|
||||
MarkAllNotificationsRead(ctx context.Context, arg MarkAllNotificationsReadParams) error
|
||||
MarkNotificationAsRead(ctx context.Context, arg MarkNotificationAsReadParams) error
|
||||
SetFirstUserActive(ctx context.Context) (UserAccount, error)
|
||||
SetInactiveLastMoveForTaskID(ctx context.Context, taskID uuid.UUID) error
|
||||
SetPublicOn(ctx context.Context, arg SetPublicOnParams) (Project, error)
|
||||
SetTaskChecklistItemComplete(ctx context.Context, arg SetTaskChecklistItemCompleteParams) (TaskChecklistItem, error)
|
||||
SetTaskComplete(ctx context.Context, arg SetTaskCompleteParams) (Task, error)
|
||||
SetTaskGroupName(ctx context.Context, arg SetTaskGroupNameParams) (TaskGroup, error)
|
||||
SetUserActiveByEmail(ctx context.Context, email string) (UserAccount, error)
|
||||
SetUserPassword(ctx context.Context, arg SetUserPasswordParams) (UserAccount, error)
|
||||
UpdateDueDateReminder(ctx context.Context, arg UpdateDueDateReminderParams) (TaskDueDateReminder, error)
|
||||
UpdateDueDateReminderRemindAt(ctx context.Context, arg UpdateDueDateReminderRemindAtParams) (TaskDueDateReminder, error)
|
||||
UpdateProjectLabel(ctx context.Context, arg UpdateProjectLabelParams) (ProjectLabel, error)
|
||||
UpdateProjectLabelColor(ctx context.Context, arg UpdateProjectLabelColorParams) (ProjectLabel, error)
|
||||
UpdateProjectLabelName(ctx context.Context, arg UpdateProjectLabelNameParams) (ProjectLabel, error)
|
||||
UpdateProjectMemberRole(ctx context.Context, arg UpdateProjectMemberRoleParams) (ProjectMember, error)
|
||||
UpdateProjectNameByID(ctx context.Context, arg UpdateProjectNameByIDParams) (Project, error)
|
||||
UpdateTaskChecklistItemLocation(ctx context.Context, arg UpdateTaskChecklistItemLocationParams) (TaskChecklistItem, error)
|
||||
UpdateTaskChecklistItemName(ctx context.Context, arg UpdateTaskChecklistItemNameParams) (TaskChecklistItem, error)
|
||||
UpdateTaskChecklistName(ctx context.Context, arg UpdateTaskChecklistNameParams) (TaskChecklist, error)
|
||||
UpdateTaskChecklistPosition(ctx context.Context, arg UpdateTaskChecklistPositionParams) (TaskChecklist, error)
|
||||
UpdateTaskComment(ctx context.Context, arg UpdateTaskCommentParams) (TaskComment, error)
|
||||
UpdateTaskDescription(ctx context.Context, arg UpdateTaskDescriptionParams) (Task, error)
|
||||
UpdateTaskDueDate(ctx context.Context, arg UpdateTaskDueDateParams) (Task, error)
|
||||
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)
|
||||
UpdateUserAccountInfo(ctx context.Context, arg UpdateUserAccountInfoParams) (UserAccount, error)
|
||||
UpdateUserAccountProfileAvatarURL(ctx context.Context, arg UpdateUserAccountProfileAvatarURLParams) (UserAccount, error)
|
||||
UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) (UserAccount, error)
|
||||
GetUserAccounts(ctx context.Context) ([]UserAccount, error)
|
||||
HasAnyUserAccount(ctx context.Context) (bool, error)
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
|
@ -1,9 +0,0 @@
|
||||
-- name: GetLabelColorByID :one
|
||||
SELECT * FROM label_color WHERE label_color_id = $1;
|
||||
|
||||
-- name: GetLabelColors :many
|
||||
SELECT * FROM label_color;
|
||||
|
||||
-- name: CreateLabelColor :one
|
||||
INSERT INTO label_color (name, color_hex, position) VALUES ($1, $2, $3)
|
||||
RETURNING *;
|
@ -1,50 +0,0 @@
|
||||
-- name: GetAllNotificationsForUserID :many
|
||||
SELECT * FROM notification_notified AS nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE nn.user_id = $1;
|
||||
|
||||
-- name: GetNotifiedByID :one
|
||||
SELECT * FROM notification_notified as nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE notified_id = $1;
|
||||
|
||||
-- name: GetNotifiedByIDNoExtra :one
|
||||
SELECT * FROM notification_notified as nn WHERE nn.notified_id = $1;
|
||||
|
||||
-- name: HasUnreadNotification :one
|
||||
SELECT EXISTS (SELECT 1 FROM notification_notified WHERE read = false AND user_id = $1);
|
||||
|
||||
-- name: MarkNotificationAsRead :exec
|
||||
UPDATE notification_notified SET read = $3, read_at = $2 WHERE user_id = $1 AND notified_id = $4;
|
||||
|
||||
-- name: MarkAllNotificationsRead :exec
|
||||
UPDATE notification_notified SET read = true, read_at = $2 WHERE user_id = $1;
|
||||
|
||||
-- name: CreateNotification :one
|
||||
INSERT INTO notification (caused_by, data, action_type, created_on)
|
||||
VALUES ($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: CreateNotificationNotifed :one
|
||||
INSERT INTO notification_notified (notification_id, user_id) VALUES ($1, $2) RETURNING *;
|
||||
|
||||
-- name: GetNotificationByID :one
|
||||
SELECT * FROM notification WHERE notification_id = $1;
|
||||
|
||||
-- name: GetNotificationsForUserIDPaged :many
|
||||
SELECT n.*, nn.* FROM notification_notified AS nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE nn.user_id = @user_id::uuid
|
||||
AND (@enable_unread::boolean = false OR nn.read = false)
|
||||
AND (@enable_action_type::boolean = false OR n.action_type = ANY(@action_type::text[]))
|
||||
ORDER BY n.created_on DESC
|
||||
LIMIT @limit_rows::int;
|
||||
|
||||
-- name: GetNotificationsForUserIDCursor :many
|
||||
SELECT n.*, nn.* FROM notification_notified AS nn
|
||||
INNER JOIN notification AS n ON n.notification_id = nn.notification_id
|
||||
WHERE (n.created_on, n.notification_id) < (@created_on::timestamptz, @notification_id::uuid)
|
||||
AND nn.user_id = @user_id::uuid
|
||||
AND (@enable_unread::boolean = false OR nn.read = false)
|
||||
AND (@enable_action_type::boolean = false OR n.action_type = ANY(@action_type::text[]))
|
||||
ORDER BY n.created_on DESC
|
||||
LIMIT @limit_rows::int;
|
@ -1,5 +0,0 @@
|
||||
-- name: GetAllOrganizations :many
|
||||
SELECT * FROM organization;
|
||||
|
||||
-- name: CreateOrganization :one
|
||||
INSERT INTO organization (created_at, name) VALUES ($1, $2) RETURNING *;
|
@ -1,88 +0,0 @@
|
||||
-- name: GetAllTeamProjects :many
|
||||
SELECT * FROM project WHERE team_id IS NOT null;
|
||||
|
||||
-- name: GetProjectIDByShortID :one
|
||||
SELECT project_id FROM project WHERE short_id = $1;
|
||||
|
||||
-- name: GetAllProjectsForTeam :many
|
||||
SELECT * FROM project WHERE team_id = $1;
|
||||
|
||||
-- name: GetProjectByID :one
|
||||
SELECT * FROM project WHERE project_id = $1;
|
||||
|
||||
-- name: CreateTeamProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES ($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: CreatePersonalProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES (null, $1, $2) RETURNING *;
|
||||
|
||||
-- name: UpdateProjectNameByID :one
|
||||
UPDATE project SET name = $2 WHERE project_id = $1 RETURNING *;
|
||||
|
||||
-- name: DeleteProjectByID :exec
|
||||
DELETE FROM project WHERE project_id = $1;
|
||||
|
||||
-- name: GetProjectMembersForProjectID :many
|
||||
SELECT * FROM project_member WHERE project_id = $1;
|
||||
|
||||
-- name: GetRoleForProjectMemberByUserID :one
|
||||
SELECT code, role.name FROM project_member INNER JOIN role ON role.code = project_member.role_code
|
||||
WHERE user_id = $1 AND project_id = $2;
|
||||
|
||||
-- name: CreateProjectMember :one
|
||||
INSERT INTO project_member (project_id, user_id, role_code, added_at) VALUES ($1, $2, $3, $4)
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteProjectMember :exec
|
||||
DELETE FROM project_member WHERE user_id = $1 AND project_id = $2;
|
||||
|
||||
-- name: UpdateProjectMemberRole :one
|
||||
UPDATE project_member SET role_code = $3 WHERE project_id = $1 AND user_id = $2
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetProjectRolesForUserID :many
|
||||
SELECT project_id, role_code FROM project_member WHERE user_id = $1;
|
||||
|
||||
-- name: GetMemberProjectIDsForUserID :many
|
||||
SELECT project_id FROM project_member WHERE user_id = $1;
|
||||
|
||||
-- name: GetInvitedMembersForProjectID :many
|
||||
SELECT uai.user_account_invited_id, email, invited_on FROM project_member_invited AS pmi
|
||||
INNER JOIN user_account_invited AS uai
|
||||
ON uai.user_account_invited_id = pmi.user_account_invited_id
|
||||
WHERE project_id = $1;
|
||||
|
||||
-- name: GetProjectMemberInvitedIDByEmail :one
|
||||
SELECT email, invited_on, project_member_invited_id FROM user_account_invited AS uai
|
||||
inner join project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE email = $1;
|
||||
|
||||
-- name: DeleteInvitedProjectMemberByID :exec
|
||||
DELETE FROM project_member_invited WHERE project_member_invited_id = $1;
|
||||
|
||||
-- name: GetAllVisibleProjectsForUserID :many
|
||||
SELECT project.* FROM project LEFT JOIN
|
||||
project_member ON project_member.project_id = project.project_id WHERE project_member.user_id = $1;
|
||||
|
||||
-- name: GetPersonalProjectsForUserID :many
|
||||
SELECT project.* FROM project
|
||||
LEFT JOIN personal_project ON personal_project.project_id = project.project_id
|
||||
WHERE personal_project.user_id = $1;
|
||||
|
||||
|
||||
-- name: GetUserRolesForProject :one
|
||||
SELECT p.team_id, COALESCE(tm.role_code, '') AS team_role, COALESCE(pm.role_code, '') AS project_role
|
||||
FROM project AS p
|
||||
LEFT JOIN project_member AS pm ON pm.project_id = p.project_id AND pm.user_id = $1
|
||||
LEFT JOIN team_member AS tm ON tm.team_id = p.team_id AND tm.user_id = $1
|
||||
WHERE p.project_id = $2;
|
||||
|
||||
-- name: CreatePersonalProjectLink :one
|
||||
INSERT INTO personal_project (project_id, user_id) VALUES ($1, $2) RETURNING *;
|
||||
|
||||
-- name: SetPublicOn :one
|
||||
UPDATE project SET public_on = $2 WHERE project_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetPublicOn :one
|
||||
SELECT public_on FROM project WHERE project_id = $1;
|
@ -1,21 +0,0 @@
|
||||
-- name: CreateProjectLabel :one
|
||||
INSERT INTO project_label (project_id, label_color_id, created_date, name)
|
||||
VALUES ($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: GetProjectLabelsForProject :many
|
||||
SELECT * FROM project_label WHERE project_id = $1;
|
||||
|
||||
-- name: GetProjectLabelByID :one
|
||||
SELECT * FROM project_label WHERE project_label_id = $1;
|
||||
|
||||
-- name: DeleteProjectLabelByID :exec
|
||||
DELETE FROM project_label WHERE project_label_id = $1;
|
||||
|
||||
-- name: UpdateProjectLabelName :one
|
||||
UPDATE project_label SET name = $2 WHERE project_label_id = $1 RETURNING *;
|
||||
|
||||
-- name: UpdateProjectLabelColor :one
|
||||
UPDATE project_label SET label_color_id = $2 WHERE project_label_id = $1 RETURNING *;
|
||||
|
||||
-- name: UpdateProjectLabel :one
|
||||
UPDATE project_label SET name = $2, label_color_id = $3 WHERE project_label_id = $1 RETURNING *;
|
@ -1,5 +0,0 @@
|
||||
-- name: GetSystemOptionByKey :one
|
||||
SELECT key, value FROM system_options WHERE key = $1;
|
||||
|
||||
-- name: CreateSystemOption :one
|
||||
INSERT INTO system_options (key, value) VALUES ($1, $2) RETURNING *;
|
@ -1,149 +0,0 @@
|
||||
-- name: GetTaskWatcher :one
|
||||
SELECT * FROM task_watcher WHERE user_id = $1 AND task_id = $2;
|
||||
|
||||
-- name: GetTaskWatchersForTask :many
|
||||
SELECT * FROM task_watcher WHERE task_id = $1;
|
||||
|
||||
-- name: CreateTaskWatcher :one
|
||||
INSERT INTO task_watcher (user_id, task_id, watched_at) VALUES ($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: GetTaskIDByShortID :one
|
||||
SELECT task_id FROM task WHERE short_id = $1;
|
||||
|
||||
-- name: DeleteTaskWatcher :exec
|
||||
DELETE FROM task_watcher WHERE user_id = $1 AND task_id = $2;
|
||||
|
||||
-- name: CreateTask :one
|
||||
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 *;
|
||||
|
||||
-- name: GetTaskByID :one
|
||||
SELECT * FROM task WHERE task_id = $1;
|
||||
|
||||
-- name: GetTasksForTaskGroupID :many
|
||||
SELECT * FROM task WHERE task_group_id = $1;
|
||||
|
||||
-- name: GetAllTasks :many
|
||||
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;
|
||||
|
||||
-- name: UpdateTaskName :one
|
||||
UPDATE task SET name = $2 WHERE task_id = $1 RETURNING *;
|
||||
|
||||
-- name: DeleteTasksByTaskGroupID :execrows
|
||||
DELETE FROM task where task_group_id = $1;
|
||||
|
||||
-- name: UpdateTaskDueDate :one
|
||||
UPDATE task SET due_date = $2, has_time = $3 WHERE task_id = $1 RETURNING *;
|
||||
|
||||
-- name: SetTaskComplete :one
|
||||
UPDATE task SET complete = $2, completed_at = $3 WHERE task_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetProjectIDForTask :one
|
||||
SELECT project_id FROM task
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE task_id = $1;
|
||||
|
||||
-- name: GetProjectInfoForTask :one
|
||||
SELECT project.short_id AS project_short_id, project.name, task.short_id AS task_short_id FROM task
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
INNER JOIN project ON task_group.project_id = project.project_id
|
||||
WHERE task_id = $1;
|
||||
|
||||
-- name: CreateTaskComment :one
|
||||
INSERT INTO task_comment (task_id, message, created_at, created_by)
|
||||
VALUES ($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: GetCommentsForTaskID :many
|
||||
SELECT * FROM task_comment WHERE task_id = $1 ORDER BY created_at;
|
||||
|
||||
-- name: DeleteTaskCommentByID :one
|
||||
DELETE FROM task_comment WHERE task_comment_id = $1 RETURNING *;
|
||||
|
||||
-- name: UpdateTaskComment :one
|
||||
UPDATE task_comment SET message = $2, updated_at = $3 WHERE task_comment_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetRecentlyAssignedTaskForUserID :many
|
||||
SELECT task.* FROM task_assigned INNER JOIN
|
||||
task ON task.task_id = task_assigned.task_id WHERE user_id = $1
|
||||
AND $4::boolean = true OR (
|
||||
$4::boolean = false AND complete = $2 AND (
|
||||
$2 = false OR ($2 = true AND completed_at > $3)
|
||||
)
|
||||
)
|
||||
ORDER BY task_assigned.assigned_date DESC;
|
||||
|
||||
-- name: GetAssignedTasksProjectForUserID :many
|
||||
SELECT task.* FROM task_assigned
|
||||
INNER JOIN task ON task.task_id = task_assigned.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE user_id = $1
|
||||
AND $4::boolean = true OR (
|
||||
$4::boolean = false AND complete = $2 AND (
|
||||
$2 = false OR ($2 = true AND completed_at > $3)
|
||||
)
|
||||
)
|
||||
ORDER BY task_group.project_id DESC, task_assigned.assigned_date DESC;
|
||||
|
||||
-- name: GetProjectIdMappings :many
|
||||
SELECT project_id, task_id FROM task
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE task_id = ANY($1::uuid[]);
|
||||
|
||||
-- name: GetAssignedTasksDueDateForUserID :many
|
||||
SELECT task.* FROM task_assigned
|
||||
INNER JOIN task ON task.task_id = task_assigned.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE user_id = $1
|
||||
AND $4::boolean = true OR (
|
||||
$4::boolean = false AND complete = $2 AND (
|
||||
$2 = false OR ($2 = true AND completed_at > $3)
|
||||
)
|
||||
)
|
||||
ORDER BY task.due_date DESC, task_group.project_id DESC;
|
||||
|
||||
-- name: GetCommentCountForTask :one
|
||||
SELECT COUNT(*) FROM task_comment WHERE task_id = $1;
|
||||
|
||||
|
||||
-- name: CreateDueDateReminder :one
|
||||
INSERT INTO task_due_date_reminder (task_id, period, duration, remind_at) VALUES ($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: UpdateDueDateReminder :one
|
||||
UPDATE task_due_date_reminder SET remind_at = $4, period = $2, duration = $3 WHERE due_date_reminder_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetTaskForDueDateReminder :one
|
||||
SELECT task.* FROM task_due_date_reminder
|
||||
INNER JOIN task ON task.task_id = task_due_date_reminder.task_id
|
||||
WHERE task_due_date_reminder.due_date_reminder_id = $1;
|
||||
|
||||
-- name: UpdateDueDateReminderRemindAt :one
|
||||
UPDATE task_due_date_reminder SET remind_at = $2 WHERE due_date_reminder_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetDueDateRemindersForTaskID :many
|
||||
SELECT * FROM task_due_date_reminder WHERE task_id = $1;
|
||||
|
||||
-- name: GetDueDateReminderByID :one
|
||||
SELECT * FROM task_due_date_reminder WHERE due_date_reminder_id = $1;
|
||||
|
||||
-- name: DeleteDueDateReminder :exec
|
||||
DELETE FROM task_due_date_reminder WHERE due_date_reminder_id = $1;
|
||||
|
||||
-- name: GetDueDateRemindersForDuration :many
|
||||
SELECT * FROM task_due_date_reminder WHERE remind_at >= @start_at::timestamptz;
|
||||
|
@ -1,22 +0,0 @@
|
||||
-- name: CreateTaskActivity :one
|
||||
INSERT INTO task_activity (task_id, caused_by, created_at, activity_type_id, data)
|
||||
VALUES ($1, $2, $3, $4, $5) RETURNING *;
|
||||
|
||||
-- name: GetActivityForTaskID :many
|
||||
SELECT * FROM task_activity WHERE task_id = $1 AND active = true;
|
||||
|
||||
-- name: GetTemplateForActivityID :one
|
||||
SELECT template FROM task_activity_type WHERE task_activity_type_id = $1;
|
||||
|
||||
-- name: GetLastMoveForTaskID :one
|
||||
SELECT active, created_at, data->>'CurTaskGroupID' AS cur_task_group_id, data->>'PrevTaskGroupID' AS prev_task_group_id FROM task_activity
|
||||
WHERE task_id = $1 AND activity_type_id = 2 AND created_at >= NOW() - INTERVAL '5 minutes'
|
||||
ORDER BY created_at DESC LIMIT 1;
|
||||
|
||||
-- name: SetInactiveLastMoveForTaskID :exec
|
||||
UPDATE task_activity SET active = false WHERE task_activity_id = (
|
||||
SELECT task_activity_id FROM task_activity AS ta
|
||||
WHERE ta.activity_type_id = 2 AND ta.task_id = $1
|
||||
AND ta.created_at >= NOW() - INTERVAL '5 minutes'
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
);
|
@ -1,9 +0,0 @@
|
||||
-- name: CreateTaskAssigned :one
|
||||
INSERT INTO task_assigned (task_id, user_id, assigned_date)
|
||||
VALUES($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: GetAssignedMembersForTask :many
|
||||
SELECT * FROM task_assigned WHERE task_id = $1;
|
||||
|
||||
-- name: DeleteTaskAssignedByID :one
|
||||
DELETE FROM task_assigned WHERE task_id = $1 AND user_id = $2 RETURNING *;
|
@ -1,56 +0,0 @@
|
||||
-- name: CreateTaskChecklist :one
|
||||
INSERT INTO task_checklist (task_id, created_at, name, position) VALUES ($1, $2, $3, $4)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetTaskChecklistsForTask :many
|
||||
SELECT * FROM task_checklist WHERE task_id = $1;
|
||||
|
||||
-- name: UpdateTaskChecklistName :one
|
||||
UPDATE task_checklist SET name = $2 WHERE task_checklist_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteTaskChecklistByID :exec
|
||||
DELETE FROM task_checklist WHERE task_checklist_id = $1;
|
||||
|
||||
-- name: GetTaskChecklistByID :one
|
||||
SELECT * FROM task_checklist WHERE task_checklist_id = $1;
|
||||
|
||||
-- name: CreateTaskChecklistItem :one
|
||||
INSERT INTO task_checklist_item (task_checklist_id, created_at, name, position, complete, due_date) VALUES ($1, $2, $3, $4, false, null)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetTaskChecklistItemsForTaskChecklist :many
|
||||
SELECT * FROM task_checklist_item WHERE task_checklist_id = $1;
|
||||
|
||||
-- name: SetTaskChecklistItemComplete :one
|
||||
UPDATE task_checklist_item SET complete = $2 WHERE task_checklist_item_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteTaskChecklistItem :exec
|
||||
DELETE FROM task_checklist_item WHERE task_checklist_item_id = $1;
|
||||
|
||||
-- name: GetTaskChecklistItemByID :one
|
||||
SELECT * FROM task_checklist_item WHERE task_checklist_item_id = $1;
|
||||
|
||||
-- name: UpdateTaskChecklistItemName :one
|
||||
UPDATE task_checklist_item SET name = $2 WHERE task_checklist_item_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateTaskChecklistPosition :one
|
||||
UPDATE task_checklist SET position = $2 WHERE task_checklist_id = $1 RETURNING *;
|
||||
|
||||
-- name: UpdateTaskChecklistItemLocation :one
|
||||
UPDATE task_checklist_item SET position = $2, task_checklist_id = $3 WHERE task_checklist_item_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetProjectIDForTaskChecklist :one
|
||||
SELECT project_id FROM task_checklist
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE task_checklist.task_checklist_id = $1;
|
||||
|
||||
-- name: GetProjectIDForTaskChecklistItem :one
|
||||
SELECT project_id FROM task_checklist_item AS tci
|
||||
INNER JOIN task_checklist ON task_checklist.task_checklist_id = tci.task_checklist_id
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE tci.task_checklist_item_id = $1;
|
@ -1,24 +0,0 @@
|
||||
-- name: CreateTaskGroup :one
|
||||
INSERT INTO task_group (project_id, created_at, name, position)
|
||||
VALUES($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: GetTaskGroupsForProject :many
|
||||
SELECT * FROM task_group WHERE project_id = $1;
|
||||
|
||||
-- name: GetProjectIDForTaskGroup :one
|
||||
SELECT project_id from task_group WHERE task_group_id = $1;
|
||||
|
||||
-- name: GetAllTaskGroups :many
|
||||
SELECT * FROM task_group;
|
||||
|
||||
-- name: GetTaskGroupByID :one
|
||||
SELECT * FROM task_group WHERE task_group_id = $1;
|
||||
|
||||
-- name: SetTaskGroupName :one
|
||||
UPDATE task_group SET name = $2 WHERE task_group_id = $1 RETURNING *;
|
||||
|
||||
-- name: DeleteTaskGroupByID :execrows
|
||||
DELETE FROM task_group WHERE task_group_id = $1;
|
||||
|
||||
-- name: UpdateTaskGroupLocation :one
|
||||
UPDATE task_group SET position = $2 WHERE task_group_id = $1 RETURNING *;
|
@ -1,18 +0,0 @@
|
||||
-- name: CreateTaskLabelForTask :one
|
||||
INSERT INTO task_label (task_id, project_label_id, assigned_date)
|
||||
VALUES ($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: GetTaskLabelsForTaskID :many
|
||||
SELECT * FROM task_label WHERE task_id = $1;
|
||||
|
||||
-- name: GetTaskLabelByID :one
|
||||
SELECT * FROM task_label WHERE task_label_id = $1;
|
||||
|
||||
-- name: DeleteTaskLabelByID :exec
|
||||
DELETE FROM task_label WHERE task_label_id = $1;
|
||||
|
||||
-- name: GetTaskLabelForTaskByProjectLabelID :one
|
||||
SELECT * FROM task_label WHERE task_id = $1 AND project_label_id = $2;
|
||||
|
||||
-- name: DeleteTaskLabelForTaskByProjectLabelID :exec
|
||||
DELETE FROM task_label WHERE project_label_id = $2 AND task_id = $1;
|
@ -1,27 +0,0 @@
|
||||
-- name: GetAllTeams :many
|
||||
SELECT * FROM team;
|
||||
|
||||
-- name: GetTeamByID :one
|
||||
SELECT * FROM team WHERE team_id = $1;
|
||||
|
||||
-- name: CreateTeam :one
|
||||
INSERT INTO team (organization_id, created_at, name) VALUES ($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: DeleteTeamByID :exec
|
||||
DELETE FROM team WHERE team_id = $1;
|
||||
|
||||
-- name: GetTeamsForOrganization :many
|
||||
SELECT * FROM team WHERE organization_id = $1;
|
||||
|
||||
-- name: GetMemberTeamIDsForUserID :many
|
||||
SELECT team_id FROM team_member WHERE user_id = $1;
|
||||
|
||||
-- name: GetTeamRoleForUserID :one
|
||||
SELECT team_id, role_code FROM team_member WHERE user_id = $1 AND team_id = $2;
|
||||
|
||||
-- name: GetTeamRolesForUserID :many
|
||||
SELECT team_id, role_code FROM team_member WHERE user_id = $1;
|
||||
|
||||
-- name: GetTeamsForUserIDWhereAdmin :many
|
||||
SELECT team.* FROM team_member INNER JOIN team
|
||||
ON team.team_id = team_member.team_id WHERE (role_code = 'admin' OR role_code = 'member') AND user_id = $1;
|
@ -1,21 +0,0 @@
|
||||
-- name: CreateTeamMember :one
|
||||
INSERT INTO team_member (team_id, user_id, addedDate, role_code) VALUES ($1, $2, $3, $4)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetTeamMembersForTeamID :many
|
||||
SELECT * FROM team_member WHERE team_id = $1;
|
||||
|
||||
-- name: DeleteTeamMember :exec
|
||||
DELETE FROM team_member WHERE user_id = $1 AND team_id = $2;
|
||||
|
||||
-- name: GetRoleForTeamMember :one
|
||||
SELECT code, role.name FROM team_member
|
||||
INNER JOIN role ON role.code = team_member.role_code
|
||||
WHERE user_id = $1 AND team_id = $2;
|
||||
|
||||
-- name: UpdateTeamMemberRole :one
|
||||
UPDATE team_member SET role_code = $3 WHERE user_id = $2 AND team_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetTeamMemberByID :one
|
||||
SELECT * FROM team_member WHERE team_id = $1 AND user_id = $2;
|
@ -1,14 +0,0 @@
|
||||
-- name: GetAuthTokenByID :one
|
||||
SELECT * FROM auth_token WHERE token_id = $1;
|
||||
|
||||
-- name: CreateAuthToken :one
|
||||
INSERT INTO auth_token (user_id, created_at, expires_at) VALUES ($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: DeleteAuthTokenByID :exec
|
||||
DELETE FROM auth_token WHERE token_id = $1;
|
||||
|
||||
-- name: DeleteAuthTokenByUserID :exec
|
||||
DELETE FROM auth_token WHERE user_id = $1;
|
||||
|
||||
-- name: DeleteExpiredTokens :exec
|
||||
DELETE FROM auth_token WHERE expires_at <= NOW();
|
23
internal/db/query/user_account.sql
Normal file
23
internal/db/query/user_account.sql
Normal file
@ -0,0 +1,23 @@
|
||||
-- name: GetUserAccounts :many
|
||||
SELECT * FROM user_account;
|
||||
|
||||
-- name: GetUserAccountByUsername :one
|
||||
SELECT * FROM user_account WHERE username = $1;
|
||||
|
||||
-- name: GetUserAccountByID :one
|
||||
SELECT * FROM user_account WHERE user_id = $1;
|
||||
|
||||
-- name: HasAnyUserAccount :one
|
||||
SELECT EXISTS (SELECT * FROM user_account LIMIT 1);
|
||||
|
||||
-- name: CreateUserAccount :one
|
||||
INSERT INTO user_account (created_at, fullname, username, email, password_hash) VALUES ($1, $2, $3, $4, $5) RETURNING *;
|
||||
|
||||
-- name: CreateAccessToken :one
|
||||
INSERT INTO access_token (token, user_id, expires_at, created_at) VALUES ($1, $2, $3, $4) RETURNING *;
|
||||
|
||||
-- name: GetAccessToken :one
|
||||
SELECT * FROM access_token WHERE token = $1;
|
||||
|
||||
-- name: DeleteAccessToken :exec
|
||||
DELETE FROM access_token WHERE token = $1;
|
@ -1,106 +0,0 @@
|
||||
-- name: GetUserAccountByID :one
|
||||
SELECT * FROM user_account WHERE user_id = $1;
|
||||
|
||||
-- name: GetAllUserAccounts :many
|
||||
SELECT * FROM user_account WHERE username != 'system';
|
||||
|
||||
-- name: GetUserAccountByUsername :one
|
||||
SELECT * FROM user_account WHERE username = $1;
|
||||
|
||||
-- name: GetUserAccountByEmail :one
|
||||
SELECT * FROM user_account WHERE email = $1;
|
||||
|
||||
-- name: CreateUserAccount :one
|
||||
INSERT INTO user_account(full_name, initials, email, username, created_at, password_hash, role_code, active)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *;
|
||||
|
||||
-- name: UpdateUserAccountProfileAvatarURL :one
|
||||
UPDATE user_account SET profile_avatar_url = $2 WHERE user_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetMemberData :many
|
||||
SELECT * FROM user_account
|
||||
WHERE username != 'system'
|
||||
AND user_id NOT IN (SELECT user_id FROM project_member WHERE project_id = $1);
|
||||
|
||||
-- name: UpdateUserAccountInfo :one
|
||||
UPDATE user_account SET bio = $2, full_name = $3, initials = $4, email = $5
|
||||
WHERE user_id = $1 RETURNING *;
|
||||
|
||||
-- name: DeleteUserAccountByID :exec
|
||||
DELETE FROM user_account WHERE user_id = $1;
|
||||
|
||||
-- name: GetRoleForUserID :one
|
||||
SELECT username, role.code, role.name FROM user_account
|
||||
INNER JOIN role ON role.code = user_account.role_code
|
||||
WHERE user_id = $1;
|
||||
|
||||
-- name: UpdateUserRole :one
|
||||
UPDATE user_account SET role_code = $2 WHERE user_id = $1 RETURNING *;
|
||||
|
||||
-- name: SetUserPassword :one
|
||||
UPDATE user_account SET password_hash = $2 WHERE user_id = $1 RETURNING *;
|
||||
|
||||
-- name: CreateInvitedUser :one
|
||||
INSERT INTO user_account_invited (email) VALUES ($1) RETURNING *;
|
||||
|
||||
-- name: GetInvitedUserByEmail :one
|
||||
SELECT * FROM user_account_invited WHERE email = $1;
|
||||
|
||||
-- name: CreateInvitedProjectMember :one
|
||||
INSERT INTO project_member_invited (project_id, user_account_invited_id) VALUES ($1, $2)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetInvitedUserAccounts :many
|
||||
SELECT * FROM user_account_invited;
|
||||
|
||||
-- name: DeleteInvitedUserAccount :one
|
||||
DELETE FROM user_account_invited WHERE user_account_invited_id = $1 RETURNING *;
|
||||
|
||||
-- name: HasAnyUser :one
|
||||
SELECT EXISTS(SELECT 1 FROM user_account WHERE username != 'system');
|
||||
|
||||
-- name: HasActiveUser :one
|
||||
SELECT EXISTS(SELECT 1 FROM user_account WHERE username != 'system' AND active = true);
|
||||
|
||||
-- name: DoesUserExist :one
|
||||
SELECT EXISTS(SELECT 1 FROM user_account WHERE email = $1 OR username = $2);
|
||||
|
||||
-- name: CreateConfirmToken :one
|
||||
INSERT INTO user_account_confirm_token (email) VALUES ($1) RETURNING *;
|
||||
|
||||
-- name: GetConfirmTokenByEmail :one
|
||||
SELECT * FROM user_account_confirm_token WHERE email = $1;
|
||||
|
||||
-- name: GetConfirmTokenByID :one
|
||||
SELECT * FROM user_account_confirm_token WHERE confirm_token_id = $1;
|
||||
|
||||
-- name: SetFirstUserActive :one
|
||||
UPDATE user_account SET active = true WHERE user_id = (
|
||||
SELECT user_id from user_account WHERE active = false LIMIT 1
|
||||
) RETURNING *;
|
||||
|
||||
-- name: SetUserActiveByEmail :one
|
||||
UPDATE user_account SET active = true WHERE email = $1 RETURNING *;
|
||||
|
||||
-- name: GetProjectsForInvitedMember :many
|
||||
SELECT project_id FROM user_account_invited AS uai
|
||||
INNER JOIN project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE uai.email = $1;
|
||||
|
||||
-- name: DeleteProjectMemberInvitedForEmail :exec
|
||||
DELETE FROM project_member_invited WHERE project_member_invited_id IN (
|
||||
SELECT pmi.project_member_invited_id FROM user_account_invited AS uai
|
||||
INNER JOIN project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE uai.email = $1
|
||||
);
|
||||
|
||||
-- name: DeleteUserAccountInvitedForEmail :exec
|
||||
DELETE FROM user_account_invited WHERE email = $1;
|
||||
|
||||
-- name: DeleteConfirmTokenForEmail :exec
|
||||
DELETE FROM user_account_confirm_token WHERE email = $1;
|
||||
|
||||
|
@ -1,19 +1,17 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
import "database/sql"
|
||||
|
||||
// Repository contains methods for interacting with a database storage
|
||||
type Repository struct {
|
||||
*Queries
|
||||
db *sqlx.DB
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
// NewRepository returns an implementation of the Repository interface.
|
||||
func NewRepository(db *sqlx.DB) *Repository {
|
||||
func NewRepository(db *sql.DB) *Repository {
|
||||
return &Repository{
|
||||
Queries: New(db.DB),
|
||||
Queries: New(db),
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: system_options.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createSystemOption = `-- name: CreateSystemOption :one
|
||||
INSERT INTO system_options (key, value) VALUES ($1, $2) RETURNING option_id, key, value
|
||||
`
|
||||
|
||||
type CreateSystemOptionParams struct {
|
||||
Key string `json:"key"`
|
||||
Value sql.NullString `json:"value"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSystemOption(ctx context.Context, arg CreateSystemOptionParams) (SystemOption, error) {
|
||||
row := q.db.QueryRowContext(ctx, createSystemOption, arg.Key, arg.Value)
|
||||
var i SystemOption
|
||||
err := row.Scan(&i.OptionID, &i.Key, &i.Value)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSystemOptionByKey = `-- name: GetSystemOptionByKey :one
|
||||
SELECT key, value FROM system_options WHERE key = $1
|
||||
`
|
||||
|
||||
type GetSystemOptionByKeyRow struct {
|
||||
Key string `json:"key"`
|
||||
Value sql.NullString `json:"value"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetSystemOptionByKey(ctx context.Context, key string) (GetSystemOptionByKeyRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getSystemOptionByKey, key)
|
||||
var i GetSystemOptionByKeyRow
|
||||
err := row.Scan(&i.Key, &i.Value)
|
||||
return i, err
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,131 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: task_activity.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTaskActivity = `-- name: CreateTaskActivity :one
|
||||
INSERT INTO task_activity (task_id, caused_by, created_at, activity_type_id, data)
|
||||
VALUES ($1, $2, $3, $4, $5) RETURNING task_activity_id, active, task_id, created_at, caused_by, activity_type_id, data
|
||||
`
|
||||
|
||||
type CreateTaskActivityParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
CausedBy uuid.UUID `json:"caused_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ActivityTypeID int32 `json:"activity_type_id"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskActivity(ctx context.Context, arg CreateTaskActivityParams) (TaskActivity, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskActivity,
|
||||
arg.TaskID,
|
||||
arg.CausedBy,
|
||||
arg.CreatedAt,
|
||||
arg.ActivityTypeID,
|
||||
arg.Data,
|
||||
)
|
||||
var i TaskActivity
|
||||
err := row.Scan(
|
||||
&i.TaskActivityID,
|
||||
&i.Active,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.CausedBy,
|
||||
&i.ActivityTypeID,
|
||||
&i.Data,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getActivityForTaskID = `-- name: GetActivityForTaskID :many
|
||||
SELECT task_activity_id, active, task_id, created_at, caused_by, activity_type_id, data FROM task_activity WHERE task_id = $1 AND active = true
|
||||
`
|
||||
|
||||
func (q *Queries) GetActivityForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskActivity, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getActivityForTaskID, taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskActivity
|
||||
for rows.Next() {
|
||||
var i TaskActivity
|
||||
if err := rows.Scan(
|
||||
&i.TaskActivityID,
|
||||
&i.Active,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.CausedBy,
|
||||
&i.ActivityTypeID,
|
||||
&i.Data,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getLastMoveForTaskID = `-- name: GetLastMoveForTaskID :one
|
||||
SELECT active, created_at, data->>'CurTaskGroupID' AS cur_task_group_id, data->>'PrevTaskGroupID' AS prev_task_group_id FROM task_activity
|
||||
WHERE task_id = $1 AND activity_type_id = 2 AND created_at >= NOW() - INTERVAL '5 minutes'
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
`
|
||||
|
||||
type GetLastMoveForTaskIDRow struct {
|
||||
Active bool `json:"active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CurTaskGroupID interface{} `json:"cur_task_group_id"`
|
||||
PrevTaskGroupID interface{} `json:"prev_task_group_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetLastMoveForTaskID(ctx context.Context, taskID uuid.UUID) (GetLastMoveForTaskIDRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getLastMoveForTaskID, taskID)
|
||||
var i GetLastMoveForTaskIDRow
|
||||
err := row.Scan(
|
||||
&i.Active,
|
||||
&i.CreatedAt,
|
||||
&i.CurTaskGroupID,
|
||||
&i.PrevTaskGroupID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTemplateForActivityID = `-- name: GetTemplateForActivityID :one
|
||||
SELECT template FROM task_activity_type WHERE task_activity_type_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTemplateForActivityID(ctx context.Context, taskActivityTypeID int32) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTemplateForActivityID, taskActivityTypeID)
|
||||
var template string
|
||||
err := row.Scan(&template)
|
||||
return template, err
|
||||
}
|
||||
|
||||
const setInactiveLastMoveForTaskID = `-- name: SetInactiveLastMoveForTaskID :exec
|
||||
UPDATE task_activity SET active = false WHERE task_activity_id = (
|
||||
SELECT task_activity_id FROM task_activity AS ta
|
||||
WHERE ta.activity_type_id = 2 AND ta.task_id = $1
|
||||
AND ta.created_at >= NOW() - INTERVAL '5 minutes'
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
)
|
||||
`
|
||||
|
||||
func (q *Queries) SetInactiveLastMoveForTaskID(ctx context.Context, taskID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, setInactiveLastMoveForTaskID, taskID)
|
||||
return err
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: task_assigned.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTaskAssigned = `-- name: CreateTaskAssigned :one
|
||||
INSERT INTO task_assigned (task_id, user_id, assigned_date)
|
||||
VALUES($1, $2, $3) RETURNING task_assigned_id, task_id, user_id, assigned_date
|
||||
`
|
||||
|
||||
type CreateTaskAssignedParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
AssignedDate time.Time `json:"assigned_date"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskAssigned(ctx context.Context, arg CreateTaskAssignedParams) (TaskAssigned, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskAssigned, arg.TaskID, arg.UserID, arg.AssignedDate)
|
||||
var i TaskAssigned
|
||||
err := row.Scan(
|
||||
&i.TaskAssignedID,
|
||||
&i.TaskID,
|
||||
&i.UserID,
|
||||
&i.AssignedDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTaskAssignedByID = `-- name: DeleteTaskAssignedByID :one
|
||||
DELETE FROM task_assigned WHERE task_id = $1 AND user_id = $2 RETURNING task_assigned_id, task_id, user_id, assigned_date
|
||||
`
|
||||
|
||||
type DeleteTaskAssignedByIDParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteTaskAssignedByID(ctx context.Context, arg DeleteTaskAssignedByIDParams) (TaskAssigned, error) {
|
||||
row := q.db.QueryRowContext(ctx, deleteTaskAssignedByID, arg.TaskID, arg.UserID)
|
||||
var i TaskAssigned
|
||||
err := row.Scan(
|
||||
&i.TaskAssignedID,
|
||||
&i.TaskID,
|
||||
&i.UserID,
|
||||
&i.AssignedDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAssignedMembersForTask = `-- name: GetAssignedMembersForTask :many
|
||||
SELECT task_assigned_id, task_id, user_id, assigned_date FROM task_assigned WHERE task_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAssignedMembersForTask(ctx context.Context, taskID uuid.UUID) ([]TaskAssigned, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAssignedMembersForTask, taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskAssigned
|
||||
for rows.Next() {
|
||||
var i TaskAssigned
|
||||
if err := rows.Scan(
|
||||
&i.TaskAssignedID,
|
||||
&i.TaskID,
|
||||
&i.UserID,
|
||||
&i.AssignedDate,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
@ -1,344 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: task_checklist.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTaskChecklist = `-- name: CreateTaskChecklist :one
|
||||
INSERT INTO task_checklist (task_id, created_at, name, position) VALUES ($1, $2, $3, $4)
|
||||
RETURNING task_checklist_id, task_id, created_at, name, position
|
||||
`
|
||||
|
||||
type CreateTaskChecklistParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskChecklist(ctx context.Context, arg CreateTaskChecklistParams) (TaskChecklist, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskChecklist,
|
||||
arg.TaskID,
|
||||
arg.CreatedAt,
|
||||
arg.Name,
|
||||
arg.Position,
|
||||
)
|
||||
var i TaskChecklist
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistID,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createTaskChecklistItem = `-- name: CreateTaskChecklistItem :one
|
||||
INSERT INTO task_checklist_item (task_checklist_id, created_at, name, position, complete, due_date) VALUES ($1, $2, $3, $4, false, null)
|
||||
RETURNING task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date
|
||||
`
|
||||
|
||||
type CreateTaskChecklistItemParams struct {
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskChecklistItem(ctx context.Context, arg CreateTaskChecklistItemParams) (TaskChecklistItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskChecklistItem,
|
||||
arg.TaskChecklistID,
|
||||
arg.CreatedAt,
|
||||
arg.Name,
|
||||
arg.Position,
|
||||
)
|
||||
var i TaskChecklistItem
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTaskChecklistByID = `-- name: DeleteTaskChecklistByID :exec
|
||||
DELETE FROM task_checklist WHERE task_checklist_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTaskChecklistByID(ctx context.Context, taskChecklistID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteTaskChecklistByID, taskChecklistID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteTaskChecklistItem = `-- name: DeleteTaskChecklistItem :exec
|
||||
DELETE FROM task_checklist_item WHERE task_checklist_item_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteTaskChecklistItem, taskChecklistItemID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getProjectIDForTaskChecklist = `-- name: GetProjectIDForTaskChecklist :one
|
||||
SELECT project_id FROM task_checklist
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE task_checklist.task_checklist_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDForTaskChecklist, taskChecklistID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getProjectIDForTaskChecklistItem = `-- name: GetProjectIDForTaskChecklistItem :one
|
||||
SELECT project_id FROM task_checklist_item AS tci
|
||||
INNER JOIN task_checklist ON task_checklist.task_checklist_id = tci.task_checklist_id
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE tci.task_checklist_item_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDForTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDForTaskChecklistItem, taskChecklistItemID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getTaskChecklistByID = `-- name: GetTaskChecklistByID :one
|
||||
SELECT task_checklist_id, task_id, created_at, name, position FROM task_checklist WHERE task_checklist_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskChecklistByID(ctx context.Context, taskChecklistID uuid.UUID) (TaskChecklist, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTaskChecklistByID, taskChecklistID)
|
||||
var i TaskChecklist
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistID,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTaskChecklistItemByID = `-- name: GetTaskChecklistItemByID :one
|
||||
SELECT task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date FROM task_checklist_item WHERE task_checklist_item_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskChecklistItemByID(ctx context.Context, taskChecklistItemID uuid.UUID) (TaskChecklistItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTaskChecklistItemByID, taskChecklistItemID)
|
||||
var i TaskChecklistItem
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTaskChecklistItemsForTaskChecklist = `-- name: GetTaskChecklistItemsForTaskChecklist :many
|
||||
SELECT task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date FROM task_checklist_item WHERE task_checklist_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskChecklistItemsForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) ([]TaskChecklistItem, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTaskChecklistItemsForTaskChecklist, taskChecklistID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskChecklistItem
|
||||
for rows.Next() {
|
||||
var i TaskChecklistItem
|
||||
if err := rows.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTaskChecklistsForTask = `-- name: GetTaskChecklistsForTask :many
|
||||
SELECT task_checklist_id, task_id, created_at, name, position FROM task_checklist WHERE task_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskChecklistsForTask(ctx context.Context, taskID uuid.UUID) ([]TaskChecklist, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTaskChecklistsForTask, taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskChecklist
|
||||
for rows.Next() {
|
||||
var i TaskChecklist
|
||||
if err := rows.Scan(
|
||||
&i.TaskChecklistID,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setTaskChecklistItemComplete = `-- name: SetTaskChecklistItemComplete :one
|
||||
UPDATE task_checklist_item SET complete = $2 WHERE task_checklist_item_id = $1
|
||||
RETURNING task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date
|
||||
`
|
||||
|
||||
type SetTaskChecklistItemCompleteParams struct {
|
||||
TaskChecklistItemID uuid.UUID `json:"task_checklist_item_id"`
|
||||
Complete bool `json:"complete"`
|
||||
}
|
||||
|
||||
func (q *Queries) SetTaskChecklistItemComplete(ctx context.Context, arg SetTaskChecklistItemCompleteParams) (TaskChecklistItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, setTaskChecklistItemComplete, arg.TaskChecklistItemID, arg.Complete)
|
||||
var i TaskChecklistItem
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistItemLocation = `-- name: UpdateTaskChecklistItemLocation :one
|
||||
UPDATE task_checklist_item SET position = $2, task_checklist_id = $3 WHERE task_checklist_item_id = $1 RETURNING task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date
|
||||
`
|
||||
|
||||
type UpdateTaskChecklistItemLocationParams struct {
|
||||
TaskChecklistItemID uuid.UUID `json:"task_checklist_item_id"`
|
||||
Position float64 `json:"position"`
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskChecklistItemLocation(ctx context.Context, arg UpdateTaskChecklistItemLocationParams) (TaskChecklistItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskChecklistItemLocation, arg.TaskChecklistItemID, arg.Position, arg.TaskChecklistID)
|
||||
var i TaskChecklistItem
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistItemName = `-- name: UpdateTaskChecklistItemName :one
|
||||
UPDATE task_checklist_item SET name = $2 WHERE task_checklist_item_id = $1
|
||||
RETURNING task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date
|
||||
`
|
||||
|
||||
type UpdateTaskChecklistItemNameParams struct {
|
||||
TaskChecklistItemID uuid.UUID `json:"task_checklist_item_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskChecklistItemName(ctx context.Context, arg UpdateTaskChecklistItemNameParams) (TaskChecklistItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskChecklistItemName, arg.TaskChecklistItemID, arg.Name)
|
||||
var i TaskChecklistItem
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistName = `-- name: UpdateTaskChecklistName :one
|
||||
UPDATE task_checklist SET name = $2 WHERE task_checklist_id = $1
|
||||
RETURNING task_checklist_id, task_id, created_at, name, position
|
||||
`
|
||||
|
||||
type UpdateTaskChecklistNameParams struct {
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskChecklistName(ctx context.Context, arg UpdateTaskChecklistNameParams) (TaskChecklist, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskChecklistName, arg.TaskChecklistID, arg.Name)
|
||||
var i TaskChecklist
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistID,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistPosition = `-- name: UpdateTaskChecklistPosition :one
|
||||
UPDATE task_checklist SET position = $2 WHERE task_checklist_id = $1 RETURNING task_checklist_id, task_id, created_at, name, position
|
||||
`
|
||||
|
||||
type UpdateTaskChecklistPositionParams struct {
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskChecklistPosition(ctx context.Context, arg UpdateTaskChecklistPositionParams) (TaskChecklist, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskChecklistPosition, arg.TaskChecklistID, arg.Position)
|
||||
var i TaskChecklist
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistID,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: task_group.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTaskGroup = `-- name: CreateTaskGroup :one
|
||||
INSERT INTO task_group (project_id, created_at, name, position)
|
||||
VALUES($1, $2, $3, $4) RETURNING task_group_id, project_id, created_at, name, position
|
||||
`
|
||||
|
||||
type CreateTaskGroupParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskGroup(ctx context.Context, arg CreateTaskGroupParams) (TaskGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskGroup,
|
||||
arg.ProjectID,
|
||||
arg.CreatedAt,
|
||||
arg.Name,
|
||||
arg.Position,
|
||||
)
|
||||
var i TaskGroup
|
||||
err := row.Scan(
|
||||
&i.TaskGroupID,
|
||||
&i.ProjectID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTaskGroupByID = `-- name: DeleteTaskGroupByID :execrows
|
||||
DELETE FROM task_group WHERE task_group_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTaskGroupByID(ctx context.Context, taskGroupID uuid.UUID) (int64, error) {
|
||||
result, err := q.db.ExecContext(ctx, deleteTaskGroupByID, taskGroupID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected()
|
||||
}
|
||||
|
||||
const getAllTaskGroups = `-- name: GetAllTaskGroups :many
|
||||
SELECT task_group_id, project_id, created_at, name, position FROM task_group
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllTaskGroups(ctx context.Context) ([]TaskGroup, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllTaskGroups)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskGroup
|
||||
for rows.Next() {
|
||||
var i TaskGroup
|
||||
if err := rows.Scan(
|
||||
&i.TaskGroupID,
|
||||
&i.ProjectID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectIDForTaskGroup = `-- name: GetProjectIDForTaskGroup :one
|
||||
SELECT project_id from task_group WHERE task_group_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDForTaskGroup(ctx context.Context, taskGroupID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDForTaskGroup, taskGroupID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getTaskGroupByID = `-- name: GetTaskGroupByID :one
|
||||
SELECT task_group_id, project_id, created_at, name, position FROM task_group WHERE task_group_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskGroupByID(ctx context.Context, taskGroupID uuid.UUID) (TaskGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTaskGroupByID, taskGroupID)
|
||||
var i TaskGroup
|
||||
err := row.Scan(
|
||||
&i.TaskGroupID,
|
||||
&i.ProjectID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTaskGroupsForProject = `-- name: GetTaskGroupsForProject :many
|
||||
SELECT task_group_id, project_id, created_at, name, position FROM task_group WHERE project_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskGroupsForProject(ctx context.Context, projectID uuid.UUID) ([]TaskGroup, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTaskGroupsForProject, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskGroup
|
||||
for rows.Next() {
|
||||
var i TaskGroup
|
||||
if err := rows.Scan(
|
||||
&i.TaskGroupID,
|
||||
&i.ProjectID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setTaskGroupName = `-- name: SetTaskGroupName :one
|
||||
UPDATE task_group SET name = $2 WHERE task_group_id = $1 RETURNING task_group_id, project_id, created_at, name, position
|
||||
`
|
||||
|
||||
type SetTaskGroupNameParams struct {
|
||||
TaskGroupID uuid.UUID `json:"task_group_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) SetTaskGroupName(ctx context.Context, arg SetTaskGroupNameParams) (TaskGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, setTaskGroupName, arg.TaskGroupID, arg.Name)
|
||||
var i TaskGroup
|
||||
err := row.Scan(
|
||||
&i.TaskGroupID,
|
||||
&i.ProjectID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskGroupLocation = `-- name: UpdateTaskGroupLocation :one
|
||||
UPDATE task_group SET position = $2 WHERE task_group_id = $1 RETURNING task_group_id, project_id, created_at, name, position
|
||||
`
|
||||
|
||||
type UpdateTaskGroupLocationParams struct {
|
||||
TaskGroupID uuid.UUID `json:"task_group_id"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskGroupLocation(ctx context.Context, arg UpdateTaskGroupLocationParams) (TaskGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskGroupLocation, arg.TaskGroupID, arg.Position)
|
||||
var i TaskGroup
|
||||
err := row.Scan(
|
||||
&i.TaskGroupID,
|
||||
&i.ProjectID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: task_label.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTaskLabelForTask = `-- name: CreateTaskLabelForTask :one
|
||||
INSERT INTO task_label (task_id, project_label_id, assigned_date)
|
||||
VALUES ($1, $2, $3) RETURNING task_label_id, task_id, project_label_id, assigned_date
|
||||
`
|
||||
|
||||
type CreateTaskLabelForTaskParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
AssignedDate time.Time `json:"assigned_date"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskLabelForTask(ctx context.Context, arg CreateTaskLabelForTaskParams) (TaskLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTaskLabelForTask, arg.TaskID, arg.ProjectLabelID, arg.AssignedDate)
|
||||
var i TaskLabel
|
||||
err := row.Scan(
|
||||
&i.TaskLabelID,
|
||||
&i.TaskID,
|
||||
&i.ProjectLabelID,
|
||||
&i.AssignedDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTaskLabelByID = `-- name: DeleteTaskLabelByID :exec
|
||||
DELETE FROM task_label WHERE task_label_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTaskLabelByID(ctx context.Context, taskLabelID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteTaskLabelByID, taskLabelID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteTaskLabelForTaskByProjectLabelID = `-- name: DeleteTaskLabelForTaskByProjectLabelID :exec
|
||||
DELETE FROM task_label WHERE project_label_id = $2 AND task_id = $1
|
||||
`
|
||||
|
||||
type DeleteTaskLabelForTaskByProjectLabelIDParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteTaskLabelForTaskByProjectLabelID(ctx context.Context, arg DeleteTaskLabelForTaskByProjectLabelIDParams) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteTaskLabelForTaskByProjectLabelID, arg.TaskID, arg.ProjectLabelID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getTaskLabelByID = `-- name: GetTaskLabelByID :one
|
||||
SELECT task_label_id, task_id, project_label_id, assigned_date FROM task_label WHERE task_label_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskLabelByID(ctx context.Context, taskLabelID uuid.UUID) (TaskLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTaskLabelByID, taskLabelID)
|
||||
var i TaskLabel
|
||||
err := row.Scan(
|
||||
&i.TaskLabelID,
|
||||
&i.TaskID,
|
||||
&i.ProjectLabelID,
|
||||
&i.AssignedDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTaskLabelForTaskByProjectLabelID = `-- name: GetTaskLabelForTaskByProjectLabelID :one
|
||||
SELECT task_label_id, task_id, project_label_id, assigned_date FROM task_label WHERE task_id = $1 AND project_label_id = $2
|
||||
`
|
||||
|
||||
type GetTaskLabelForTaskByProjectLabelIDParams struct {
|
||||
TaskID uuid.UUID `json:"task_id"`
|
||||
ProjectLabelID uuid.UUID `json:"project_label_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTaskLabelForTaskByProjectLabelID(ctx context.Context, arg GetTaskLabelForTaskByProjectLabelIDParams) (TaskLabel, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTaskLabelForTaskByProjectLabelID, arg.TaskID, arg.ProjectLabelID)
|
||||
var i TaskLabel
|
||||
err := row.Scan(
|
||||
&i.TaskLabelID,
|
||||
&i.TaskID,
|
||||
&i.ProjectLabelID,
|
||||
&i.AssignedDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTaskLabelsForTaskID = `-- name: GetTaskLabelsForTaskID :many
|
||||
SELECT task_label_id, task_id, project_label_id, assigned_date FROM task_label WHERE task_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskLabelsForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskLabel, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTaskLabelsForTaskID, taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TaskLabel
|
||||
for rows.Next() {
|
||||
var i TaskLabel
|
||||
if err := rows.Scan(
|
||||
&i.TaskLabelID,
|
||||
&i.TaskID,
|
||||
&i.ProjectLabelID,
|
||||
&i.AssignedDate,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: team.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTeam = `-- name: CreateTeam :one
|
||||
INSERT INTO team (organization_id, created_at, name) VALUES ($1, $2, $3) RETURNING team_id, created_at, name, organization_id
|
||||
`
|
||||
|
||||
type CreateTeamParams struct {
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTeam(ctx context.Context, arg CreateTeamParams) (Team, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTeam, arg.OrganizationID, arg.CreatedAt, arg.Name)
|
||||
var i Team
|
||||
err := row.Scan(
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.OrganizationID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTeamByID = `-- name: DeleteTeamByID :exec
|
||||
DELETE FROM team WHERE team_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTeamByID(ctx context.Context, teamID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteTeamByID, teamID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllTeams = `-- name: GetAllTeams :many
|
||||
SELECT team_id, created_at, name, organization_id FROM team
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllTeams(ctx context.Context) ([]Team, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllTeams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Team
|
||||
for rows.Next() {
|
||||
var i Team
|
||||
if err := rows.Scan(
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.OrganizationID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getMemberTeamIDsForUserID = `-- name: GetMemberTeamIDsForUserID :many
|
||||
SELECT team_id FROM team_member WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetMemberTeamIDsForUserID(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getMemberTeamIDsForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []uuid.UUID
|
||||
for rows.Next() {
|
||||
var team_id uuid.UUID
|
||||
if err := rows.Scan(&team_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, team_id)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTeamByID = `-- name: GetTeamByID :one
|
||||
SELECT team_id, created_at, name, organization_id FROM team WHERE team_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTeamByID(ctx context.Context, teamID uuid.UUID) (Team, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTeamByID, teamID)
|
||||
var i Team
|
||||
err := row.Scan(
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.OrganizationID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTeamRoleForUserID = `-- name: GetTeamRoleForUserID :one
|
||||
SELECT team_id, role_code FROM team_member WHERE user_id = $1 AND team_id = $2
|
||||
`
|
||||
|
||||
type GetTeamRoleForUserIDParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
}
|
||||
|
||||
type GetTeamRoleForUserIDRow struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTeamRoleForUserID(ctx context.Context, arg GetTeamRoleForUserIDParams) (GetTeamRoleForUserIDRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTeamRoleForUserID, arg.UserID, arg.TeamID)
|
||||
var i GetTeamRoleForUserIDRow
|
||||
err := row.Scan(&i.TeamID, &i.RoleCode)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTeamRolesForUserID = `-- name: GetTeamRolesForUserID :many
|
||||
SELECT team_id, role_code FROM team_member WHERE user_id = $1
|
||||
`
|
||||
|
||||
type GetTeamRolesForUserIDRow struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTeamRolesForUserID(ctx context.Context, userID uuid.UUID) ([]GetTeamRolesForUserIDRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTeamRolesForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetTeamRolesForUserIDRow
|
||||
for rows.Next() {
|
||||
var i GetTeamRolesForUserIDRow
|
||||
if err := rows.Scan(&i.TeamID, &i.RoleCode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTeamsForOrganization = `-- name: GetTeamsForOrganization :many
|
||||
SELECT team_id, created_at, name, organization_id FROM team WHERE organization_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTeamsForOrganization(ctx context.Context, organizationID uuid.UUID) ([]Team, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTeamsForOrganization, organizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Team
|
||||
for rows.Next() {
|
||||
var i Team
|
||||
if err := rows.Scan(
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.OrganizationID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTeamsForUserIDWhereAdmin = `-- name: GetTeamsForUserIDWhereAdmin :many
|
||||
SELECT team.team_id, team.created_at, team.name, team.organization_id FROM team_member INNER JOIN team
|
||||
ON team.team_id = team_member.team_id WHERE (role_code = 'admin' OR role_code = 'member') AND user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTeamsForUserIDWhereAdmin(ctx context.Context, userID uuid.UUID) ([]Team, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTeamsForUserIDWhereAdmin, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Team
|
||||
for rows.Next() {
|
||||
var i Team
|
||||
if err := rows.Scan(
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.OrganizationID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: team_member.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createTeamMember = `-- name: CreateTeamMember :one
|
||||
INSERT INTO team_member (team_id, user_id, addedDate, role_code) VALUES ($1, $2, $3, $4)
|
||||
RETURNING team_member_id, team_id, user_id, addeddate, role_code
|
||||
`
|
||||
|
||||
type CreateTeamMemberParams struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Addeddate time.Time `json:"addeddate"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTeamMember(ctx context.Context, arg CreateTeamMemberParams) (TeamMember, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTeamMember,
|
||||
arg.TeamID,
|
||||
arg.UserID,
|
||||
arg.Addeddate,
|
||||
arg.RoleCode,
|
||||
)
|
||||
var i TeamMember
|
||||
err := row.Scan(
|
||||
&i.TeamMemberID,
|
||||
&i.TeamID,
|
||||
&i.UserID,
|
||||
&i.Addeddate,
|
||||
&i.RoleCode,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTeamMember = `-- name: DeleteTeamMember :exec
|
||||
DELETE FROM team_member WHERE user_id = $1 AND team_id = $2
|
||||
`
|
||||
|
||||
type DeleteTeamMemberParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteTeamMember(ctx context.Context, arg DeleteTeamMemberParams) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteTeamMember, arg.UserID, arg.TeamID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getRoleForTeamMember = `-- name: GetRoleForTeamMember :one
|
||||
SELECT code, role.name FROM team_member
|
||||
INNER JOIN role ON role.code = team_member.role_code
|
||||
WHERE user_id = $1 AND team_id = $2
|
||||
`
|
||||
|
||||
type GetRoleForTeamMemberParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetRoleForTeamMember(ctx context.Context, arg GetRoleForTeamMemberParams) (Role, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRoleForTeamMember, arg.UserID, arg.TeamID)
|
||||
var i Role
|
||||
err := row.Scan(&i.Code, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTeamMemberByID = `-- name: GetTeamMemberByID :one
|
||||
SELECT team_member_id, team_id, user_id, addeddate, role_code FROM team_member WHERE team_id = $1 AND user_id = $2
|
||||
`
|
||||
|
||||
type GetTeamMemberByIDParams struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTeamMemberByID(ctx context.Context, arg GetTeamMemberByIDParams) (TeamMember, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTeamMemberByID, arg.TeamID, arg.UserID)
|
||||
var i TeamMember
|
||||
err := row.Scan(
|
||||
&i.TeamMemberID,
|
||||
&i.TeamID,
|
||||
&i.UserID,
|
||||
&i.Addeddate,
|
||||
&i.RoleCode,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTeamMembersForTeamID = `-- name: GetTeamMembersForTeamID :many
|
||||
SELECT team_member_id, team_id, user_id, addeddate, role_code FROM team_member WHERE team_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTeamMembersForTeamID(ctx context.Context, teamID uuid.UUID) ([]TeamMember, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTeamMembersForTeamID, teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TeamMember
|
||||
for rows.Next() {
|
||||
var i TeamMember
|
||||
if err := rows.Scan(
|
||||
&i.TeamMemberID,
|
||||
&i.TeamID,
|
||||
&i.UserID,
|
||||
&i.Addeddate,
|
||||
&i.RoleCode,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateTeamMemberRole = `-- name: UpdateTeamMemberRole :one
|
||||
UPDATE team_member SET role_code = $3 WHERE user_id = $2 AND team_id = $1
|
||||
RETURNING team_member_id, team_id, user_id, addeddate, role_code
|
||||
`
|
||||
|
||||
type UpdateTeamMemberRoleParams struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTeamMemberRole(ctx context.Context, arg UpdateTeamMemberRoleParams) (TeamMember, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTeamMemberRole, arg.TeamID, arg.UserID, arg.RoleCode)
|
||||
var i TeamMember
|
||||
err := row.Scan(
|
||||
&i.TeamMemberID,
|
||||
&i.TeamID,
|
||||
&i.UserID,
|
||||
&i.Addeddate,
|
||||
&i.RoleCode,
|
||||
)
|
||||
return i, err
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: token.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createAuthToken = `-- name: CreateAuthToken :one
|
||||
INSERT INTO auth_token (user_id, created_at, expires_at) VALUES ($1, $2, $3) RETURNING token_id, user_id, created_at, expires_at
|
||||
`
|
||||
|
||||
type CreateAuthTokenParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateAuthToken(ctx context.Context, arg CreateAuthTokenParams) (AuthToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, createAuthToken, arg.UserID, arg.CreatedAt, arg.ExpiresAt)
|
||||
var i AuthToken
|
||||
err := row.Scan(
|
||||
&i.TokenID,
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.ExpiresAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteAuthTokenByID = `-- name: DeleteAuthTokenByID :exec
|
||||
DELETE FROM auth_token WHERE token_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAuthTokenByID(ctx context.Context, tokenID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteAuthTokenByID, tokenID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteAuthTokenByUserID = `-- name: DeleteAuthTokenByUserID :exec
|
||||
DELETE FROM auth_token WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAuthTokenByUserID(ctx context.Context, userID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteAuthTokenByUserID, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteExpiredTokens = `-- name: DeleteExpiredTokens :exec
|
||||
DELETE FROM auth_token WHERE expires_at <= NOW()
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteExpiredTokens(ctx context.Context) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteExpiredTokens)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAuthTokenByID = `-- name: GetAuthTokenByID :one
|
||||
SELECT token_id, user_id, created_at, expires_at FROM auth_token WHERE token_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAuthTokenByID(ctx context.Context, tokenID uuid.UUID) (AuthToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAuthTokenByID, tokenID)
|
||||
var i AuthToken
|
||||
err := row.Scan(
|
||||
&i.TokenID,
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.ExpiresAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
181
internal/db/user_account.sql.go
Normal file
181
internal/db/user_account.sql.go
Normal file
@ -0,0 +1,181 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: user_account.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createAccessToken = `-- name: CreateAccessToken :one
|
||||
INSERT INTO access_token (token, user_id, expires_at, created_at) VALUES ($1, $2, $3, $4) RETURNING token, user_id, expires_at, created_at
|
||||
`
|
||||
|
||||
type CreateAccessTokenParams struct {
|
||||
Token string `json:"token"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateAccessToken(ctx context.Context, arg CreateAccessTokenParams) (AccessToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, createAccessToken,
|
||||
arg.Token,
|
||||
arg.UserID,
|
||||
arg.ExpiresAt,
|
||||
arg.CreatedAt,
|
||||
)
|
||||
var i AccessToken
|
||||
err := row.Scan(
|
||||
&i.Token,
|
||||
&i.UserID,
|
||||
&i.ExpiresAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createUserAccount = `-- name: CreateUserAccount :one
|
||||
INSERT INTO user_account (created_at, fullname, username, email, password_hash) VALUES ($1, $2, $3, $4, $5) RETURNING user_id, created_at, fullname, username, email, password_hash, avatar_url
|
||||
`
|
||||
|
||||
type CreateUserAccountParams struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Fullname string `json:"fullname"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, createUserAccount,
|
||||
arg.CreatedAt,
|
||||
arg.Fullname,
|
||||
arg.Username,
|
||||
arg.Email,
|
||||
arg.PasswordHash,
|
||||
)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Fullname,
|
||||
&i.Username,
|
||||
&i.Email,
|
||||
&i.PasswordHash,
|
||||
&i.AvatarUrl,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteAccessToken = `-- name: DeleteAccessToken :exec
|
||||
DELETE FROM access_token WHERE token = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAccessToken(ctx context.Context, token string) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteAccessToken, token)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAccessToken = `-- name: GetAccessToken :one
|
||||
SELECT token, user_id, expires_at, created_at FROM access_token WHERE token = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAccessToken(ctx context.Context, token string) (AccessToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAccessToken, token)
|
||||
var i AccessToken
|
||||
err := row.Scan(
|
||||
&i.Token,
|
||||
&i.UserID,
|
||||
&i.ExpiresAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserAccountByID = `-- name: GetUserAccountByID :one
|
||||
SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserAccountByID(ctx context.Context, userID uuid.UUID) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserAccountByID, userID)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Fullname,
|
||||
&i.Username,
|
||||
&i.Email,
|
||||
&i.PasswordHash,
|
||||
&i.AvatarUrl,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserAccountByUsername = `-- name: GetUserAccountByUsername :one
|
||||
SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account WHERE username = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserAccountByUsername(ctx context.Context, username string) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserAccountByUsername, username)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Fullname,
|
||||
&i.Username,
|
||||
&i.Email,
|
||||
&i.PasswordHash,
|
||||
&i.AvatarUrl,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserAccounts = `-- name: GetUserAccounts :many
|
||||
SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserAccounts(ctx context.Context) ([]UserAccount, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getUserAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []UserAccount
|
||||
for rows.Next() {
|
||||
var i UserAccount
|
||||
if err := rows.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Fullname,
|
||||
&i.Username,
|
||||
&i.Email,
|
||||
&i.PasswordHash,
|
||||
&i.AvatarUrl,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const hasAnyUserAccount = `-- name: HasAnyUserAccount :one
|
||||
SELECT EXISTS (SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account LIMIT 1)
|
||||
`
|
||||
|
||||
func (q *Queries) HasAnyUserAccount(ctx context.Context) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, hasAnyUserAccount)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
@ -1,646 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// source: user_accounts.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createConfirmToken = `-- name: CreateConfirmToken :one
|
||||
INSERT INTO user_account_confirm_token (email) VALUES ($1) RETURNING confirm_token_id, email
|
||||
`
|
||||
|
||||
func (q *Queries) CreateConfirmToken(ctx context.Context, email string) (UserAccountConfirmToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, createConfirmToken, email)
|
||||
var i UserAccountConfirmToken
|
||||
err := row.Scan(&i.ConfirmTokenID, &i.Email)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createInvitedProjectMember = `-- name: CreateInvitedProjectMember :one
|
||||
INSERT INTO project_member_invited (project_id, user_account_invited_id) VALUES ($1, $2)
|
||||
RETURNING project_member_invited_id, project_id, user_account_invited_id
|
||||
`
|
||||
|
||||
type CreateInvitedProjectMemberParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateInvitedProjectMember(ctx context.Context, arg CreateInvitedProjectMemberParams) (ProjectMemberInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, createInvitedProjectMember, arg.ProjectID, arg.UserAccountInvitedID)
|
||||
var i ProjectMemberInvited
|
||||
err := row.Scan(&i.ProjectMemberInvitedID, &i.ProjectID, &i.UserAccountInvitedID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createInvitedUser = `-- name: CreateInvitedUser :one
|
||||
INSERT INTO user_account_invited (email) VALUES ($1) RETURNING user_account_invited_id, email, invited_on, has_joined
|
||||
`
|
||||
|
||||
func (q *Queries) CreateInvitedUser(ctx context.Context, email string) (UserAccountInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, createInvitedUser, email)
|
||||
var i UserAccountInvited
|
||||
err := row.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createUserAccount = `-- name: CreateUserAccount :one
|
||||
INSERT INTO user_account(full_name, initials, email, username, created_at, password_hash, role_code, active)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
type CreateUserAccountParams struct {
|
||||
FullName string `json:"full_name"`
|
||||
Initials string `json:"initials"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
RoleCode string `json:"role_code"`
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, createUserAccount,
|
||||
arg.FullName,
|
||||
arg.Initials,
|
||||
arg.Email,
|
||||
arg.Username,
|
||||
arg.CreatedAt,
|
||||
arg.PasswordHash,
|
||||
arg.RoleCode,
|
||||
arg.Active,
|
||||
)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteConfirmTokenForEmail = `-- name: DeleteConfirmTokenForEmail :exec
|
||||
DELETE FROM user_account_confirm_token WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteConfirmTokenForEmail(ctx context.Context, email string) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteConfirmTokenForEmail, email)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteInvitedUserAccount = `-- name: DeleteInvitedUserAccount :one
|
||||
DELETE FROM user_account_invited WHERE user_account_invited_id = $1 RETURNING user_account_invited_id, email, invited_on, has_joined
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteInvitedUserAccount(ctx context.Context, userAccountInvitedID uuid.UUID) (UserAccountInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, deleteInvitedUserAccount, userAccountInvitedID)
|
||||
var i UserAccountInvited
|
||||
err := row.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteProjectMemberInvitedForEmail = `-- name: DeleteProjectMemberInvitedForEmail :exec
|
||||
DELETE FROM project_member_invited WHERE project_member_invited_id IN (
|
||||
SELECT pmi.project_member_invited_id FROM user_account_invited AS uai
|
||||
INNER JOIN project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE uai.email = $1
|
||||
)
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteProjectMemberInvitedForEmail(ctx context.Context, email string) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteProjectMemberInvitedForEmail, email)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteUserAccountByID = `-- name: DeleteUserAccountByID :exec
|
||||
DELETE FROM user_account WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteUserAccountByID(ctx context.Context, userID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteUserAccountByID, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteUserAccountInvitedForEmail = `-- name: DeleteUserAccountInvitedForEmail :exec
|
||||
DELETE FROM user_account_invited WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteUserAccountInvitedForEmail(ctx context.Context, email string) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteUserAccountInvitedForEmail, email)
|
||||
return err
|
||||
}
|
||||
|
||||
const doesUserExist = `-- name: DoesUserExist :one
|
||||
SELECT EXISTS(SELECT 1 FROM user_account WHERE email = $1 OR username = $2)
|
||||
`
|
||||
|
||||
type DoesUserExistParams struct {
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
func (q *Queries) DoesUserExist(ctx context.Context, arg DoesUserExistParams) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, doesUserExist, arg.Email, arg.Username)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const getAllUserAccounts = `-- name: GetAllUserAccounts :many
|
||||
SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active FROM user_account WHERE username != 'system'
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllUserAccounts(ctx context.Context) ([]UserAccount, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllUserAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []UserAccount
|
||||
for rows.Next() {
|
||||
var i UserAccount
|
||||
if err := rows.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getConfirmTokenByEmail = `-- name: GetConfirmTokenByEmail :one
|
||||
SELECT confirm_token_id, email FROM user_account_confirm_token WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetConfirmTokenByEmail(ctx context.Context, email string) (UserAccountConfirmToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, getConfirmTokenByEmail, email)
|
||||
var i UserAccountConfirmToken
|
||||
err := row.Scan(&i.ConfirmTokenID, &i.Email)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getConfirmTokenByID = `-- name: GetConfirmTokenByID :one
|
||||
SELECT confirm_token_id, email FROM user_account_confirm_token WHERE confirm_token_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetConfirmTokenByID(ctx context.Context, confirmTokenID uuid.UUID) (UserAccountConfirmToken, error) {
|
||||
row := q.db.QueryRowContext(ctx, getConfirmTokenByID, confirmTokenID)
|
||||
var i UserAccountConfirmToken
|
||||
err := row.Scan(&i.ConfirmTokenID, &i.Email)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getInvitedUserAccounts = `-- name: GetInvitedUserAccounts :many
|
||||
SELECT user_account_invited_id, email, invited_on, has_joined FROM user_account_invited
|
||||
`
|
||||
|
||||
func (q *Queries) GetInvitedUserAccounts(ctx context.Context) ([]UserAccountInvited, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getInvitedUserAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []UserAccountInvited
|
||||
for rows.Next() {
|
||||
var i UserAccountInvited
|
||||
if err := rows.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getInvitedUserByEmail = `-- name: GetInvitedUserByEmail :one
|
||||
SELECT user_account_invited_id, email, invited_on, has_joined FROM user_account_invited WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetInvitedUserByEmail(ctx context.Context, email string) (UserAccountInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, getInvitedUserByEmail, email)
|
||||
var i UserAccountInvited
|
||||
err := row.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getMemberData = `-- name: GetMemberData :many
|
||||
SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active FROM user_account
|
||||
WHERE username != 'system'
|
||||
AND user_id NOT IN (SELECT user_id FROM project_member WHERE project_id = $1)
|
||||
`
|
||||
|
||||
func (q *Queries) GetMemberData(ctx context.Context, projectID uuid.UUID) ([]UserAccount, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getMemberData, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []UserAccount
|
||||
for rows.Next() {
|
||||
var i UserAccount
|
||||
if err := rows.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectsForInvitedMember = `-- name: GetProjectsForInvitedMember :many
|
||||
SELECT project_id FROM user_account_invited AS uai
|
||||
INNER JOIN project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE uai.email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectsForInvitedMember(ctx context.Context, email string) ([]uuid.UUID, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getProjectsForInvitedMember, email)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []uuid.UUID
|
||||
for rows.Next() {
|
||||
var project_id uuid.UUID
|
||||
if err := rows.Scan(&project_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, project_id)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getRoleForUserID = `-- name: GetRoleForUserID :one
|
||||
SELECT username, role.code, role.name FROM user_account
|
||||
INNER JOIN role ON role.code = user_account.role_code
|
||||
WHERE user_id = $1
|
||||
`
|
||||
|
||||
type GetRoleForUserIDRow struct {
|
||||
Username string `json:"username"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetRoleForUserID(ctx context.Context, userID uuid.UUID) (GetRoleForUserIDRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRoleForUserID, userID)
|
||||
var i GetRoleForUserIDRow
|
||||
err := row.Scan(&i.Username, &i.Code, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserAccountByEmail = `-- name: GetUserAccountByEmail :one
|
||||
SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active FROM user_account WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserAccountByEmail(ctx context.Context, email string) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserAccountByEmail, email)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserAccountByID = `-- name: GetUserAccountByID :one
|
||||
SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active FROM user_account WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserAccountByID(ctx context.Context, userID uuid.UUID) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserAccountByID, userID)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserAccountByUsername = `-- name: GetUserAccountByUsername :one
|
||||
SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active FROM user_account WHERE username = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserAccountByUsername(ctx context.Context, username string) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserAccountByUsername, username)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const hasActiveUser = `-- name: HasActiveUser :one
|
||||
SELECT EXISTS(SELECT 1 FROM user_account WHERE username != 'system' AND active = true)
|
||||
`
|
||||
|
||||
func (q *Queries) HasActiveUser(ctx context.Context) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, hasActiveUser)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const hasAnyUser = `-- name: HasAnyUser :one
|
||||
SELECT EXISTS(SELECT 1 FROM user_account WHERE username != 'system')
|
||||
`
|
||||
|
||||
func (q *Queries) HasAnyUser(ctx context.Context) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, hasAnyUser)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const setFirstUserActive = `-- name: SetFirstUserActive :one
|
||||
UPDATE user_account SET active = true WHERE user_id = (
|
||||
SELECT user_id from user_account WHERE active = false LIMIT 1
|
||||
) RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
func (q *Queries) SetFirstUserActive(ctx context.Context) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, setFirstUserActive)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const setUserActiveByEmail = `-- name: SetUserActiveByEmail :one
|
||||
UPDATE user_account SET active = true WHERE email = $1 RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
func (q *Queries) SetUserActiveByEmail(ctx context.Context, email string) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, setUserActiveByEmail, email)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const setUserPassword = `-- name: SetUserPassword :one
|
||||
UPDATE user_account SET password_hash = $2 WHERE user_id = $1 RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
type SetUserPasswordParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
}
|
||||
|
||||
func (q *Queries) SetUserPassword(ctx context.Context, arg SetUserPasswordParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, setUserPassword, arg.UserID, arg.PasswordHash)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUserAccountInfo = `-- name: UpdateUserAccountInfo :one
|
||||
UPDATE user_account SET bio = $2, full_name = $3, initials = $4, email = $5
|
||||
WHERE user_id = $1 RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
type UpdateUserAccountInfoParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Bio string `json:"bio"`
|
||||
FullName string `json:"full_name"`
|
||||
Initials string `json:"initials"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserAccountInfo(ctx context.Context, arg UpdateUserAccountInfoParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateUserAccountInfo,
|
||||
arg.UserID,
|
||||
arg.Bio,
|
||||
arg.FullName,
|
||||
arg.Initials,
|
||||
arg.Email,
|
||||
)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUserAccountProfileAvatarURL = `-- name: UpdateUserAccountProfileAvatarURL :one
|
||||
UPDATE user_account SET profile_avatar_url = $2 WHERE user_id = $1
|
||||
RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
type UpdateUserAccountProfileAvatarURLParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
ProfileAvatarUrl sql.NullString `json:"profile_avatar_url"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserAccountProfileAvatarURL(ctx context.Context, arg UpdateUserAccountProfileAvatarURLParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateUserAccountProfileAvatarURL, arg.UserID, arg.ProfileAvatarUrl)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUserRole = `-- name: UpdateUserRole :one
|
||||
UPDATE user_account SET role_code = $2 WHERE user_id = $1 RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio, active
|
||||
`
|
||||
|
||||
type UpdateUserRoleParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateUserRole, arg.UserID, arg.RoleCode)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
&i.Active,
|
||||
)
|
||||
return i, err
|
||||
}
|
Reference in New Issue
Block a user