Documentation
¶
Index ¶
- func GetExternalIdentityDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetLoggerDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetMenuDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetMenuResourceDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetRoleDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetRoleMenuDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetTenantDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetTenantEndpointDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetTenantModelDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetUserAPIKeyDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetUserDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetUserRoleDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- type ExternalIdentity
- func (a *ExternalIdentity) Create(ctx context.Context, item *schema.ExternalIdentity) error
- func (a *ExternalIdentity) GetByProviderUserID(ctx context.Context, provider, providerUserID string) (*schema.ExternalIdentity, error)
- func (a *ExternalIdentity) UpdateSnapshot(ctx context.Context, item *schema.ExternalIdentity) error
- type Logger
- type Menu
- func (a *Menu) Create(ctx context.Context, item *schema.Menu) error
- func (a *Menu) Delete(ctx context.Context, id string) error
- func (a *Menu) Exists(ctx context.Context, id string) (bool, error)
- func (a *Menu) ExistsCodeByParentID(ctx context.Context, code, parentID string) (bool, error)
- func (a *Menu) ExistsNameByParentID(ctx context.Context, name, parentID string) (bool, error)
- func (a *Menu) Get(ctx context.Context, id string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)
- func (a *Menu) GetByCodeAndParentID(ctx context.Context, code, parentID string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)
- func (a *Menu) GetByNameAndParentID(ctx context.Context, name, parentID string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)
- func (a *Menu) GetUniquePageByCode(ctx context.Context, code string) (*schema.Menu, error)
- func (a *Menu) Query(ctx context.Context, params schema.MenuQueryParam, ...) (*schema.MenuQueryResult, error)
- func (a *Menu) QueryPagesByCode(ctx context.Context, code string) (schema.Menus, error)
- func (a *Menu) Update(ctx context.Context, item *schema.Menu) error
- func (a *Menu) UpdateParentPath(ctx context.Context, id, parentPath string) error
- func (a *Menu) UpdateStatusByParentPath(ctx context.Context, parentPath, status string) error
- type MenuResource
- func (a *MenuResource) Create(ctx context.Context, item *schema.MenuResource) error
- func (a *MenuResource) Delete(ctx context.Context, id string) error
- func (a *MenuResource) DeleteByMenuID(ctx context.Context, menuID string) error
- func (a *MenuResource) Exists(ctx context.Context, id string) (bool, error)
- func (a *MenuResource) ExistsMethodPathByMenuID(ctx context.Context, method, path, menuID string) (bool, error)
- func (a *MenuResource) Get(ctx context.Context, id string, opts ...schema.MenuResourceQueryOptions) (*schema.MenuResource, error)
- func (a *MenuResource) Query(ctx context.Context, params schema.MenuResourceQueryParam, ...) (*schema.MenuResourceQueryResult, error)
- func (a *MenuResource) Update(ctx context.Context, item *schema.MenuResource) error
- type Role
- func (a *Role) Create(ctx context.Context, item *schema.Role) error
- func (a *Role) Delete(ctx context.Context, id string) error
- func (a *Role) Exists(ctx context.Context, id string) (bool, error)
- func (a *Role) ExistsCode(ctx context.Context, code string) (bool, error)
- func (a *Role) Get(ctx context.Context, id string, opts ...schema.RoleQueryOptions) (*schema.Role, error)
- func (a *Role) GetByCode(ctx context.Context, code string, opts ...schema.RoleQueryOptions) (*schema.Role, error)
- func (a *Role) Query(ctx context.Context, params schema.RoleQueryParam, ...) (*schema.RoleQueryResult, error)
- func (a *Role) Update(ctx context.Context, item *schema.Role) error
- type RoleMenu
- func (a *RoleMenu) Create(ctx context.Context, item *schema.RoleMenu) error
- func (a *RoleMenu) Delete(ctx context.Context, id string) error
- func (a *RoleMenu) DeleteByMenuID(ctx context.Context, menuID string) error
- func (a *RoleMenu) DeleteByRoleID(ctx context.Context, roleID string) error
- func (a *RoleMenu) Exists(ctx context.Context, id string) (bool, error)
- func (a *RoleMenu) ExistsRoleIDMenuID(ctx context.Context, roleID, menuID string) (bool, error)
- func (a *RoleMenu) Get(ctx context.Context, id string, opts ...schema.RoleMenuQueryOptions) (*schema.RoleMenu, error)
- func (a *RoleMenu) Query(ctx context.Context, params schema.RoleMenuQueryParam, ...) (*schema.RoleMenuQueryResult, error)
- func (a *RoleMenu) Update(ctx context.Context, item *schema.RoleMenu) error
- type Tenant
- func (a *Tenant) Create(ctx context.Context, item *schema.Tenant) error
- func (a *Tenant) Delete(ctx context.Context, id string) error
- func (a *Tenant) Exists(ctx context.Context, id string) (bool, error)
- func (a *Tenant) ExistsCode(ctx context.Context, code string) (bool, error)
- func (a *Tenant) Get(ctx context.Context, id string, opts ...schema.TenantQueryOptions) (*schema.Tenant, error)
- func (a *Tenant) GetByCode(ctx context.Context, code string, opts ...schema.TenantQueryOptions) (*schema.Tenant, error)
- func (a *Tenant) Query(ctx context.Context, params schema.TenantQueryParam, ...) (*schema.TenantQueryResult, error)
- func (a *Tenant) Update(ctx context.Context, item *schema.Tenant) error
- type TenantEndpoint
- func (a *TenantEndpoint) CreateInBatches(ctx context.Context, tx *gorm.DB, items []*schema.TenantEndpoint) error
- func (a *TenantEndpoint) DeleteByTenantAndModel(ctx context.Context, tx *gorm.DB, tenantCode, modelID string) error
- func (a *TenantEndpoint) QueryEndpointIDsByModel(ctx context.Context, tx *gorm.DB, modelID string) ([]string, error)
- func (a *TenantEndpoint) QueryEndpointIDsByTenantAndModel(ctx context.Context, tenantCode, modelID string) ([]string, error)
- type TenantModel
- func (a *TenantModel) CreateInBatches(ctx context.Context, tx *gorm.DB, items []*schema.TenantModel) error
- func (a *TenantModel) DeleteByTenantCode(ctx context.Context, tx *gorm.DB, tenantCode string) error
- func (a *TenantModel) QueryByTenantCode(ctx context.Context, tenantCode string) ([]*schema.TenantModel, error)
- type User
- func (a *User) Create(ctx context.Context, item *schema.User) error
- func (a *User) Delete(ctx context.Context, id string) error
- func (a *User) Exists(ctx context.Context, id string) (bool, error)
- func (a *User) ExistsUsername(ctx context.Context, username string) (bool, error)
- func (a *User) Get(ctx context.Context, id string, opts ...schema.UserQueryOptions) (*schema.User, error)
- func (a *User) GetByEmail(ctx context.Context, email string, opts ...schema.UserQueryOptions) (*schema.User, error)
- func (a *User) GetByUsername(ctx context.Context, username string, opts ...schema.UserQueryOptions) (*schema.User, error)
- func (a *User) Query(ctx context.Context, params schema.UserQueryParam, ...) (*schema.UserQueryResult, error)
- func (a *User) Update(ctx context.Context, item *schema.User, selectFields ...string) error
- func (a *User) UpdatePasswordByID(ctx context.Context, id string, password string) error
- type UserAPIKey
- func (a *UserAPIKey) Create(ctx context.Context, item *schema.UserAPIKey) error
- func (a *UserAPIKey) Delete(ctx context.Context, id string) error
- func (a *UserAPIKey) Exists(ctx context.Context, id string) (bool, error)
- func (a *UserAPIKey) ExistsAPIKey(ctx context.Context, apiKey string) (bool, error)
- func (a *UserAPIKey) Get(ctx context.Context, id string, opts ...schema.UserAPIKeyQueryOptions) (*schema.UserAPIKey, error)
- func (a *UserAPIKey) GetByAPIKey(ctx context.Context, apiKey string, opts ...schema.UserAPIKeyQueryOptions) (*schema.UserAPIKey, error)
- func (a *UserAPIKey) Query(ctx context.Context, params schema.UserAPIKeyQueryParam, ...) (*schema.UserAPIKeyQueryResult, error)
- func (a *UserAPIKey) Update(ctx context.Context, item *schema.UserAPIKey, selectFields ...string) error
- type UserRole
- func (a *UserRole) Create(ctx context.Context, item *schema.UserRole) error
- func (a *UserRole) Delete(ctx context.Context, id string) error
- func (a *UserRole) DeleteByRoleID(ctx context.Context, roleID string) error
- func (a *UserRole) DeleteByUserID(ctx context.Context, userID string) error
- func (a *UserRole) Exists(ctx context.Context, id string) (bool, error)
- func (a *UserRole) Get(ctx context.Context, id string, opts ...schema.UserRoleQueryOptions) (*schema.UserRole, error)
- func (a *UserRole) Query(ctx context.Context, params schema.UserRoleQueryParam, ...) (*schema.UserRoleQueryResult, error)
- func (a *UserRole) Update(ctx context.Context, item *schema.UserRole) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExternalIdentityDB ¶
func GetLoggerDB ¶
Get logger storage instance
func GetMenuResourceDB ¶
Get menu resource storage instance
func GetRoleMenuDB ¶
Get role menu storage instance
func GetTenantDB ¶
Get tenant storage instance
func GetTenantEndpointDB ¶
GetTenantEndpointDB 获取租户-端点关联表 DB 实例
func GetTenantModelDB ¶
Get tenant_model storage instance
func GetUserAPIKeyDB ¶
GetUserAPIKeyDB 获取 API Key 表的数据库实例并关联 Model
Types ¶
type ExternalIdentity ¶
func (*ExternalIdentity) Create ¶
func (a *ExternalIdentity) Create(ctx context.Context, item *schema.ExternalIdentity) error
func (*ExternalIdentity) GetByProviderUserID ¶
func (a *ExternalIdentity) GetByProviderUserID(ctx context.Context, provider, providerUserID string) (*schema.ExternalIdentity, error)
func (*ExternalIdentity) UpdateSnapshot ¶
func (a *ExternalIdentity) UpdateSnapshot(ctx context.Context, item *schema.ExternalIdentity) error
type Logger ¶
Logger management
func (*Logger) Query ¶
func (a *Logger) Query(ctx context.Context, params schema.LoggerQueryParam, opts ...schema.LoggerQueryOptions) (*schema.LoggerQueryResult, error)
Query loggers from the database based on the provided parameters and options.
type Menu ¶
Menu management for RBAC
func (*Menu) ExistsCodeByParentID ¶
Checks if a menu with the specified `code` exists under the specified `parentID` in the database.
func (*Menu) ExistsNameByParentID ¶
Checks if a menu with the specified `name` exists under the specified `parentID` in the database.
func (*Menu) Get ¶
func (a *Menu) Get(ctx context.Context, id string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)
Get the specified menu from the database.
func (*Menu) GetByCodeAndParentID ¶
func (*Menu) GetByNameAndParentID ¶
func (a *Menu) GetByNameAndParentID(ctx context.Context, name, parentID string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)
GetByNameAndParentID get the specified menu from the database.
func (*Menu) GetUniquePageByCode ¶
func (*Menu) Query ¶
func (a *Menu) Query(ctx context.Context, params schema.MenuQueryParam, opts ...schema.MenuQueryOptions) (*schema.MenuQueryResult, error)
Query menus from the database based on the provided parameters and options.
func (*Menu) QueryPagesByCode ¶
func (*Menu) UpdateParentPath ¶
Updates the parent path of the specified menu.
type MenuResource ¶
Menu resource management for RBAC
func (*MenuResource) Create ¶
func (a *MenuResource) Create(ctx context.Context, item *schema.MenuResource) error
Create a new menu resource.
func (*MenuResource) Delete ¶
func (a *MenuResource) Delete(ctx context.Context, id string) error
Delete the specified menu resource from the database.
func (*MenuResource) DeleteByMenuID ¶
func (a *MenuResource) DeleteByMenuID(ctx context.Context, menuID string) error
Deletes the menu resource by menu id.
func (*MenuResource) ExistsMethodPathByMenuID ¶
func (a *MenuResource) ExistsMethodPathByMenuID(ctx context.Context, method, path, menuID string) (bool, error)
ExistsMethodPathByMenuID checks if the specified menu resource exists in the database.
func (*MenuResource) Get ¶
func (a *MenuResource) Get(ctx context.Context, id string, opts ...schema.MenuResourceQueryOptions) (*schema.MenuResource, error)
Get the specified menu resource from the database.
func (*MenuResource) Query ¶
func (a *MenuResource) Query(ctx context.Context, params schema.MenuResourceQueryParam, opts ...schema.MenuResourceQueryOptions) (*schema.MenuResourceQueryResult, error)
Query menu resources from the database based on the provided parameters and options.
func (*MenuResource) Update ¶
func (a *MenuResource) Update(ctx context.Context, item *schema.MenuResource) error
Update the specified menu resource in the database.
type Role ¶
Role management for RBAC
func (*Role) Get ¶
func (a *Role) Get(ctx context.Context, id string, opts ...schema.RoleQueryOptions) (*schema.Role, error)
Get the specified role from the database.
func (*Role) Query ¶
func (a *Role) Query(ctx context.Context, params schema.RoleQueryParam, opts ...schema.RoleQueryOptions) (*schema.RoleQueryResult, error)
Query roles from the database based on the provided parameters and options.
type RoleMenu ¶
Role permissions for RBAC
func (*RoleMenu) DeleteByMenuID ¶
Deletes role menus by menu id.
func (*RoleMenu) DeleteByRoleID ¶
Deletes role menus by role id.
func (*RoleMenu) ExistsRoleIDMenuID ¶
func (*RoleMenu) Get ¶
func (a *RoleMenu) Get(ctx context.Context, id string, opts ...schema.RoleMenuQueryOptions) (*schema.RoleMenu, error)
Get the specified role menu from the database.
func (*RoleMenu) Query ¶
func (a *RoleMenu) Query(ctx context.Context, params schema.RoleMenuQueryParam, opts ...schema.RoleMenuQueryOptions) (*schema.RoleMenuQueryResult, error)
Query role menus from the database based on the provided parameters and options.
type Tenant ¶
Tenant management for RBAC
func (*Tenant) ExistsCode ¶
func (*Tenant) Get ¶
func (a *Tenant) Get(ctx context.Context, id string, opts ...schema.TenantQueryOptions) (*schema.Tenant, error)
Get the specified tenant from the database.
func (*Tenant) Query ¶
func (a *Tenant) Query(ctx context.Context, params schema.TenantQueryParam, opts ...schema.TenantQueryOptions) (*schema.TenantQueryResult, error)
Query tenants from the database based on the provided parameters and options.
type TenantEndpoint ¶
TenantEndpoint RBAC 模块下的租户-端点关联数据访问层
func (*TenantEndpoint) CreateInBatches ¶
func (a *TenantEndpoint) CreateInBatches(ctx context.Context, tx *gorm.DB, items []*schema.TenantEndpoint) error
CreateInBatches 在事务中批量插入端点白名单关联
func (*TenantEndpoint) DeleteByTenantAndModel ¶
func (a *TenantEndpoint) DeleteByTenantAndModel(ctx context.Context, tx *gorm.DB, tenantCode, modelID string) error
DeleteByTenantAndModel 在事务中删除指定租户及模型关联的全部端点白名单。 采用两步执行(先查端点 ID,再用字面量 IN 列表删除)替代 DML 内子查询, 规避 Vitess "subqueries in sharded DML" 限制(Error 1235)。
func (*TenantEndpoint) QueryEndpointIDsByModel ¶
func (a *TenantEndpoint) QueryEndpointIDsByModel(ctx context.Context, tx *gorm.DB, modelID string) ([]string, error)
QueryEndpointIDsByModel 查询指定模型下所有未删除的端点 ID 列表(单表查询)。 单表 SELECT 对 Vitess 分片环境友好,供按模型范围清理/过滤场景复用。
func (*TenantEndpoint) QueryEndpointIDsByTenantAndModel ¶
func (a *TenantEndpoint) QueryEndpointIDsByTenantAndModel(ctx context.Context, tenantCode, modelID string) ([]string, error)
QueryEndpointIDsByTenantAndModel 查询指定租户及模型下已授权的端点 ID 列表。 采用两步查询替代跨表 JOIN:先按模型查出端点 ID,再在租户关联表中按字面量 IN 过滤, 避免 Vitess 分片环境下的跨表 JOIN scatter 风险。
type TenantModel ¶
TenantModel management for RBAC
func (*TenantModel) CreateInBatches ¶
func (a *TenantModel) CreateInBatches(ctx context.Context, tx *gorm.DB, items []*schema.TenantModel) error
CreateInBatches inserts a list of bindings inside a transaction.
func (*TenantModel) DeleteByTenantCode ¶
DeleteByTenantCode deletes all bindings of a tenant inside a transaction.
func (*TenantModel) QueryByTenantCode ¶
func (a *TenantModel) QueryByTenantCode(ctx context.Context, tenantCode string) ([]*schema.TenantModel, error)
QueryByTenantCode queries all models associated with the specified tenant.
type User ¶
User management for RBAC
func (*User) ExistsUsername ¶
func (*User) Get ¶
func (a *User) Get(ctx context.Context, id string, opts ...schema.UserQueryOptions) (*schema.User, error)
Get the specified user from the database.
func (*User) GetByEmail ¶
func (*User) GetByUsername ¶
func (*User) Query ¶
func (a *User) Query(ctx context.Context, params schema.UserQueryParam, opts ...schema.UserQueryOptions) (*schema.UserQueryResult, error)
Query users from the database based on the provided parameters and options.
type UserAPIKey ¶
UserAPIKey 用户 API Key 的数据持久层结构体
func (*UserAPIKey) Create ¶
func (a *UserAPIKey) Create(ctx context.Context, item *schema.UserAPIKey) error
Create 新增一条记录
func (*UserAPIKey) Delete ¶
func (a *UserAPIKey) Delete(ctx context.Context, id string) error
Delete 逻辑删除记录
func (*UserAPIKey) ExistsAPIKey ¶
ExistsAPIKey 检查 API Key 字符串是否已存在(避免生成重复的 Key)
func (*UserAPIKey) Get ¶
func (a *UserAPIKey) Get(ctx context.Context, id string, opts ...schema.UserAPIKeyQueryOptions) (*schema.UserAPIKey, error)
Get 根据 ID 获取单条 API Key
func (*UserAPIKey) GetByAPIKey ¶
func (a *UserAPIKey) GetByAPIKey(ctx context.Context, apiKey string, opts ...schema.UserAPIKeyQueryOptions) (*schema.UserAPIKey, error)
GetByAPIKey 根据实际的 API Key 字符串获取对应的信息(供精确匹配或校验使用)
func (*UserAPIKey) Query ¶
func (a *UserAPIKey) Query(ctx context.Context, params schema.UserAPIKeyQueryParam, opts ...schema.UserAPIKeyQueryOptions) (*schema.UserAPIKeyQueryResult, error)
Query 分页查询用户 API Key
func (*UserAPIKey) Update ¶
func (a *UserAPIKey) Update(ctx context.Context, item *schema.UserAPIKey, selectFields ...string) error
Update 更新记录
type UserRole ¶
User roles for RBAC
func (*UserRole) DeleteByRoleID ¶
func (*UserRole) DeleteByUserID ¶
func (*UserRole) Get ¶
func (a *UserRole) Get(ctx context.Context, id string, opts ...schema.UserRoleQueryOptions) (*schema.UserRole, error)
Get the specified user role from the database.
func (*UserRole) Query ¶
func (a *UserRole) Query(ctx context.Context, params schema.UserRoleQueryParam, opts ...schema.UserRoleQueryOptions) (*schema.UserRoleQueryResult, error)
Query user roles from the database based on the provided parameters and options.