dal

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDataPermissionDB

func GetDataPermissionDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

Get data permission storage instance

func GetEndpointDB

func GetEndpointDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetEndpointDB returns the database instance for Endpoint (only active records).

func GetModelAliasDB

func GetModelAliasDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetModelAliasDB returns the database instance for ModelAlias (only active records).

func GetModelCatalogDB

func GetModelCatalogDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetModelCatalogDB returns the database instance for ModelCatalog.

func GetModelCatalogI18nDB

func GetModelCatalogI18nDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetModelCatalogI18nDB returns the database instance for ModelCatalogI18n.

func GetModelDB

func GetModelDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetModelDB returns the database instance for Model (only active records).

func GetModelPriceVersionDB

func GetModelPriceVersionDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetModelPriceVersionDB returns the database instance for ModelPriceVersion (only active records).

func GetProviderDB

func GetProviderDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetProviderDB returns the database instance for Provider (only active records).

Types

type DataPermission

type DataPermission struct {
	DB *gorm.DB
}

Data permission management

func (*DataPermission) Create

func (a *DataPermission) Create(ctx context.Context, item *schema.DataPermission) error

Create a new data permission.

func (*DataPermission) Delete

func (a *DataPermission) Delete(ctx context.Context, id string) error

Delete the specified data permission from the database.

func (*DataPermission) DeleteByTypeAndDataId

func (a *DataPermission) DeleteByTypeAndDataId(ctx context.Context, dataType, dataId string) error

DeleteByTypeAndDataId deletes data permissions by type and data ID.

func (*DataPermission) Exists

func (a *DataPermission) Exists(ctx context.Context, id string) (bool, error)

Exists checks if the specified data permission exists in the database.

func (*DataPermission) Get

Get the specified data permission from the database.

func (*DataPermission) HasReadPermission

func (a *DataPermission) HasReadPermission(ctx context.Context, dataType, dataId, user, tenant string) (bool, error)

HasReadPermission checks if a user has read permission for a specific data item.

func (*DataPermission) Query

Query data permissions from the database based on the provided parameters and options.

func (*DataPermission) Update

func (a *DataPermission) Update(ctx context.Context, item *schema.DataPermission) error

Update the specified data permission in the database.

type Endpoint

type Endpoint struct {
	DB *gorm.DB
}

Endpoint data access layer

func (*Endpoint) Create

func (e *Endpoint) Create(ctx context.Context, item *schema.Endpoint) error

Create a new endpoint.

func (*Endpoint) Delete

func (e *Endpoint) Delete(ctx context.Context, id string) error

Delete the specified endpoint logically.

func (*Endpoint) Exists

func (e *Endpoint) Exists(ctx context.Context, id string) (bool, error)

Exists checks if the specified endpoint exists.

func (*Endpoint) ExistsByCode

func (e *Endpoint) ExistsByCode(ctx context.Context, code string, excludeID string) (bool, error)

ExistsByCode checks if an endpoint with the given code exists.

func (*Endpoint) ExistsDuplicate

func (e *Endpoint) ExistsDuplicate(ctx context.Context, modelID, providerID, url, apiKey, protocol, realModel string, excludeID string) (bool, error)

ExistsDuplicate checks if an active endpoint with the same route identity already exists.

func (*Endpoint) Get

Get the specified endpoint from the database.

func (*Endpoint) Query

Query endpoints from the database.

func (*Endpoint) QueryEndpointsByModelCode

func (e *Endpoint) QueryEndpointsByModelCode(ctx context.Context, modelCode string) (schema.Endpoints, error)

QueryEndpointsByModelCode queries enabled endpoints by model_code (for routing). Joins endpoint → model → provider and filters all three to enabled + not deleted.

func (*Endpoint) QueryEndpointsByModelID

func (e *Endpoint) QueryEndpointsByModelID(ctx context.Context, modelID string) (schema.Endpoints, error)

QueryEndpointsByModelID queries endpoints by Model ID (only enabled endpoints).

func (*Endpoint) QueryEndpointsByProviderID

func (e *Endpoint) QueryEndpointsByProviderID(ctx context.Context, providerID string) (schema.Endpoints, error)

QueryEndpointsByProviderID queries active endpoints by Provider ID.

func (*Endpoint) Update

func (e *Endpoint) Update(ctx context.Context, item *schema.Endpoint) error

Update the specified endpoint.

func (*Endpoint) UpdateApiKeyByProviderAndOldKey added in v0.3.0

