Documentation
¶
Index ¶
- Constants
- Variables
- func MaskAPIKey(apiKey string) string
- type Captcha
- type ExternalIdentity
- type Logger
- type LoggerQueryOptions
- type LoggerQueryParam
- type LoggerQueryResult
- type Loggers
- type LoginForm
- type LoginToken
- type Menu
- type MenuForm
- type MenuQueryOptions
- type MenuQueryParam
- type MenuQueryResult
- type MenuResource
- type MenuResourceForm
- type MenuResourceQueryOptions
- type MenuResourceQueryParam
- type MenuResourceQueryResult
- type MenuResources
- type Menus
- type OAuthExchangeForm
- type OAuthProfile
- type OAuthProvider
- type OAuthResolveResult
- type RefreshTokenForm
- type Role
- type RoleForm
- type RoleMenu
- type RoleMenuForm
- type RoleMenuQueryOptions
- type RoleMenuQueryParam
- type RoleMenuQueryResult
- type RoleMenus
- type RoleQueryOptions
- type RoleQueryParam
- type RoleQueryResult
- type Roles
- type Tenant
- type TenantEndpoint
- type TenantEndpointForm
- type TenantForm
- type TenantModel
- type TenantModelForm
- type TenantQueryOptions
- type TenantQueryParam
- type TenantQueryResult
- type Tenants
- type UpdateCurrentUser
- type UpdateLoginPassword
- type User
- type UserAPIKey
- type UserAPIKeyForm
- type UserAPIKeyQueryOptions
- type UserAPIKeyQueryParam
- type UserAPIKeyQueryResult
- type UserAPIKeys
- type UserForm
- type UserQueryOptions
- type UserQueryParam
- type UserQueryResult
- type UserRole
- type UserRoleForm
- type UserRoleQueryOptions
- type UserRoleQueryParam
- type UserRoleQueryResult
- type UserRoles
- type Users
Constants ¶
const ( MenuStatusDisabled = "disabled" MenuStatusEnabled = "enabled" )
const ( OAuthProviderGoogle = "google" OAuthProviderGitHub = "github" )
const ( RoleStatusEnabled = "enabled" // Enabled RoleStatusDisabled = "disabled" // Disabled RoleResultTypeSelect = "select" // Select )
const ( TenantStatusActivated = "activated" TenantStatusFreezed = "freezed" )
const ( UserStatusActivated = "activated" UserStatusFreezed = "freezed" )
Variables ¶
var ( MenusOrderParams = []util.OrderByParam{ {Field: "sequence", Direction: util.DESC}, {Field: "created_at", Direction: util.DESC}, } )
Functions ¶
Types ¶
type ExternalIdentity ¶
type ExternalIdentity struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
UserID string `json:"user_id" gorm:"type:varchar(20);not null;index:idx_external_identity_user_id;comment:用户ID;"`
Provider string `` /* 133-byte string literal not displayed */
ProviderUserID string `` /* 150-byte string literal not displayed */
Email string `json:"email" gorm:"type:varchar(128);default:null;index:idx_external_identity_email;comment:邮箱;"`
EmailVerified bool `json:"email_verified" gorm:"type:boolean;not null;default:false;comment:邮箱是否已验证;"`
DisplayName string `json:"display_name" gorm:"type:varchar(128);default:null;comment:显示名称;"`
AvatarURL string `json:"avatar_url" gorm:"type:varchar(512);default:null;comment:头像地址;"`
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
}
func (*ExternalIdentity) TableName ¶
func (a *ExternalIdentity) TableName() string
type Logger ¶
type Logger struct {
ID string `gorm:"size:20;primaryKey;" json:"id"` // Unique ID
Level string `gorm:"size:20;index;" json:"level"` // Log level
TraceID string `gorm:"size:64;index;" json:"trace_id"` // Trace ID
UserID string `gorm:"size:20;index;" json:"user_id"` // User ID
Tag string `gorm:"size:32;index;" json:"tag"` // Log tag
Message string `gorm:"size:1024;" json:"message"` // Log message
Stack string `gorm:"type:text;" json:"stack"` // Error stack
Data string `gorm:"type:text;" json:"data"` // Log data
CreatedAt time.Time `gorm:"index;" json:"created_at"` // Create time
LoginName string `json:"login_name" gorm:"->;-:migration"` // From User.Username
UserName string `json:"user_name" gorm:"->;-:migration"` // From User.Name
}
Logger management
type LoggerQueryOptions ¶
type LoggerQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `Logger` struct.
type LoggerQueryParam ¶
type LoggerQueryParam struct {
util.PaginationParam
Level string `form:"level"` // Log level
TraceID string `form:"traceID"` // Trace ID
LikeUserName string `form:"userName"` // User Name
Tag string `form:"tag"` // Log tag
LikeMessage string `form:"message"` // Log message
StartTime string `form:"startTime"` // Start time
EndTime string `form:"endTime"` // End time
}
Defining the query parameters for the `Logger` struct.
type LoggerQueryResult ¶
type LoggerQueryResult struct {
Data Loggers
PageResult *util.PaginationResult
}
Defining the query result for the `Logger` struct.
type LoginForm ¶
type LoginForm struct {
Username string `json:"username" binding:"required"` // Login name
Password string `json:"password" binding:"required"` // Login password (md5 hash)
CaptchaID string `json:"captcha_id"` // Captcha verify id (optional when captcha disabled)
CaptchaCode string `json:"captcha_code"` // Captcha verify code (optional when captcha disabled)
RememberMe bool `json:"remember_me"` // Remember login state (30 days)
}
type LoginToken ¶
type LoginToken struct {
AccessToken string `json:"access_token"` // Access token (JWT)
TokenType string `json:"token_type"` // Token type (Usage: Authorization=${token_type} ${access_token})
ExpiresAt int64 `json:"expires_at"` // Expired time (Unit: second)
RefreshToken string `json:"refresh_token"` // Refresh token (only when remember_me=true)
}
type Menu ¶
type Menu struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
Code string `json:"code" gorm:"type:varchar(32);default:null;index:idx_menu_code;comment:菜单编码;"`
Name string `json:"name" gorm:"type:varchar(128);default:null;index:idx_menu_name;comment:菜单名称;"`
Description string `json:"description" gorm:"type:varchar(1024);default:null;comment:描述;"`
Sequence int `json:"sequence" gorm:"type:bigint;default:null;index:idx_menu_sequence;comment:序列;"`
Type string `json:"type" gorm:"type:varchar(20);default:null;index:idx_menu_type;comment:类型: page, button;"`
Path string `json:"path" gorm:"type:varchar(255);default:null;comment:路径;"`
Properties string `json:"properties" gorm:"type:text;comment:属性;"`
Status string `json:"status" gorm:"type:varchar(20);default:null;index:idx_menu_status;comment:状态;"`
ParentID string `json:"parent_id" gorm:"type:varchar(20);default:null;index:idx_menu_parent_id;comment:父ID;"`
ParentPath string `json:"parent_path" gorm:"type:varchar(255);default:null;index:idx_menu_parent_path;comment:父路径;"`
Children *Menus `json:"children" gorm:"-"` // Child menus
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
Resources MenuResources `json:"resources" gorm:"-"` // Resources of menu
}
Menu management for RBAC
type MenuForm ¶
type MenuForm struct {
Code string `json:"code" binding:"required,max=32"` // Code of menu (unique for each level)
Name string `json:"name" binding:"required,max=128"` // Display name of menu
Description string `json:"description"` // Details about menu
Sequence int `json:"sequence"` // Sequence for sorting (Order by desc)
Type string `json:"type" binding:"required,oneof=page button"` // Type of menu (page, button)
Path string `json:"path"` // Access path of menu
Properties string `json:"properties"` // Properties of menu (JSON)
Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of menu (enabled, disabled)
ParentID string `json:"parent_id"` // Parent ID (From Menu.ID)
Resources MenuResources `json:"resources"` // Resources of menu
}
Defining the data structure for creating a `Menu` struct.
type MenuQueryOptions ¶
type MenuQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `Menu` struct.
type MenuQueryParam ¶
type MenuQueryParam struct {
util.PaginationParam
CodePath string `form:"code"` // Code path (like xxx.xxx.xxx)
LikeName string `form:"name"` // Display name of menu
IncludeResources bool `form:"includeResources"` // Include resources
InIDs []string `form:"-"` // Include menu IDs
Status string `form:"-"` // Status of menu (disabled, enabled)
ParentID string `form:"-"` // Parent ID (From Menu.ID)
ParentPathPrefix string `form:"-"` // Parent path (split by .)
UserID string `form:"-"` // User ID
RoleID string `form:"-"` // Role ID
}
Defining the query parameters for the `Menu` struct.
type MenuQueryResult ¶
type MenuQueryResult struct {
Data Menus
PageResult *util.PaginationResult
}
Defining the query result for the `Menu` struct.
type MenuResource ¶
type MenuResource struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
MenuID string `json:"menu_id" gorm:"type:varchar(20);default:null;index:idx_menu_resource_menu_id;comment:菜单ID;"`
Method string `json:"method" gorm:"type:varchar(20);default:null;comment:请求方法;"`
Path string `json:"path" gorm:"type:varchar(255);default:null;comment:请求路径;"`
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
}
Menu resource management for RBAC
func (*MenuResource) TableName ¶
func (a *MenuResource) TableName() string
type MenuResourceForm ¶
type MenuResourceForm struct {
}
Defining the data structure for creating a `MenuResource` struct.
func (*MenuResourceForm) FillTo ¶
func (a *MenuResourceForm) FillTo(menuResource *MenuResource) error
func (*MenuResourceForm) Validate ¶
func (a *MenuResourceForm) Validate() error
A validation function for the `MenuResourceForm` struct.
type MenuResourceQueryOptions ¶
type MenuResourceQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `MenuResource` struct.
type MenuResourceQueryParam ¶
type MenuResourceQueryParam struct {
util.PaginationParam
MenuID string `form:"-"` // From Menu.ID
MenuIDs []string `form:"-"` // From Menu.ID
}
Defining the query parameters for the `MenuResource` struct.
type MenuResourceQueryResult ¶
type MenuResourceQueryResult struct {
Data MenuResources
PageResult *util.PaginationResult
}
Defining the query result for the `MenuResource` struct.
type MenuResources ¶
type MenuResources []*MenuResource
Defining the slice of `MenuResource` struct.
type OAuthExchangeForm ¶
type OAuthExchangeForm struct {
Ticket string `json:"ticket" binding:"required"`
}
type OAuthProfile ¶
type OAuthProvider ¶
type OAuthResolveResult ¶
type OAuthResolveResult struct {
User *User
Tenant *Tenant
Identity *ExternalIdentity
Created bool
}
type RefreshTokenForm ¶
type RefreshTokenForm struct {
RefreshToken string `json:"refresh_token" binding:"required"` // Refresh token
}
type Role ¶
type Role struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
Code string `json:"code" gorm:"type:varchar(32);default:null;index:idx_role_code;comment:角色编码;"`
Name string `json:"name" gorm:"type:varchar(128);default:null;index:idx_role_name;comment:角色名称;"`
Description string `json:"description" gorm:"type:varchar(1024);default:null;comment:角色描述;"`
Sequence int `json:"sequence" gorm:"type:bigint;default:null;index:idx_role_sequence;comment:角色序列;"`
Tenant string `json:"tenant" gorm:"type:varchar(255);default:null;comment:租户信息;"`
Status string `json:"status" gorm:"type:varchar(20);default:null;index:idx_role_status;comment:状态;"`
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
Menus RoleMenus `json:"menus" gorm:"-"` // Role menu list
}
Role management for RBAC
type RoleForm ¶
type RoleForm struct {
Code string `json:"code" binding:"required,max=32"` // Code of role (unique)
Name string `json:"name" binding:"required,max=128"` // Display name of role
Description string `json:"description"` // Details about role
Sequence int `json:"sequence"` // Sequence for sorting
Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of role (enabled, disabled)
Menus RoleMenus `json:"menus"` // Role menu list
}
Defining the data structure for creating a `Role` struct.
type RoleMenu ¶
type RoleMenu struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
RoleID string `json:"role_id" gorm:"type:varchar(20);default:null;index:idx_role_menu_role_id;comment:角色ID;"`
MenuID string `json:"menu_id" gorm:"type:varchar(20);default:null;index:idx_role_menu_menu_id;comment:菜单ID;"`
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
}
Role permissions for RBAC
type RoleMenuForm ¶
type RoleMenuForm struct {
}
Defining the data structure for creating a `RoleMenu` struct.
func (*RoleMenuForm) FillTo ¶
func (a *RoleMenuForm) FillTo(roleMenu *RoleMenu) error
func (*RoleMenuForm) Validate ¶
func (a *RoleMenuForm) Validate() error
A validation function for the `RoleMenuForm` struct.
type RoleMenuQueryOptions ¶
type RoleMenuQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `RoleMenu` struct.
type RoleMenuQueryParam ¶
type RoleMenuQueryParam struct {
util.PaginationParam
RoleID string `form:"-"` // From Role.ID
MenuID string `form:"-"` // From Menu.ID
}
Defining the query parameters for the `RoleMenu` struct.
type RoleMenuQueryResult ¶
type RoleMenuQueryResult struct {
Data RoleMenus
PageResult *util.PaginationResult
}
Defining the query result for the `RoleMenu` struct.
type RoleQueryOptions ¶
type RoleQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `Role` struct.
type RoleQueryParam ¶
type RoleQueryParam struct {
util.PaginationParam
LikeName string `form:"name"` // Display name of role
Status string `form:"status" binding:"oneof=disabled enabled ''"` // Status of role (disabled, enabled)
ResultType string `form:"resultType"` // Result type (options: select)
InIDs []string `form:"-"` // ID list
GtUpdatedAt *time.Time `form:"-"` // Update time is greater than
}
Defining the query parameters for the `Role` struct.
type RoleQueryResult ¶
type RoleQueryResult struct {
Data Roles
PageResult *util.PaginationResult
}
Defining the query result for the `Role` struct.
type Tenant ¶
type Tenant struct {
ID string `json:"id" gorm:"type:char(20);primaryKey;comment:主键ID (XID);"`
Code string `` /* 152-byte string literal not displayed */
Name string `json:"name" gorm:"type:varchar(128);not null;comment:租户名称,如 默认租户、演示组织;"`
Status string `json:"status" gorm:"type:varchar(20);not null;default:activated;comment:状态: activated-启用, freezed-冻结;"`
Description string `json:"description" gorm:"type:varchar(255);default:null;comment:备注描述;"`
APIKey string `` /* 126-byte string literal not displayed */
Creator string `json:"creator" gorm:"type:varchar(255);default:null;comment:创建者;"`
Modifier string `json:"modifier" gorm:"type:varchar(255);default:null;comment:修改者;"`
CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;not null;default:CURRENT_TIMESTAMP;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime;comment:更新时间;"`
Deleted string `` /* 129-byte string literal not displayed */
DeletedAt *time.Time `json:"-" gorm:"type:datetime;default:null;comment:逻辑删除时间;"`
}
Tenant management for multi-tenancy
type TenantEndpoint ¶
type TenantEndpoint struct {
ID string `json:"id" gorm:"type:char(20);primaryKey;comment:主键ID (XID);"`
TenantCode string `` /* 175-byte string literal not displayed */
EndpointID string `` /* 156-byte string literal not displayed */
Creator string `json:"creator" gorm:"type:varchar(255);default:null;comment:创建者;"`
CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;not null;default:CURRENT_TIMESTAMP;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime;comment:更新时间;"`
}
TenantEndpoint 租户-端点关联表
func (TenantEndpoint) TableName ¶
func (TenantEndpoint) TableName() string
type TenantEndpointForm ¶
type TenantEndpointForm struct {
TenantCode string `json:"tenant_code" binding:"required"`
ModelID string `json:"model_id" binding:"required"`
EndpointIDs []string `json:"endpoint_ids"` // 允许的端点 ID 列表,空表示不限制(全放通)
}
TenantEndpointForm 保存租户端点白名单表单
type TenantForm ¶
type TenantForm struct {
Code string `json:"code" binding:"required,max=64"` // Code
Name string `json:"name" binding:"required,max=128"` // Name
Status string `json:"status" binding:"required,oneof=activated freezed"` // Status (activated, freezed)
Description string `json:"description" binding:"max=255"` // Description
APIKey string `json:"api_key" binding:"max=128"` // Tenant API Key
}
TenantForm defines the data structure for creating/updating a Tenant.
func (*TenantForm) FillTo ¶
func (a *TenantForm) FillTo(tenant *Tenant) error
func (*TenantForm) Validate ¶
func (a *TenantForm) Validate() error
type TenantModel ¶
type TenantModel struct {
ID string `json:"id" gorm:"type:char(20);primaryKey;comment:主键ID (XID);"`
TenantCode string `` /* 182-byte string literal not displayed */
ModelID string `` /* 154-byte string literal not displayed */
Creator string `json:"creator" gorm:"type:varchar(255);default:null;comment:创建者;"`
CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;not null;default:CURRENT_TIMESTAMP;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime;comment:更新时间;"`
}
TenantModel represents the multi-to-multi association between Tenant and Model
func (TenantModel) TableName ¶
func (TenantModel) TableName() string
type TenantModelForm ¶
type TenantModelForm struct {
TenantCode string `json:"tenant_code" binding:"required"`
ModelIDs []string `json:"model_ids"`
}
TenantModelForm defines the data structure for batch binding tenant models.
type TenantQueryOptions ¶
type TenantQueryOptions struct {
util.QueryOptions
}
TenantQueryOptions defines the query options for Tenant.
type TenantQueryParam ¶
type TenantQueryParam struct {
util.PaginationParam
LikeCode string `form:"code"` // Code (like)
LikeName string `form:"name"` // Name (like)
Status string `form:"status" binding:"oneof=activated freezed ''"` // Status
}
TenantQueryParam defines the query parameters for Tenant.
type TenantQueryResult ¶
type TenantQueryResult struct {
Data Tenants
PageResult *util.PaginationResult
}
TenantQueryResult defines the query result for Tenant.
type UpdateCurrentUser ¶
type UpdateCurrentUser struct {
Name string `json:"name" binding:"required,max=64"` // Name of user
Phone string `json:"phone" binding:"max=32"` // Phone number of user
Email string `json:"email" binding:"max=128"` // Email of user
Remark string `json:"remark" binding:"max=1024"` // Remark of user
}
type UpdateLoginPassword ¶
type User ¶
type User struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
Username string `json:"username" gorm:"type:varchar(64);default:null;index:idx_user_username;comment:用户名;"`
Name string `json:"name" gorm:"type:varchar(64);default:null;index:idx_user_name;comment:用户名称;"`
Password string `json:"-" gorm:"type:varchar(64);default:null;comment:密码;"`
Phone string `json:"phone" gorm:"type:varchar(32);default:null;comment:电话;"`
Email string `json:"email" gorm:"type:varchar(128);default:null;comment:邮件;"`
Remark string `json:"remark" gorm:"type:varchar(1024);default:null;comment:备注;"`
Tenant string `json:"tenant" gorm:"type:varchar(255);default:null;comment:租户信息;"`
Status string `json:"status" gorm:"type:varchar(20);default:null;index:idx_user_status;comment:状态;"`
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
Roles UserRoles `json:"roles" gorm:"-"` // Roles of user
}
User management for RBAC
type UserAPIKey ¶
type UserAPIKey struct {
ID string `json:"id" gorm:"type:char(20);primaryKey;comment:主键ID (XID);"`
UserID string `json:"user_id" gorm:"type:char(20);not null;index:idx_user_id,priority:1;comment:关联的用户 ID;"`
Name string `json:"name" gorm:"type:varchar(64);not null;comment:API Key 友好名称;"`
APIKey string `` /* 129-byte string literal not displayed */
Status int `json:"status" gorm:"type:int;not null;default:1;comment:状态: 1-启用, 2-禁用;"`
Credits int64 `json:"credits" gorm:"type:bigint;not null;default:-1;comment:剩余额度(微元): -1表示无限制;"`
ExpiresAt *time.Time `json:"expires_at" gorm:"type:datetime;default:null;comment:过期时间: NULL表示永不过期;"`
Description string `json:"description" gorm:"type:varchar(255);default:null;comment:备注描述;"`
Creator string `json:"creator" gorm:"type:varchar(255);default:null;comment:创建者;"`
Modifier string `json:"modifier" gorm:"type:varchar(255);default:null;comment:修改者;"`
CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;not null;default:CURRENT_TIMESTAMP;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime;comment:更新时间;"`
Deleted string `` /* 160-byte string literal not displayed */
DeletedAt *time.Time `json:"deleted_at" gorm:"type:datetime;default:null;comment:逻辑删除时间;"`
}
UserAPIKey 用户 API Key 结构体
type UserAPIKeyForm ¶
type UserAPIKeyForm struct {
UserID string `json:"user_id" binding:"required,max=20"` // 关联的用户 ID
Name string `json:"name" binding:"required,max=64"` // API Key 友好名称
Status int `json:"status" binding:"required,oneof=1 2"` // 状态: 1-启用, 2-禁用
Credits int64 `json:"credits"` // 剩余额度(微元): -1表示无限制
ExpiresAt *time.Time `json:"expires_at"` // 过期时间
Description string `json:"description" binding:"max=255"` // 描述信息
}
UserAPIKeyForm 定义创建与修改 API Key 的表单数据结构
func (*UserAPIKeyForm) FillTo ¶
func (a *UserAPIKeyForm) FillTo(apiKey *UserAPIKey)
FillTo 将表单数据填充到 GORM 模型中
type UserAPIKeyQueryOptions ¶
type UserAPIKeyQueryOptions struct {
util.QueryOptions
}
UserAPIKeyQueryOptions 定义查询可选项
type UserAPIKeyQueryParam ¶
type UserAPIKeyQueryParam struct {
util.PaginationParam
UserID string `form:"user_id"` // 按用户ID过滤
LikeName string `form:"name"` // 按友好名称模糊搜索
Status int `form:"status"` // 按启用/禁用状态过滤
}
UserAPIKeyQueryParam 定义 API Key 查询参数
type UserAPIKeyQueryResult ¶
type UserAPIKeyQueryResult struct {
Data UserAPIKeys
PageResult *util.PaginationResult
}
UserAPIKeyQueryResult 定义查询结果结构体
type UserForm ¶
type UserForm struct {
Username string `json:"username" binding:"required,max=64"` // Username for login
Name string `json:"name" binding:"required,max=64"` // Name of user
Password string `json:"password" binding:"max=64"` // Password for login (md5 hash)
Phone string `json:"phone" binding:"max=32"` // Phone number of user
Email string `json:"email" binding:"max=128"` // Email of user
Remark string `json:"remark" binding:"max=1024"` // Remark of user
Tenant string `json:"tenant" binding:"max=255"` // Tenant
Status string `json:"status" binding:"required,oneof=activated freezed"` // Status of user (activated, freezed)
Roles UserRoles `json:"roles" binding:"required"` // Roles of user
}
Defining the data structure for creating a `User` struct.
type UserQueryOptions ¶
type UserQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `User` struct.
type UserQueryParam ¶
type UserQueryParam struct {
util.PaginationParam
LikeUsername string `form:"username"` // Username for login
LikeName string `form:"name"` // Name of user
Tenant string `form:"tenant"` // Tenant
Status string `form:"status" binding:"oneof=activated freezed ''"` // Status of user (activated, freezed)
}
Defining the query parameters for the `User` struct.
type UserQueryResult ¶
type UserQueryResult struct {
Data Users
PageResult *util.PaginationResult
}
Defining the query result for the `User` struct.
type UserRole ¶
type UserRole struct {
ID string `json:"id" gorm:"type:varchar(20);primaryKey;comment:ID;"`
UserID string `json:"user_id" gorm:"type:varchar(20);default:null;index:idx_user_role_user_id;comment:用户ID;"`
RoleID string `json:"role_id" gorm:"type:varchar(20);default:null;index:idx_user_role_role_id;comment:角色ID;"`
CreatedAt time.Time `json:"created_at" gorm:"type:datetime;default:null;autoCreateTime;comment:创建时间;"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:datetime;default:null;autoUpdateTime;comment:更新时间;"`
RoleName string `json:"role_name" gorm:"->;-:migration"` // From Role.Name
}
User roles for RBAC
type UserRoleForm ¶
type UserRoleForm struct {
}
Defining the data structure for creating a `UserRole` struct.
func (*UserRoleForm) FillTo ¶
func (a *UserRoleForm) FillTo(userRole *UserRole) error
func (*UserRoleForm) Validate ¶
func (a *UserRoleForm) Validate() error
A validation function for the `UserRoleForm` struct.
type UserRoleQueryOptions ¶
type UserRoleQueryOptions struct {
util.QueryOptions
JoinRole bool // Join role table
}
Defining the query options for the `UserRole` struct.
type UserRoleQueryParam ¶
type UserRoleQueryParam struct {
util.PaginationParam
InUserIDs []string `form:"-"` // From User.ID
UserID string `form:"-"` // From User.ID
RoleID string `form:"-"` // From Role.ID
}
Defining the query parameters for the `UserRole` struct.
type UserRoleQueryResult ¶
type UserRoleQueryResult struct {
Data UserRoles
PageResult *util.PaginationResult
}
Defining the query result for the `UserRole` struct.
type UserRoles ¶
type UserRoles []*UserRole
Defining the slice of `UserRole` struct.