You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
340 lines
8.8 KiB
340 lines
8.8 KiB
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.13.0
|
|
// source: project.sql
|
|
|
|
package mysqlcore
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
const deleteAllProjectRequirementStats = `-- name: DeleteAllProjectRequirementStats :exec
|
|
DELETE FROM project_requirement_stat WHERE project_requirement_id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteAllProjectRequirementStats(ctx context.Context, projectRequirementID int) error {
|
|
_, err := q.exec(ctx, q.deleteAllProjectRequirementStatsStmt, deleteAllProjectRequirementStats, projectRequirementID)
|
|
return err
|
|
}
|
|
|
|
const deleteAllProjectRequirementStatsByStat = `-- name: DeleteAllProjectRequirementStatsByStat :exec
|
|
DELETE FROM project_requirement_stat WHERE stat_id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteAllProjectRequirementStatsByStat(ctx context.Context, statID int) error {
|
|
_, err := q.exec(ctx, q.deleteAllProjectRequirementStatsByStatStmt, deleteAllProjectRequirementStatsByStat, statID)
|
|
return err
|
|
}
|
|
|
|
const deleteAllProjectRequirements = `-- name: DeleteAllProjectRequirements :exec
|
|
DELETE FROM project_requirement WHERE project_id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteAllProjectRequirements(ctx context.Context, projectID int) error {
|
|
_, err := q.exec(ctx, q.deleteAllProjectRequirementsStmt, deleteAllProjectRequirements, projectID)
|
|
return err
|
|
}
|
|
|
|
const deleteProject = `-- name: DeleteProject :exec
|
|
DELETE FROM project WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteProject(ctx context.Context, id int) error {
|
|
_, err := q.exec(ctx, q.deleteProjectStmt, deleteProject, id)
|
|
return err
|
|
}
|
|
|
|
const deleteProjectRequirement = `-- name: DeleteProjectRequirement :exec
|
|
DELETE FROM project_requirement WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteProjectRequirement(ctx context.Context, id int) error {
|
|
_, err := q.exec(ctx, q.deleteProjectRequirementStmt, deleteProjectRequirement, id)
|
|
return err
|
|
}
|
|
|
|
const deleteProjectRequirementStat = `-- name: DeleteProjectRequirementStat :exec
|
|
DELETE FROM project_requirement_stat WHERE project_requirement_id = ? AND stat_id = ?
|
|
`
|
|
|
|
type DeleteProjectRequirementStatParams struct {
|
|
ProjectRequirementID int
|
|
StatID int
|
|
}
|
|
|
|
func (q *Queries) DeleteProjectRequirementStat(ctx context.Context, arg DeleteProjectRequirementStatParams) error {
|
|
_, err := q.exec(ctx, q.deleteProjectRequirementStatStmt, deleteProjectRequirementStat, arg.ProjectRequirementID, arg.StatID)
|
|
return err
|
|
}
|
|
|
|
const getProject = `-- name: GetProject :one
|
|
SELECT id, scope_id, author_id, name, status, description, created_time FROM project WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetProject(ctx context.Context, id int) (Project, error) {
|
|
row := q.queryRow(ctx, q.getProjectStmt, getProject, id)
|
|
var i Project
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ScopeID,
|
|
&i.AuthorID,
|
|
&i.Name,
|
|
&i.Status,
|
|
&i.Description,
|
|
&i.CreatedTime,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getProjectRequirement = `-- name: GetProjectRequirement :one
|
|
SELECT id, scope_id, project_id, name, status, description FROM project_requirement WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetProjectRequirement(ctx context.Context, id int) (ProjectRequirement, error) {
|
|
row := q.queryRow(ctx, q.getProjectRequirementStmt, getProjectRequirement, id)
|
|
var i ProjectRequirement
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ScopeID,
|
|
&i.ProjectID,
|
|
&i.Name,
|
|
&i.Status,
|
|
&i.Description,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertProject = `-- name: InsertProject :execresult
|
|
INSERT INTO project (scope_id, author_id, name, status, description, created_time)
|
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
`
|
|
|
|
type InsertProjectParams struct {
|
|
ScopeID int
|
|
AuthorID string
|
|
Name string
|
|
Status int
|
|
Description string
|
|
CreatedTime time.Time
|
|
}
|
|
|
|
func (q *Queries) InsertProject(ctx context.Context, arg InsertProjectParams) (sql.Result, error) {
|
|
return q.exec(ctx, q.insertProjectStmt, insertProject,
|
|
arg.ScopeID,
|
|
arg.AuthorID,
|
|
arg.Name,
|
|
arg.Status,
|
|
arg.Description,
|
|
arg.CreatedTime,
|
|
)
|
|
}
|
|
|
|
const insertProjectRequirement = `-- name: InsertProjectRequirement :execresult
|
|
INSERT INTO project_requirement (scope_id, project_id, name, status, description)
|
|
VALUES (?, ?, ?, ?, ?)
|
|
`
|
|
|
|
type InsertProjectRequirementParams struct {
|
|
ScopeID int
|
|
ProjectID int
|
|
Name string
|
|
Status int
|
|
Description string
|
|
}
|
|
|
|
func (q *Queries) InsertProjectRequirement(ctx context.Context, arg InsertProjectRequirementParams) (sql.Result, error) {
|
|
return q.exec(ctx, q.insertProjectRequirementStmt, insertProjectRequirement,
|
|
arg.ScopeID,
|
|
arg.ProjectID,
|
|
arg.Name,
|
|
arg.Status,
|
|
arg.Description,
|
|
)
|
|
}
|
|
|
|
const listProjectEntries = `-- name: ListProjectEntries :many
|
|
SELECT id, name, status, created_time, author_id FROM project
|
|
WHERE scope_id = ?
|
|
ORDER BY status, created_time
|
|
`
|
|
|
|
type ListProjectEntriesRow struct {
|
|
ID int
|
|
Name string
|
|
Status int
|
|
CreatedTime time.Time
|
|
AuthorID string
|
|
}
|
|
|
|
func (q *Queries) ListProjectEntries(ctx context.Context, scopeID int) ([]ListProjectEntriesRow, error) {
|
|
rows, err := q.query(ctx, q.listProjectEntriesStmt, listProjectEntries, scopeID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ListProjectEntriesRow{}
|
|
for rows.Next() {
|
|
var i ListProjectEntriesRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Status,
|
|
&i.CreatedTime,
|
|
&i.AuthorID,
|
|
); 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 listProjectRequirementStats = `-- name: ListProjectRequirementStats :many
|
|
SELECT prs.required, s.id, s.name, s.weight FROM project_requirement_stat prs
|
|
RIGHT JOIN stat s ON s.id = prs.stat_id
|
|
WHERE project_requirement_id = ?
|
|
`
|
|
|
|
type ListProjectRequirementStatsRow struct {
|
|
Required sql.NullInt32
|
|
ID int
|
|
Name string
|
|
Weight float64
|
|
}
|
|
|
|
func (q *Queries) ListProjectRequirementStats(ctx context.Context, projectRequirementID int) ([]ListProjectRequirementStatsRow, error) {
|
|
rows, err := q.query(ctx, q.listProjectRequirementStatsStmt, listProjectRequirementStats, projectRequirementID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ListProjectRequirementStatsRow{}
|
|
for rows.Next() {
|
|
var i ListProjectRequirementStatsRow
|
|
if err := rows.Scan(
|
|
&i.Required,
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Weight,
|
|
); 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 listProjectRequirementsByProjectID = `-- name: ListProjectRequirementsByProjectID :many
|
|
SELECT id, scope_id, project_id, name, status, description FROM project_requirement WHERE project_id = ?
|
|
`
|
|
|
|
func (q *Queries) ListProjectRequirementsByProjectID(ctx context.Context, projectID int) ([]ProjectRequirement, error) {
|
|
rows, err := q.query(ctx, q.listProjectRequirementsByProjectIDStmt, listProjectRequirementsByProjectID, projectID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ProjectRequirement{}
|
|
for rows.Next() {
|
|
var i ProjectRequirement
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ScopeID,
|
|
&i.ProjectID,
|
|
&i.Name,
|
|
&i.Status,
|
|
&i.Description,
|
|
); 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 replaceProjectRequirementStat = `-- name: ReplaceProjectRequirementStat :exec
|
|
REPLACE INTO project_requirement_stat (project_requirement_id, stat_id, required)
|
|
VALUES (?, ?, ?)
|
|
`
|
|
|
|
type ReplaceProjectRequirementStatParams struct {
|
|
ProjectRequirementID int
|
|
StatID int
|
|
Required int
|
|
}
|
|
|
|
func (q *Queries) ReplaceProjectRequirementStat(ctx context.Context, arg ReplaceProjectRequirementStatParams) error {
|
|
_, err := q.exec(ctx, q.replaceProjectRequirementStatStmt, replaceProjectRequirementStat, arg.ProjectRequirementID, arg.StatID, arg.Required)
|
|
return err
|
|
}
|
|
|
|
const updateProject = `-- name: UpdateProject :exec
|
|
UPDATE project
|
|
SET name = ?,
|
|
status = ?,
|
|
description = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type UpdateProjectParams struct {
|
|
Name string
|
|
Status int
|
|
Description string
|
|
ID int
|
|
}
|
|
|
|
func (q *Queries) UpdateProject(ctx context.Context, arg UpdateProjectParams) error {
|
|
_, err := q.exec(ctx, q.updateProjectStmt, updateProject,
|
|
arg.Name,
|
|
arg.Status,
|
|
arg.Description,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateProjectRequirement = `-- name: UpdateProjectRequirement :exec
|
|
UPDATE project_requirement
|
|
SET name = ?,
|
|
status = ?,
|
|
description = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type UpdateProjectRequirementParams struct {
|
|
Name string
|
|
Status int
|
|
Description string
|
|
ID int
|
|
}
|
|
|
|
func (q *Queries) UpdateProjectRequirement(ctx context.Context, arg UpdateProjectRequirementParams) error {
|
|
_, err := q.exec(ctx, q.updateProjectRequirementStmt, updateProjectRequirement,
|
|
arg.Name,
|
|
arg.Status,
|
|
arg.Description,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|