feat: add component_types management functionality
This commit is contained in:
152
sqlc_gen/conponent_type.sql.go
Normal file
152
sqlc_gen/conponent_type.sql.go
Normal file
@@ -0,0 +1,152 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: conponent_type.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const createComponentType = `-- name: CreateComponentType :one
|
||||
INSERT INTO component_types (name, description,metadata, created_at)
|
||||
VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4
|
||||
)
|
||||
RETURNING id, name, description, metadata, created_at, updated_at
|
||||
`
|
||||
|
||||
type CreateComponentTypeParams struct {
|
||||
Name string `db:"name" json:"name"`
|
||||
Description pgtype.Text `db:"description" json:"description"`
|
||||
Metadata []byte `db:"metadata" json:"metadata"`
|
||||
CreatedAt time.Time `db:"created_at" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateComponentType(ctx context.Context, arg CreateComponentTypeParams) (ComponentType, error) {
|
||||
row := q.db.QueryRow(ctx, createComponentType,
|
||||
arg.Name,
|
||||
arg.Description,
|
||||
arg.Metadata,
|
||||
arg.CreatedAt,
|
||||
)
|
||||
var i ComponentType
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Metadata,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteComponentType = `-- name: DeleteComponentType :execrows
|
||||
DELETE FROM component_types
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteComponentType(ctx context.Context, id int64) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, deleteComponentType, id)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const getComponentTypeByID = `-- name: GetComponentTypeByID :one
|
||||
SELECT id, name, description, metadata, created_at, updated_at FROM component_types
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetComponentTypeByID(ctx context.Context, id int64) (ComponentType, error) {
|
||||
row := q.db.QueryRow(ctx, getComponentTypeByID, id)
|
||||
var i ComponentType
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Metadata,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listComponentTypes = `-- name: ListComponentTypes :many
|
||||
SELECT id, name, description, metadata, created_at, updated_at FROM component_types
|
||||
ORDER BY created_at DESC
|
||||
`
|
||||
|
||||
func (q *Queries) ListComponentTypes(ctx context.Context) ([]ComponentType, error) {
|
||||
rows, err := q.db.Query(ctx, listComponentTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ComponentType
|
||||
for rows.Next() {
|
||||
var i ComponentType
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Metadata,
|
||||
&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 updateComponentType = `-- name: UpdateComponentType :one
|
||||
UPDATE component_types
|
||||
SET name = CASE WHEN $1 = '' THEN name ELSE $1 END,
|
||||
description = coalesce($2, description),
|
||||
metadata = coalesce($3, metadata),
|
||||
updated_at = $4
|
||||
WHERE id = $5
|
||||
RETURNING id, name, description, metadata, created_at, updated_at
|
||||
`
|
||||
|
||||
type UpdateComponentTypeParams struct {
|
||||
Name interface{} `db:"name" json:"name"`
|
||||
Description pgtype.Text `db:"description" json:"description"`
|
||||
Metadata []byte `db:"metadata" json:"metadata"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
|
||||
ID int64 `db:"id" json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateComponentType(ctx context.Context, arg UpdateComponentTypeParams) (ComponentType, error) {
|
||||
row := q.db.QueryRow(ctx, updateComponentType,
|
||||
arg.Name,
|
||||
arg.Description,
|
||||
arg.Metadata,
|
||||
arg.UpdatedAt,
|
||||
arg.ID,
|
||||
)
|
||||
var i ComponentType
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Metadata,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -14,6 +14,7 @@ type Querier interface {
|
||||
AssignRoleToUser(ctx context.Context, arg AssignRoleToUserParams) (UserRole, error)
|
||||
CountUsersByRoleID(ctx context.Context, roleID uuid.UUID) (int64, error)
|
||||
CreateCabinet(ctx context.Context, arg CreateCabinetParams) (Cabinet, error)
|
||||
CreateComponentType(ctx context.Context, arg CreateComponentTypeParams) (ComponentType, error)
|
||||
CreateContainer(ctx context.Context, arg CreateContainerParams) (Container, error)
|
||||
CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
|
||||
CreateRoom(ctx context.Context, arg CreateRoomParams) (Room, error)
|
||||
@@ -21,12 +22,14 @@ type Querier interface {
|
||||
CreateUser(ctx context.Context, arg CreateUserParams) (uuid.UUID, error)
|
||||
CreateWarehouse(ctx context.Context, arg CreateWarehouseParams) (Warehouse, error)
|
||||
DeleteCabinet(ctx context.Context, id int64) (int64, error)
|
||||
DeleteComponentType(ctx context.Context, id int64) (int64, error)
|
||||
DeleteContainer(ctx context.Context, id int64) (int64, error)
|
||||
DeleteRole(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteRoom(ctx context.Context, id int64) (int64, error)
|
||||
DeleteShelve(ctx context.Context, id int64) (int64, error)
|
||||
DeleteWarehouse(ctx context.Context, id int64) (int64, error)
|
||||
GetCabinetByID(ctx context.Context, id int64) (Cabinet, error)
|
||||
GetComponentTypeByID(ctx context.Context, id int64) (ComponentType, error)
|
||||
GetContainerByID(ctx context.Context, id int64) (Container, error)
|
||||
GetRoleByID(ctx context.Context, id uuid.UUID) (Role, error)
|
||||
GetRoomByID(ctx context.Context, id int64) (Room, error)
|
||||
@@ -39,6 +42,7 @@ type Querier interface {
|
||||
GetUserRolesByUserID(ctx context.Context, userID uuid.UUID) ([]GetUserRolesByUserIDRow, error)
|
||||
GetWarehouseByID(ctx context.Context, id int64) (Warehouse, error)
|
||||
ListCabinets(ctx context.Context) ([]Cabinet, error)
|
||||
ListComponentTypes(ctx context.Context) ([]ComponentType, error)
|
||||
ListContainers(ctx context.Context) ([]Container, error)
|
||||
ListRoles(ctx context.Context) ([]Role, error)
|
||||
ListRooms(ctx context.Context) ([]Room, error)
|
||||
@@ -47,6 +51,7 @@ type Querier interface {
|
||||
RemoveAllRolesFromUser(ctx context.Context, userID uuid.UUID) error
|
||||
RemoveRoleFromUser(ctx context.Context, arg RemoveRoleFromUserParams) error
|
||||
UpdateCabinet(ctx context.Context, arg UpdateCabinetParams) (Cabinet, error)
|
||||
UpdateComponentType(ctx context.Context, arg UpdateComponentTypeParams) (ComponentType, error)
|
||||
UpdateContainer(ctx context.Context, arg UpdateContainerParams) (Container, error)
|
||||
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
||||
UpdateRoom(ctx context.Context, arg UpdateRoomParams) (Room, error)
|
||||
|
||||
Reference in New Issue
Block a user