mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 13:29:44 +02:00
Implements the Project concept as a higher-level grouping for issues. Hierarchy: workspace → project → issue → sub-issue. Backend: - Migration 034: project table + issue.project_id FK - sqlc queries for project CRUD - Project handler with list/get/create/update/delete - Issue handler updated to support project_id in create/update - Routes at /api/projects, WebSocket event constants Frontend (new monorepo structure): - @multica/core: Project types, API client methods, queries/mutations, status config, realtime sync - @multica/views: Projects list page, detail page (overview + issues tabs), project picker for issue detail panel - apps/web: Route pages, sidebar navigation entry All TypeScript type checks and tests pass.
222 lines
5.0 KiB
Go
222 lines
5.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: project.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const countIssuesByProject = `-- name: CountIssuesByProject :one
|
|
SELECT count(*) FROM issue
|
|
WHERE project_id = $1
|
|
`
|
|
|
|
func (q *Queries) CountIssuesByProject(ctx context.Context, projectID pgtype.UUID) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countIssuesByProject, projectID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createProject = `-- name: CreateProject :one
|
|
INSERT INTO project (
|
|
workspace_id, title, description, icon, status,
|
|
lead_type, lead_id
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7
|
|
) RETURNING id, workspace_id, title, description, icon, status, lead_type, lead_id, created_at, updated_at
|
|
`
|
|
|
|
type CreateProjectParams struct {
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Title string `json:"title"`
|
|
Description pgtype.Text `json:"description"`
|
|
Icon pgtype.Text `json:"icon"`
|
|
Status string `json:"status"`
|
|
LeadType pgtype.Text `json:"lead_type"`
|
|
LeadID pgtype.UUID `json:"lead_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error) {
|
|
row := q.db.QueryRow(ctx, createProject,
|
|
arg.WorkspaceID,
|
|
arg.Title,
|
|
arg.Description,
|
|
arg.Icon,
|
|
arg.Status,
|
|
arg.LeadType,
|
|
arg.LeadID,
|
|
)
|
|
var i Project
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Icon,
|
|
&i.Status,
|
|
&i.LeadType,
|
|
&i.LeadID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteProject = `-- name: DeleteProject :exec
|
|
DELETE FROM project WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteProject(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteProject, id)
|
|
return err
|
|
}
|
|
|
|
const getProject = `-- name: GetProject :one
|
|
SELECT id, workspace_id, title, description, icon, status, lead_type, lead_id, created_at, updated_at FROM project
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetProject(ctx context.Context, id pgtype.UUID) (Project, error) {
|
|
row := q.db.QueryRow(ctx, getProject, id)
|
|
var i Project
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Icon,
|
|
&i.Status,
|
|
&i.LeadType,
|
|
&i.LeadID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getProjectInWorkspace = `-- name: GetProjectInWorkspace :one
|
|
SELECT id, workspace_id, title, description, icon, status, lead_type, lead_id, created_at, updated_at FROM project
|
|
WHERE id = $1 AND workspace_id = $2
|
|
`
|
|
|
|
type GetProjectInWorkspaceParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
}
|
|
|
|
func (q *Queries) GetProjectInWorkspace(ctx context.Context, arg GetProjectInWorkspaceParams) (Project, error) {
|
|
row := q.db.QueryRow(ctx, getProjectInWorkspace, arg.ID, arg.WorkspaceID)
|
|
var i Project
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Icon,
|
|
&i.Status,
|
|
&i.LeadType,
|
|
&i.LeadID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listProjects = `-- name: ListProjects :many
|
|
SELECT id, workspace_id, title, description, icon, status, lead_type, lead_id, created_at, updated_at FROM project
|
|
WHERE workspace_id = $1
|
|
AND ($2::text IS NULL OR status = $2)
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
type ListProjectsParams struct {
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Status pgtype.Text `json:"status"`
|
|
}
|
|
|
|
func (q *Queries) ListProjects(ctx context.Context, arg ListProjectsParams) ([]Project, error) {
|
|
rows, err := q.db.Query(ctx, listProjects, arg.WorkspaceID, arg.Status)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Project{}
|
|
for rows.Next() {
|
|
var i Project
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Icon,
|
|
&i.Status,
|
|
&i.LeadType,
|
|
&i.LeadID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateProject = `-- name: UpdateProject :one
|
|
UPDATE project SET
|
|
title = COALESCE($2, title),
|
|
description = $3,
|
|
icon = $4,
|
|
status = COALESCE($5, status),
|
|
lead_type = $6,
|
|
lead_id = $7,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, workspace_id, title, description, icon, status, lead_type, lead_id, created_at, updated_at
|
|
`
|
|
|
|
type UpdateProjectParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Title pgtype.Text `json:"title"`
|
|
Description pgtype.Text `json:"description"`
|
|
Icon pgtype.Text `json:"icon"`
|
|
Status pgtype.Text `json:"status"`
|
|
LeadType pgtype.Text `json:"lead_type"`
|
|
LeadID pgtype.UUID `json:"lead_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateProject(ctx context.Context, arg UpdateProjectParams) (Project, error) {
|
|
row := q.db.QueryRow(ctx, updateProject,
|
|
arg.ID,
|
|
arg.Title,
|
|
arg.Description,
|
|
arg.Icon,
|
|
arg.Status,
|
|
arg.LeadType,
|
|
arg.LeadID,
|
|
)
|
|
var i Project
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Icon,
|
|
&i.Status,
|
|
&i.LeadType,
|
|
&i.LeadID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|