// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.13.0 // source: item.sql package mysqlcore import ( "context" "database/sql" "time" "git.aiterp.net/stufflog3/stufflog3-api/internal/sqltypes" ) const cLearItemStatProgressByStat = `-- name: CLearItemStatProgressByStat :exec DELETE FROM item_stat_progress WHERE stat_id = ? ` func (q *Queries) CLearItemStatProgressByStat(ctx context.Context, statID int) error { _, err := q.exec(ctx, q.cLearItemStatProgressByStatStmt, cLearItemStatProgressByStat, statID) return err } const clearItemProjectRequirement = `-- name: ClearItemProjectRequirement :exec UPDATE item SET project_requirement_id = NULL WHERE project_requirement_id = ? ` func (q *Queries) ClearItemProjectRequirement(ctx context.Context, projectRequirementID sql.NullInt32) error { _, err := q.exec(ctx, q.clearItemProjectRequirementStmt, clearItemProjectRequirement, projectRequirementID) return err } const clearItemProjectRequirementByProjectID = `-- name: ClearItemProjectRequirementByProjectID :exec UPDATE item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id SET i.project_requirement_id = NULL WHERE pr.project_id = ? ` func (q *Queries) ClearItemProjectRequirementByProjectID(ctx context.Context, projectID int) error { _, err := q.exec(ctx, q.clearItemProjectRequirementByProjectIDStmt, clearItemProjectRequirementByProjectID, projectID) return err } const clearItemStatProgress = `-- name: ClearItemStatProgress :exec DELETE FROM item_stat_progress WHERE item_id = ? ` func (q *Queries) ClearItemStatProgress(ctx context.Context, itemID int) error { _, err := q.exec(ctx, q.clearItemStatProgressStmt, clearItemStatProgress, itemID) return err } const deleteItem = `-- name: DeleteItem :exec DELETE FROM item WHERE id = ? ` func (q *Queries) DeleteItem(ctx context.Context, id int) error { _, err := q.exec(ctx, q.deleteItemStmt, deleteItem, id) return err } const deleteItemForRequirement = `-- name: DeleteItemForRequirement :exec DELETE FROM item WHERE project_requirement_id = ? ` func (q *Queries) DeleteItemForRequirement(ctx context.Context, projectRequirementID sql.NullInt32) error { _, err := q.exec(ctx, q.deleteItemForRequirementStmt, deleteItemForRequirement, projectRequirementID) return err } const deleteItemStatProgress = `-- name: DeleteItemStatProgress :exec DELETE FROM item_stat_progress WHERE item_id = ? AND stat_id = ? ` type DeleteItemStatProgressParams struct { ItemID int StatID int } func (q *Queries) DeleteItemStatProgress(ctx context.Context, arg DeleteItemStatProgressParams) error { _, err := q.exec(ctx, q.deleteItemStatProgressStmt, deleteItemStatProgress, arg.ItemID, arg.StatID) return err } const getItem = `-- name: GetItem :one SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.id = ? ` type GetItemRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) GetItem(ctx context.Context, id int) (GetItemRow, error) { row := q.queryRow(ctx, q.getItemStmt, getItem, id) var i GetItemRow err := row.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ) return i, err } const getItemStatProgressBetween = `-- name: GetItemStatProgressBetween :one SELECT s.id, s.name, s.weight, SUM(isp.acquired), SUM(isp.required) FROM item i LEFT JOIN item_stat_progress isp on i.id = isp.item_id LEFT JOIN stat s on isp.stat_id = s.id WHERE i.acquired_time >= ? AND i.acquired_time < ? AND i.scope_id = ? GROUP BY stat_id ` type GetItemStatProgressBetweenParams struct { AcquiredTime sql.NullTime AcquiredTime_2 sql.NullTime ScopeID int } type GetItemStatProgressBetweenRow struct { ID sql.NullInt32 Name sql.NullString Weight float64 Sum interface{} Sum_2 interface{} } func (q *Queries) GetItemStatProgressBetween(ctx context.Context, arg GetItemStatProgressBetweenParams) (GetItemStatProgressBetweenRow, error) { row := q.queryRow(ctx, q.getItemStatProgressBetweenStmt, getItemStatProgressBetween, arg.AcquiredTime, arg.AcquiredTime_2, arg.ScopeID) var i GetItemStatProgressBetweenRow err := row.Scan( &i.ID, &i.Name, &i.Weight, &i.Sum, &i.Sum_2, ) return i, err } const insertItem = `-- name: InsertItem :execresult INSERT INTO item (scope_id, project_requirement_id, name, description, created_time, created_user_id, acquired_time, scheduled_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ` type InsertItemParams struct { ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate } func (q *Queries) InsertItem(ctx context.Context, arg InsertItemParams) (sql.Result, error) { return q.exec(ctx, q.insertItemStmt, insertItem, arg.ScopeID, arg.ProjectRequirementID, arg.Name, arg.Description, arg.CreatedTime, arg.CreatedUserID, arg.AcquiredTime, arg.ScheduledDate, ) } const listItemStatProgress = `-- name: ListItemStatProgress :many SELECT isp.required, isp.acquired, s.id, s.name, s.weight FROM item_stat_progress isp LEFT JOIN stat s ON s.id = isp.stat_id WHERE item_id = ? ` type ListItemStatProgressRow struct { Required int Acquired int ID sql.NullInt32 Name sql.NullString Weight float64 } func (q *Queries) ListItemStatProgress(ctx context.Context, itemID int) ([]ListItemStatProgressRow, error) { rows, err := q.query(ctx, q.listItemStatProgressStmt, listItemStatProgress, itemID) if err != nil { return nil, err } defer rows.Close() items := []ListItemStatProgressRow{} for rows.Next() { var i ListItemStatProgressRow if err := rows.Scan( &i.Required, &i.Acquired, &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 listItemStatProgressMulti = `-- name: ListItemStatProgressMulti :many SELECT isp.item_id, isp.required, isp.acquired, s.id, s.name, s.weight FROM item_stat_progress isp LEFT JOIN stat s ON s.id = isp.stat_id WHERE item_id IN (?, ?, ?, ?, ?, ?, ?, ?) ` type ListItemStatProgressMultiParams struct { ItemID int ItemID_2 int ItemID_3 int ItemID_4 int ItemID_5 int ItemID_6 int ItemID_7 int ItemID_8 int } type ListItemStatProgressMultiRow struct { ItemID int Required int Acquired int ID sql.NullInt32 Name sql.NullString Weight float64 } func (q *Queries) ListItemStatProgressMulti(ctx context.Context, arg ListItemStatProgressMultiParams) ([]ListItemStatProgressMultiRow, error) { rows, err := q.query(ctx, q.listItemStatProgressMultiStmt, listItemStatProgressMulti, arg.ItemID, arg.ItemID_2, arg.ItemID_3, arg.ItemID_4, arg.ItemID_5, arg.ItemID_6, arg.ItemID_7, arg.ItemID_8, ) if err != nil { return nil, err } defer rows.Close() items := []ListItemStatProgressMultiRow{} for rows.Next() { var i ListItemStatProgressMultiRow if err := rows.Scan( &i.ItemID, &i.Required, &i.Acquired, &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 listItemsAcquiredBetween = `-- name: ListItemsAcquiredBetween :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.acquired_time >= ? AND i.acquired_time <= ? AND i.scope_id = ? ORDER BY acquired_time DESC, created_time DESC ` type ListItemsAcquiredBetweenParams struct { AcquiredTime sql.NullTime AcquiredTime_2 sql.NullTime ScopeID int } type ListItemsAcquiredBetweenRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsAcquiredBetween(ctx context.Context, arg ListItemsAcquiredBetweenParams) ([]ListItemsAcquiredBetweenRow, error) { rows, err := q.query(ctx, q.listItemsAcquiredBetweenStmt, listItemsAcquiredBetween, arg.AcquiredTime, arg.AcquiredTime_2, arg.ScopeID) if err != nil { return nil, err } defer rows.Close() items := []ListItemsAcquiredBetweenRow{} for rows.Next() { var i ListItemsAcquiredBetweenRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsByProject = `-- name: ListItemsByProject :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE pr.project_id = ? ` type ListItemsByProjectRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsByProject(ctx context.Context, projectID int) ([]ListItemsByProjectRow, error) { rows, err := q.query(ctx, q.listItemsByProjectStmt, listItemsByProject, projectID) if err != nil { return nil, err } defer rows.Close() items := []ListItemsByProjectRow{} for rows.Next() { var i ListItemsByProjectRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsCreatedBetween = `-- name: ListItemsCreatedBetween :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.created_time >= ? AND i.created_time <= ? AND i.scope_id = ? ORDER BY created_time DESC ` type ListItemsCreatedBetweenParams struct { CreatedTime time.Time CreatedTime_2 time.Time ScopeID int } type ListItemsCreatedBetweenRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsCreatedBetween(ctx context.Context, arg ListItemsCreatedBetweenParams) ([]ListItemsCreatedBetweenRow, error) { rows, err := q.query(ctx, q.listItemsCreatedBetweenStmt, listItemsCreatedBetween, arg.CreatedTime, arg.CreatedTime_2, arg.ScopeID) if err != nil { return nil, err } defer rows.Close() items := []ListItemsCreatedBetweenRow{} for rows.Next() { var i ListItemsCreatedBetweenRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsCreatedBetweenNoScope = `-- name: ListItemsCreatedBetweenNoScope :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.created_time >= ? AND i.created_time < ? ` type ListItemsCreatedBetweenNoScopeParams struct { CreatedTime time.Time CreatedTime_2 time.Time } type ListItemsCreatedBetweenNoScopeRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsCreatedBetweenNoScope(ctx context.Context, arg ListItemsCreatedBetweenNoScopeParams) ([]ListItemsCreatedBetweenNoScopeRow, error) { rows, err := q.query(ctx, q.listItemsCreatedBetweenNoScopeStmt, listItemsCreatedBetweenNoScope, arg.CreatedTime, arg.CreatedTime_2) if err != nil { return nil, err } defer rows.Close() items := []ListItemsCreatedBetweenNoScopeRow{} for rows.Next() { var i ListItemsCreatedBetweenNoScopeRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsLooseBetween = `-- name: ListItemsLooseBetween :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.created_time >= ? AND i.created_time <= ? AND i.scope_id = ? AND i.scheduled_date IS NULL AND i.acquired_time IS NULL AND i.project_requirement_id IS NULL ORDER BY created_time DESC ` type ListItemsLooseBetweenParams struct { CreatedTime time.Time CreatedTime_2 time.Time ScopeID int } type ListItemsLooseBetweenRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsLooseBetween(ctx context.Context, arg ListItemsLooseBetweenParams) ([]ListItemsLooseBetweenRow, error) { rows, err := q.query(ctx, q.listItemsLooseBetweenStmt, listItemsLooseBetween, arg.CreatedTime, arg.CreatedTime_2, arg.ScopeID) if err != nil { return nil, err } defer rows.Close() items := []ListItemsLooseBetweenRow{} for rows.Next() { var i ListItemsLooseBetweenRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsLooseBetweenNoScope = `-- name: ListItemsLooseBetweenNoScope :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.created_time >= ? AND i.created_time < ? AND i.scheduled_date IS NULL AND i.acquired_time IS NULL ` type ListItemsLooseBetweenNoScopeParams struct { CreatedTime time.Time CreatedTime_2 time.Time } type ListItemsLooseBetweenNoScopeRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsLooseBetweenNoScope(ctx context.Context, arg ListItemsLooseBetweenNoScopeParams) ([]ListItemsLooseBetweenNoScopeRow, error) { rows, err := q.query(ctx, q.listItemsLooseBetweenNoScopeStmt, listItemsLooseBetweenNoScope, arg.CreatedTime, arg.CreatedTime_2) if err != nil { return nil, err } defer rows.Close() items := []ListItemsLooseBetweenNoScopeRow{} for rows.Next() { var i ListItemsLooseBetweenNoScopeRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsScheduledBetween = `-- name: ListItemsScheduledBetween :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.scheduled_date >= ? AND i.scheduled_date <= ? AND i.scope_id = ? ORDER BY scheduled_date, created_time ` type ListItemsScheduledBetweenParams struct { ScheduledDate sqltypes.NullDate ScheduledDate_2 sqltypes.NullDate ScopeID int } type ListItemsScheduledBetweenRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsScheduledBetween(ctx context.Context, arg ListItemsScheduledBetweenParams) ([]ListItemsScheduledBetweenRow, error) { rows, err := q.query(ctx, q.listItemsScheduledBetweenStmt, listItemsScheduledBetween, arg.ScheduledDate, arg.ScheduledDate_2, arg.ScopeID) if err != nil { return nil, err } defer rows.Close() items := []ListItemsScheduledBetweenRow{} for rows.Next() { var i ListItemsScheduledBetweenRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 listItemsScheduledBetweenNoScope = `-- name: ListItemsScheduledBetweenNoScope :many SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id WHERE i.scheduled_date >= ? AND i.scheduled_date < ? ` type ListItemsScheduledBetweenNoScopeParams struct { ScheduledDate sqltypes.NullDate ScheduledDate_2 sqltypes.NullDate } type ListItemsScheduledBetweenNoScopeRow struct { ID int ScopeID int ProjectRequirementID sql.NullInt32 Name string Description string CreatedTime time.Time CreatedUserID string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate ProjectID sql.NullInt32 } func (q *Queries) ListItemsScheduledBetweenNoScope(ctx context.Context, arg ListItemsScheduledBetweenNoScopeParams) ([]ListItemsScheduledBetweenNoScopeRow, error) { rows, err := q.query(ctx, q.listItemsScheduledBetweenNoScopeStmt, listItemsScheduledBetweenNoScope, arg.ScheduledDate, arg.ScheduledDate_2) if err != nil { return nil, err } defer rows.Close() items := []ListItemsScheduledBetweenNoScopeRow{} for rows.Next() { var i ListItemsScheduledBetweenNoScopeRow if err := rows.Scan( &i.ID, &i.ScopeID, &i.ProjectRequirementID, &i.Name, &i.Description, &i.CreatedTime, &i.CreatedUserID, &i.AcquiredTime, &i.ScheduledDate, &i.ProjectID, ); 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 replaceItemStatProgress = `-- name: ReplaceItemStatProgress :exec REPLACE INTO item_stat_progress (item_id, stat_id, acquired, required) VALUES (?, ?, ?, ?) ` type ReplaceItemStatProgressParams struct { ItemID int StatID int Acquired int Required int } func (q *Queries) ReplaceItemStatProgress(ctx context.Context, arg ReplaceItemStatProgressParams) error { _, err := q.exec(ctx, q.replaceItemStatProgressStmt, replaceItemStatProgress, arg.ItemID, arg.StatID, arg.Acquired, arg.Required, ) return err } const updateItem = `-- name: UpdateItem :exec UPDATE item SET project_requirement_id = ?, name = ?, description = ?, acquired_time = ?, scheduled_date = ?, created_user_id = ? WHERE id = ? ` type UpdateItemParams struct { ProjectRequirementID sql.NullInt32 Name string Description string AcquiredTime sql.NullTime ScheduledDate sqltypes.NullDate CreatedUserID string ID int } func (q *Queries) UpdateItem(ctx context.Context, arg UpdateItemParams) error { _, err := q.exec(ctx, q.updateItemStmt, updateItem, arg.ProjectRequirementID, arg.Name, arg.Description, arg.AcquiredTime, arg.ScheduledDate, arg.CreatedUserID, arg.ID, ) return err }