func (e *Endpoint) UpdateApiKeyByProviderAndOldKey(ctx context.Context, providerID, oldKey, newKey string) error

UpdateApiKeyByProviderAndOldKey updates the api_key of non-deleted endpoints associated with a provider if their api_key matches oldKey.

func (*Endpoint) UpdateEnabled

func (e *Endpoint) UpdateEnabled(ctx context.Context, id string, enabled int, modifier string) error

UpdateEnabled updates only the enabled status (and modifier) of the specified endpoint.

type Model

type Model struct {
	DB *gorm.DB
}

Model data access layer

func (*Model) Create

func (m *Model) Create(ctx context.Context, item *schema.Model) error

Create a new model.

func (*Model) Delete

func (m *Model) Delete(ctx context.Context, id string) error

Delete the specified model logically.

func (*Model) Exists

func (m *Model) Exists(ctx context.Context, id string) (bool, error)

Exists checks if the specified model exists.

func (*Model) ExistsByModelCode

func (m *Model) ExistsByModelCode(ctx context.Context, modelCode string) (bool, error)

ExistsByModelCode checks if a model with the given model_code exists.

func (*Model) ExistsByModelName

func (m *Model) ExistsByModelName(ctx context.Context, modelName string) (bool, error)

ExistsByModelName checks if a model with the given model_name exists.

func (*Model) Get

func (m *Model) Get(ctx context.Context, id string, opts ...schema.ModelQueryOptions) (*schema.Model, error)

Get the specified model from the database.

func (*Model) GetIDByModelCode

func (m *Model) GetIDByModelCode(ctx context.Context, modelCode string) (string, error)

GetIDByModelCode returns model id for the specified model_code.

func (*Model) GetModelCodeByID

func (m *Model) GetModelCodeByID(ctx context.Context, id string) (string, error)

GetModelCodeByID returns model_code for the specified model id.

func (*Model) Query

Query models from the database.

func (*Model) Update

func (m *Model) Update(ctx context.Context, item *schema.Model) error

Update the specified model.

func (*Model) UpdateEnabled

func (m *Model) UpdateEnabled(ctx context.Context, id string, enabled int, modifier string) error

UpdateEnabled updates only the enabled status (and modifier) of the specified model.

type ModelAlias

type ModelAlias struct {
	DB *gorm.DB
}

ModelAlias data access layer

func (*ModelAlias) CountByModelId

func (m *ModelAlias) CountByModelId(ctx context.Context, modelId string) (int64, error)

CountByModelId counts active aliases for a given model ID.

func (*ModelAlias) Create

func (m *ModelAlias) Create(ctx context.Context, item *schema.ModelAlias) error

Create a new model alias.

func (*ModelAlias) Delete

func (m *ModelAlias) Delete(ctx context.Context, id string) error

Delete the specified model alias logically.

func (*ModelAlias) Exists

func (m *ModelAlias) Exists(ctx context.Context, id string) (bool, error)

Exists checks if the specified model alias exists.

func (*ModelAlias) ExistsByAlias

func (m *ModelAlias) ExistsByAlias(ctx context.Context, alias string) (bool, error)

ExistsByAlias checks if a model alias with the given alias name exists (global scope).

func (*ModelAlias) ExistsByUniqueKey

func (m *ModelAlias) ExistsByUniqueKey(ctx context.Context, spaceCode, alias string) (bool, error)

ExistsByUniqueKey checks if a model alias with the given space_code and alias exists.

func (*ModelAlias) Get

Get the specified model alias from the database.

func (*ModelAlias) ListByModelId

func (m *ModelAlias) ListByModelId(ctx context.Context, modelId string) (schema.ModelAliases, error)

ListByModelId returns all active aliases for a given model ID.

func (*ModelAlias) Query

Query model aliases from the database.

func (*ModelAlias) Update

func (m *ModelAlias) Update(ctx context.Context, item *schema.ModelAlias) error

Update the specified model alias.

type ModelCatalog

type ModelCatalog struct {
	DB *gorm.DB
}

ModelCatalog data access layer

func (*ModelCatalog) Create

func (m *ModelCatalog) Create(ctx context.Context, item *schema.ModelCatalog) error

Create a new model catalog.

func (*ModelCatalog) Delete

func (m *ModelCatalog) Delete(ctx context.Context, modelID string) error

Delete the specified model catalog.

func (*ModelCatalog) Exists

