Files
Tran Anh Tuan 6a4a96e0ca Base Project
2026-05-08 14:32:24 +07:00

472 lines
18 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
package db
import (
"database/sql/driver"
"fmt"
"time"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
type ComponentItemStatusEnum string
const (
ComponentItemStatusEnumNormal ComponentItemStatusEnum = "normal"
ComponentItemStatusEnumDamaged ComponentItemStatusEnum = "damaged"
ComponentItemStatusEnumLongUnused ComponentItemStatusEnum = "long_unused"
ComponentItemStatusEnumExpired ComponentItemStatusEnum = "expired"
ComponentItemStatusEnumPendingInspection ComponentItemStatusEnum = "pending_inspection"
)
func (e *ComponentItemStatusEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ComponentItemStatusEnum(s)
case string:
*e = ComponentItemStatusEnum(s)
default:
return fmt.Errorf("unsupported scan type for ComponentItemStatusEnum: %T", src)
}
return nil
}
type NullComponentItemStatusEnum struct {
ComponentItemStatusEnum ComponentItemStatusEnum `json:"componentItemStatusEnum"`
Valid bool `json:"valid"` // Valid is true if ComponentItemStatusEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullComponentItemStatusEnum) Scan(value interface{}) error {
if value == nil {
ns.ComponentItemStatusEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ComponentItemStatusEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullComponentItemStatusEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.ComponentItemStatusEnum), nil
}
type ContainerTypeEnum string
const (
ContainerTypeEnumEmptyBox ContainerTypeEnum = "empty_box"
ContainerTypeEnumTray ContainerTypeEnum = "tray"
ContainerTypeEnumPaperBox ContainerTypeEnum = "paper_box"
ContainerTypeEnumPlasticBox ContainerTypeEnum = "plastic_box"
ContainerTypeEnumBag ContainerTypeEnum = "bag"
ContainerTypeEnumOther ContainerTypeEnum = "other"
)
func (e *ContainerTypeEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ContainerTypeEnum(s)
case string:
*e = ContainerTypeEnum(s)
default:
return fmt.Errorf("unsupported scan type for ContainerTypeEnum: %T", src)
}
return nil
}
type NullContainerTypeEnum struct {
ContainerTypeEnum ContainerTypeEnum `json:"containerTypeEnum"`
Valid bool `json:"valid"` // Valid is true if ContainerTypeEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullContainerTypeEnum) Scan(value interface{}) error {
if value == nil {
ns.ContainerTypeEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ContainerTypeEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullContainerTypeEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.ContainerTypeEnum), nil
}
type InvoiceStatusEnum string
const (
InvoiceStatusEnumDraft InvoiceStatusEnum = "draft"
InvoiceStatusEnumPending InvoiceStatusEnum = "pending"
InvoiceStatusEnumApproved InvoiceStatusEnum = "approved"
InvoiceStatusEnumCompleted InvoiceStatusEnum = "completed"
InvoiceStatusEnumCancelled InvoiceStatusEnum = "cancelled"
)
func (e *InvoiceStatusEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = InvoiceStatusEnum(s)
case string:
*e = InvoiceStatusEnum(s)
default:
return fmt.Errorf("unsupported scan type for InvoiceStatusEnum: %T", src)
}
return nil
}
type NullInvoiceStatusEnum struct {
InvoiceStatusEnum InvoiceStatusEnum `json:"invoiceStatusEnum"`
Valid bool `json:"valid"` // Valid is true if InvoiceStatusEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullInvoiceStatusEnum) Scan(value interface{}) error {
if value == nil {
ns.InvoiceStatusEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.InvoiceStatusEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullInvoiceStatusEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.InvoiceStatusEnum), nil
}
type InvoiceTypeEnum string
const (
InvoiceTypeEnumImport InvoiceTypeEnum = "import"
InvoiceTypeEnumExport InvoiceTypeEnum = "export"
)
func (e *InvoiceTypeEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = InvoiceTypeEnum(s)
case string:
*e = InvoiceTypeEnum(s)
default:
return fmt.Errorf("unsupported scan type for InvoiceTypeEnum: %T", src)
}
return nil
}
type NullInvoiceTypeEnum struct {
InvoiceTypeEnum InvoiceTypeEnum `json:"invoiceTypeEnum"`
Valid bool `json:"valid"` // Valid is true if InvoiceTypeEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullInvoiceTypeEnum) Scan(value interface{}) error {
if value == nil {
ns.InvoiceTypeEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.InvoiceTypeEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullInvoiceTypeEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.InvoiceTypeEnum), nil
}
type TransactionTypeEnum string
const (
TransactionTypeEnumImport TransactionTypeEnum = "import"
TransactionTypeEnumExport TransactionTypeEnum = "export"
TransactionTypeEnumAdjustment TransactionTypeEnum = "adjustment"
TransactionTypeEnumTransfer TransactionTypeEnum = "transfer"
)
func (e *TransactionTypeEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = TransactionTypeEnum(s)
case string:
*e = TransactionTypeEnum(s)
default:
return fmt.Errorf("unsupported scan type for TransactionTypeEnum: %T", src)
}
return nil
}
type NullTransactionTypeEnum struct {
TransactionTypeEnum TransactionTypeEnum `json:"transactionTypeEnum"`
Valid bool `json:"valid"` // Valid is true if TransactionTypeEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullTransactionTypeEnum) Scan(value interface{}) error {
if value == nil {
ns.TransactionTypeEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.TransactionTypeEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullTransactionTypeEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.TransactionTypeEnum), nil
}
type AlternativeComponent struct {
ID int64 `db:"id" json:"id"`
InvoiceConfigItemID int64 `db:"invoice_config_item_id" json:"invoiceConfigItemId"`
AlternativeComponentID int64 `db:"alternative_component_id" json:"alternativeComponentId"`
ConversionRatio pgtype.Numeric `db:"conversion_ratio" json:"conversionRatio"`
Priority int32 `db:"priority" json:"priority"`
Note pgtype.Text `db:"note" json:"note"`
Metadata []byte `db:"metadata" json:"metadata"`
}
type Cabinet struct {
ID int64 `db:"id" json:"id"`
RoomID int64 `db:"room_id" json:"roomId"`
Name string `db:"name" json:"name"`
Description pgtype.Text `db:"description" json:"description"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type Component struct {
ID int64 `db:"id" json:"id"`
ComponentTypeID int64 `db:"component_type_id" json:"componentTypeId"`
Name string `db:"name" json:"name"`
Description pgtype.Text `db:"description" json:"description"`
Unit string `db:"unit" json:"unit"`
TotalQuantity int32 `db:"total_quantity" json:"totalQuantity"`
MinQuantity int32 `db:"min_quantity" json:"minQuantity"`
Metadata []byte `db:"metadata" json:"metadata"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type ComponentCode struct {
ID int64 `db:"id" json:"id"`
ComponentID int64 `db:"component_id" json:"componentId"`
Code string `db:"code" json:"code"`
CodeType pgtype.Text `db:"code_type" json:"codeType"`
IsPrimary bool `db:"is_primary" json:"isPrimary"`
Metadata []byte `db:"metadata" json:"metadata"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
}
type ComponentItem struct {
ID int64 `db:"id" json:"id"`
ComponentID int64 `db:"component_id" json:"componentId"`
ContainerID int64 `db:"container_id" json:"containerId"`
Quantity int32 `db:"quantity" json:"quantity"`
Status ComponentItemStatusEnum `db:"status" json:"status"`
Metadata []byte `db:"metadata" json:"metadata"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type ComponentStatusHistory struct {
ID int64 `db:"id" json:"id"`
ComponentItemID int64 `db:"component_item_id" json:"componentItemId"`
OldStatus NullComponentItemStatusEnum `db:"old_status" json:"oldStatus"`
NewStatus ComponentItemStatusEnum `db:"new_status" json:"newStatus"`
ChangedQuantity pgtype.Int4 `db:"changed_quantity" json:"changedQuantity"`
Note pgtype.Text `db:"note" json:"note"`
ChangedBy pgtype.Text `db:"changed_by" json:"changedBy"`
ChangedAt time.Time `db:"changed_at" json:"changedAt"`
}
type ComponentType struct {
ID int64 `db:"id" json:"id"`
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"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type Container struct {
ID int64 `db:"id" json:"id"`
ShelfID int64 `db:"shelf_id" json:"shelfId"`
Name string `db:"name" json:"name"`
ContainerType ContainerTypeEnum `db:"container_type" json:"containerType"`
Description pgtype.Text `db:"description" json:"description"`
MaxCapacity pgtype.Int4 `db:"max_capacity" json:"maxCapacity"`
Metadata []byte `db:"metadata" json:"metadata"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type Invoice struct {
ID int64 `db:"id" json:"id"`
InvoiceCode string `db:"invoice_code" json:"invoiceCode"`
Type InvoiceTypeEnum `db:"type" json:"type"`
Status InvoiceStatusEnum `db:"status" json:"status"`
InvoiceConfigID pgtype.Int8 `db:"invoice_config_id" json:"invoiceConfigId"`
TotalItems int32 `db:"total_items" json:"totalItems"`
Note pgtype.Text `db:"note" json:"note"`
CreatedBy pgtype.Text `db:"created_by" json:"createdBy"`
ApprovedBy pgtype.Text `db:"approved_by" json:"approvedBy"`
CompletedAt pgtype.Timestamptz `db:"completed_at" json:"completedAt"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
Metadata []byte `db:"metadata" json:"metadata"`
}
type InvoiceConfig struct {
ID int64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Type InvoiceTypeEnum `db:"type" json:"type"`
Description pgtype.Text `db:"description" json:"description"`
IsActive bool `db:"is_active" json:"isActive"`
Metadata []byte `db:"metadata" json:"metadata"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type InvoiceConfigItem struct {
ID int64 `db:"id" json:"id"`
InvoiceConfigID int64 `db:"invoice_config_id" json:"invoiceConfigId"`
ComponentID int64 `db:"component_id" json:"componentId"`
RequiredQuantity int32 `db:"required_quantity" json:"requiredQuantity"`
AllowAlternative bool `db:"allow_alternative" json:"allowAlternative"`
PriorityOrder int32 `db:"priority_order" json:"priorityOrder"`
Note pgtype.Text `db:"note" json:"note"`
Metadata []byte `db:"metadata" json:"metadata"`
}
type InvoiceItem struct {
ID int64 `db:"id" json:"id"`
InvoiceID int64 `db:"invoice_id" json:"invoiceId"`
ComponentID int64 `db:"component_id" json:"componentId"`
OriginalComponentID pgtype.Int8 `db:"original_component_id" json:"originalComponentId"`
RequiredQuantity int32 `db:"required_quantity" json:"requiredQuantity"`
ActualQuantity int32 `db:"actual_quantity" json:"actualQuantity"`
IsSubstituted bool `db:"is_substituted" json:"isSubstituted"`
IsShort bool `db:"is_short" json:"isShort"`
ShortageQuantity int32 `db:"shortage_quantity" json:"shortageQuantity"`
Note pgtype.Text `db:"note" json:"note"`
Metadata []byte `db:"metadata" json:"metadata"`
}
type InvoiceItemLocation struct {
ID int64 `db:"id" json:"id"`
InvoiceItemID int64 `db:"invoice_item_id" json:"invoiceItemId"`
ContainerID int64 `db:"container_id" json:"containerId"`
Quantity int32 `db:"quantity" json:"quantity"`
}
type InvoiceStatusHistory struct {
ID int64 `db:"id" json:"id"`
InvoiceID int64 `db:"invoice_id" json:"invoiceId"`
OldStatus pgtype.Text `db:"old_status" json:"oldStatus"`
NewStatus string `db:"new_status" json:"newStatus"`
ChangedBy pgtype.Text `db:"changed_by" json:"changedBy"`
Note pgtype.Text `db:"note" json:"note"`
ChangedAt time.Time `db:"changed_at" json:"changedAt"`
}
type Permission struct {
ID uuid.UUID `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Description pgtype.Text `db:"description" json:"description"`
CreatedAt pgtype.Timestamptz `db:"created_at" json:"createdAt"`
CreatedBy pgtype.Text `db:"created_by" json:"createdBy"`
}
type Role struct {
ID uuid.UUID `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Description pgtype.Text `db:"description" json:"description"`
CreatedAt pgtype.Timestamptz `db:"created_at" json:"createdAt"`
CreatedBy pgtype.Text `db:"created_by" json:"createdBy"`
}
type RolePermission struct {
RoleID uuid.UUID `db:"role_id" json:"roleId"`
PermissionID uuid.UUID `db:"permission_id" json:"permissionId"`
AssignedAt pgtype.Timestamptz `db:"assigned_at" json:"assignedAt"`
}
type Room struct {
ID int64 `db:"id" json:"id"`
WarehouseID int64 `db:"warehouse_id" json:"warehouseId"`
Name string `db:"name" json:"name"`
Description pgtype.Text `db:"description" json:"description"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type Shelf struct {
ID int64 `db:"id" json:"id"`
CabinetID int64 `db:"cabinet_id" json:"cabinetId"`
Name string `db:"name" json:"name"`
LevelIndex int32 `db:"level_index" json:"levelIndex"`
Description pgtype.Text `db:"description" json:"description"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
type StockTransaction struct {
ID int64 `db:"id" json:"id"`
InvoiceID int64 `db:"invoice_id" json:"invoiceId"`
ComponentID int64 `db:"component_id" json:"componentId"`
ContainerID int64 `db:"container_id" json:"containerId"`
TransactionType TransactionTypeEnum `db:"transaction_type" json:"transactionType"`
Quantity int32 `db:"quantity" json:"quantity"`
BalanceAfter pgtype.Int4 `db:"balance_after" json:"balanceAfter"`
Note pgtype.Text `db:"note" json:"note"`
CreatedBy pgtype.Text `db:"created_by" json:"createdBy"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
}
type User struct {
ID uuid.UUID `db:"id" json:"id"`
Username string `db:"username" json:"username"`
Email string `db:"email" json:"email"`
PasswordHash string `db:"password_hash" json:"passwordHash"`
FullName pgtype.Text `db:"full_name" json:"fullName"`
IsActive pgtype.Bool `db:"is_active" json:"isActive"`
CreatedAt pgtype.Timestamptz `db:"created_at" json:"createdAt"`
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updatedAt"`
CreatedBy pgtype.Text `db:"created_by" json:"createdBy"`
}
type UserRole struct {
UserID uuid.UUID `db:"user_id" json:"userId"`
RoleID uuid.UUID `db:"role_id" json:"roleId"`
AssignedAt pgtype.Timestamptz `db:"assigned_at" json:"assignedAt"`
}
type Warehouse struct {
ID int64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Description pgtype.Text `db:"description" json:"description"`
Address pgtype.Text `db:"address" json:"address"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}