func (m *ModelCatalog) Exists(ctx context.Context, modelID string) (bool, error)

Exists checks if the specified model catalog exists.

func (*ModelCatalog) ExistsBySlug

func (m *ModelCatalog) ExistsBySlug(ctx context.Context, slug string, excludeModelID string) (bool, error)

ExistsBySlug checks if a model catalog with the given slug exists.

func (*ModelCatalog) Get

Get the specified model catalog from the database.

func (*ModelCatalog) GetBySlug

func (m *ModelCatalog) GetBySlug(ctx context.Context, slug string) (*schema.ModelCatalog, error)

GetBySlug gets a model catalog by slug.

func (*ModelCatalog) Query

Query model catalogs from the database.

func (*ModelCatalog) QueryPublic

func (m *ModelCatalog) QueryPublic(ctx context.Context, limit int) (schema.ModelCatalogs, error)

QueryPublic queries public available model catalogs for portal display.

func (*ModelCatalog) Update

func (m *ModelCatalog) Update(ctx context.Context, item *schema.ModelCatalog) error

Update the specified model catalog.

type ModelCatalogI18n

type ModelCatalogI18n struct {
	DB *gorm.DB
}

ModelCatalogI18n data access layer

func (*ModelCatalogI18n) Create

Create a new i18n entry.

func (*ModelCatalogI18n) Delete

func (m *ModelCatalogI18n) Delete(ctx context.Context, modelID, locale string) error

Delete deletes a specific i18n entry.

func (*ModelCatalogI18n) DeleteByModelID

func (m *ModelCatalogI18n) DeleteByModelID(ctx context.Context, modelID string) error

DeleteByModelID deletes all i18n entries for a model.

func (*ModelCatalogI18n) Get

func (m *ModelCatalogI18n) Get(ctx context.Context, modelID, locale string) (*schema.ModelCatalogI18n, error)

Get gets a specific i18n entry by model_id and locale.

func (*ModelCatalogI18n) Query

Query model catalog i18n entries from the database.

func (*ModelCatalogI18n) QueryByModelID

func (m *ModelCatalogI18n) QueryByModelID(ctx context.Context, modelID string) (schema.ModelCatalogI18ns, error)

QueryByModelID gets all i18n entries for a model.

func (*ModelCatalogI18n) Update

Update the specified i18n entry.

func (*ModelCatalogI18n) Upsert

Upsert creates or updates an i18n entry.

type ModelPriceVersion

type ModelPriceVersion struct {
	DB *gorm.DB
}

ModelPriceVersion data access layer

func (*ModelPriceVersion) Create

Create a new model price version.

func (*ModelPriceVersion) Delete

func (m *ModelPriceVersion) Delete(ctx context.Context, id string) error

Delete the specified model price version.

func (*ModelPriceVersion) Get

Get the specified model price version from the database.

func (*ModelPriceVersion) GetCurrentPrice

func (m *ModelPriceVersion) GetCurrentPrice(ctx context.Context, modelID, currency string) (*schema.ModelPriceVersion, error)

GetCurrentPrice gets the currently effective price version for a model.

func (*ModelPriceVersion) Query

Query model price versions from the database.

func (*ModelPriceVersion) QueryByModelID

func (m *ModelPriceVersion) QueryByModelID(ctx context.Context, modelID string) (schema.ModelPriceVersions, error)

QueryByModelID queries all price versions for a model.

func (*ModelPriceVersion) Update

Update the specified model price version.

type Provider

type Provider struct {
	DB *gorm.DB
}

Provider data access layer

func (*Provider) Create

func (p *Provider) Create(ctx context.Context, item *schema.Provider) error

Create a new provider.

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, id string) error

Delete the specified provider logically.

func (*Provider) Exists

func (p *Provider) Exists(ctx context.Context, id string) (bool, error)

Exists checks if the specified provider exists.

func (*Provider) ExistsCode

func (p *Provider) ExistsCode(ctx context.Context, code string) (bool, error)

ExistsCode checks if a provider with the given code exists.

func (*Provider) ExistsName

func (p *Provider) ExistsName(ctx context.Context, name string) (bool, error)

ExistsName checks if a provider with the given name exists.

func (*Provider) Get

Get the specified provider from the database.

func (*Provider) Query

Query providers from the database.

func (*Provider) Update

func (p *Provider) Update(ctx context.Context, item *schema.Provider) error

Update the specified provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL