refactor: Update tenant ID handling across the application

This commit is contained in:
wizardchen
2025-11-25 16:30:54 +08:00
parent 9f6f5f5773
commit 64c44c9e27
78 changed files with 437 additions and 601 deletions
+2 -2
View File
@@ -48,8 +48,8 @@ type ChatManage struct {
MessageID string `json:"-"` // Assistant message ID for event emission
// Web search configuration (internal use)
TenantID uint `json:"-"` // Tenant ID for retrieving web search config
WebSearchEnabled bool `json:"-"` // Whether web search is enabled for this request
TenantID uint64 `json:"-"` // Tenant ID for retrieving web search config
WebSearchEnabled bool `json:"-"` // Whether web search is enabled for this request
}
// Clone creates a deep copy of the ChatManage object
+1 -1
View File
@@ -67,7 +67,7 @@ type Chunk struct {
// Unique identifier of the chunk, using UUID format
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
// Tenant ID, used for multi-tenant isolation
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
// ID of the parent knowledge, associated with the Knowledge model
KnowledgeID string `json:"knowledge_id"`
// ID of the knowledge base, for quick location
+1 -1
View File
@@ -23,7 +23,7 @@ const (
// EvaluationTask contains information about an evaluation task
type EvaluationTask struct {
ID string `json:"id"` // Unique task ID
TenantID uint `json:"tenant_id"` // Tenant/Organization ID
TenantID uint64 `json:"tenant_id"` // Tenant/Organization ID
DatasetID string `json:"dataset_id"` // Dataset ID for evaluation
StartTime time.Time `json:"start_time"` // Task start time
+3 -3
View File
@@ -7,7 +7,7 @@ const (
)
type ExtractChunkPayload struct {
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
ChunkID string `json:"chunk_id"`
ModelID string `json:"model_id"`
}
@@ -15,7 +15,7 @@ type ExtractChunkPayload struct {
// DocumentProcessPayload 文档处理任务payload
type DocumentProcessPayload struct {
RequestId string `json:"request_id"`
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
KnowledgeID string `json:"knowledge_id"`
KnowledgeBaseID string `json:"knowledge_base_id"`
FilePath string `json:"file_path,omitempty"` // 文件路径(文件导入时使用)
@@ -28,7 +28,7 @@ type DocumentProcessPayload struct {
// FAQImportPayload FAQ导入任务payload
type FAQImportPayload struct {
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
TaskID string `json:"task_id"`
KBID string `json:"kb_id"`
KnowledgeID string `json:"knowledge_id"`
+13 -13
View File
@@ -11,40 +11,40 @@ type ChunkRepository interface {
// CreateChunks creates chunks
CreateChunks(ctx context.Context, chunks []*types.Chunk) error
// GetChunkByID gets a chunk by id
GetChunkByID(ctx context.Context, tenantID uint, id string) (*types.Chunk, error)
GetChunkByID(ctx context.Context, tenantID uint64, id string) (*types.Chunk, error)
// ListChunksByID lists chunks by ids
ListChunksByID(ctx context.Context, tenantID uint, ids []string) ([]*types.Chunk, error)
ListChunksByID(ctx context.Context, tenantID uint64, ids []string) ([]*types.Chunk, error)
// ListChunksByKnowledgeID lists chunks by knowledge id
ListChunksByKnowledgeID(ctx context.Context, tenantID uint, knowledgeID string) ([]*types.Chunk, error)
ListChunksByKnowledgeID(ctx context.Context, tenantID uint64, knowledgeID string) ([]*types.Chunk, error)
// ListPagedChunksByKnowledgeID lists paged chunks by knowledge id.
// When tagID is non-empty, results are filtered by tag_id.
ListPagedChunksByKnowledgeID(
ctx context.Context,
tenantID uint,
tenantID uint64,
knowledgeID string,
page *types.Pagination,
chunkType []types.ChunkType,
tagID string,
) ([]*types.Chunk, int64, error)
ListChunkByParentID(ctx context.Context, tenantID uint, parentID string) ([]*types.Chunk, error)
ListChunkByParentID(ctx context.Context, tenantID uint64, parentID string) ([]*types.Chunk, error)
// UpdateChunk updates a chunk
UpdateChunk(ctx context.Context, chunk *types.Chunk) error
// UpdateChunks updates chunks in batch
UpdateChunks(ctx context.Context, chunks []*types.Chunk) error
// DeleteChunk deletes a chunk
DeleteChunk(ctx context.Context, tenantID uint, id string) error
DeleteChunk(ctx context.Context, tenantID uint64, id string) error
// DeleteChunks deletes chunks by IDs in batch
DeleteChunks(ctx context.Context, tenantID uint, ids []string) error
DeleteChunks(ctx context.Context, tenantID uint64, ids []string) error
// DeleteChunksByKnowledgeID deletes chunks by knowledge id
DeleteChunksByKnowledgeID(ctx context.Context, tenantID uint, knowledgeID string) error
DeleteChunksByKnowledgeID(ctx context.Context, tenantID uint64, knowledgeID string) error
// DeleteByKnowledgeList deletes all chunks for a knowledge list
DeleteByKnowledgeList(ctx context.Context, tenantID uint, knowledgeIDs []string) error
DeleteByKnowledgeList(ctx context.Context, tenantID uint64, knowledgeIDs []string) error
// CountChunksByKnowledgeBaseID counts the number of chunks in a knowledge base.
CountChunksByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) (int64, error)
CountChunksByKnowledgeBaseID(ctx context.Context, tenantID uint64, kbID string) (int64, error)
// DeleteUnindexedChunks deletes unindexed chunks by knowledge id and chunk index range
DeleteUnindexedChunks(ctx context.Context, tenantID uint, knowledgeID string) ([]*types.Chunk, error)
DeleteUnindexedChunks(ctx context.Context, tenantID uint64, knowledgeID string) ([]*types.Chunk, error)
// ListAllFAQChunksByKnowledgeID lists all FAQ chunks for a knowledge ID (only ID and ContentHash fields for efficiency)
ListAllFAQChunksByKnowledgeID(ctx context.Context, tenantID uint, knowledgeID string) ([]*types.Chunk, error)
ListAllFAQChunksByKnowledgeID(ctx context.Context, tenantID uint64, knowledgeID string) ([]*types.Chunk, error)
}
// ChunkService defines the interface for chunk service operations
@@ -75,7 +75,7 @@ type ChunkService interface {
// DeleteByKnowledgeList deletes all chunks for a knowledge list
DeleteByKnowledgeList(ctx context.Context, ids []string) error
// ListChunkByParentID lists chunks by parent id
ListChunkByParentID(ctx context.Context, tenantID uint, parentID string) ([]*types.Chunk, error)
ListChunkByParentID(ctx context.Context, tenantID uint64, parentID string) ([]*types.Chunk, error)
// GetRepository gets the chunk repository
GetRepository() ChunkRepository
}
+1 -1
View File
@@ -10,7 +10,7 @@ import (
// FileService provides methods to save, retrieve, and delete files.
type FileService interface {
// SaveFile saves a file.
SaveFile(ctx context.Context, file *multipart.FileHeader, tenantID uint, knowledgeID string) (string, error)
SaveFile(ctx context.Context, file *multipart.FileHeader, tenantID uint64, knowledgeID string) (string, error)
// GetFile retrieves a file.
GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)
// DeleteFile deletes a file.
+11 -11
View File
@@ -31,7 +31,7 @@ type KnowledgeService interface {
// GetKnowledgeByID retrieves knowledge by ID.
GetKnowledgeByID(ctx context.Context, id string) (*types.Knowledge, error)
// GetKnowledgeBatch retrieves a batch of knowledge by IDs.
GetKnowledgeBatch(ctx context.Context, tenantID uint, ids []string) ([]*types.Knowledge, error)
GetKnowledgeBatch(ctx context.Context, tenantID uint64, ids []string) ([]*types.Knowledge, error)
// ListKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base.
ListKnowledgeByKnowledgeBaseID(ctx context.Context, kbID string) ([]*types.Knowledge, error)
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base with pagination.
@@ -83,34 +83,34 @@ type KnowledgeService interface {
// KnowledgeRepository defines the interface for knowledge repositories.
type KnowledgeRepository interface {
CreateKnowledge(ctx context.Context, knowledge *types.Knowledge) error
GetKnowledgeByID(ctx context.Context, tenantID uint, id string) (*types.Knowledge, error)
ListKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) ([]*types.Knowledge, error)
GetKnowledgeByID(ctx context.Context, tenantID uint64, id string) (*types.Knowledge, error)
ListKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint64, kbID string) ([]*types.Knowledge, error)
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge in a knowledge base with pagination.
// When tagID is non-empty, results are filtered by tag_id.
ListPagedKnowledgeByKnowledgeBaseID(ctx context.Context,
tenantID uint, kbID string, page *types.Pagination, tagID string,
tenantID uint64, kbID string, page *types.Pagination, tagID string,
) ([]*types.Knowledge, int64, error)
UpdateKnowledge(ctx context.Context, knowledge *types.Knowledge) error
// UpdateKnowledgeBatch updates knowledge items in batch
UpdateKnowledgeBatch(ctx context.Context, knowledgeList []*types.Knowledge) error
DeleteKnowledge(ctx context.Context, tenantID uint, id string) error
DeleteKnowledgeList(ctx context.Context, tenantID uint, ids []string) error
GetKnowledgeBatch(ctx context.Context, tenantID uint, ids []string) ([]*types.Knowledge, error)
DeleteKnowledge(ctx context.Context, tenantID uint64, id string) error
DeleteKnowledgeList(ctx context.Context, tenantID uint64, ids []string) error
GetKnowledgeBatch(ctx context.Context, tenantID uint64, ids []string) ([]*types.Knowledge, error)
// CheckKnowledgeExists checks if knowledge already exists.
// For file types, check by fileHash or (fileName+fileSize).
// For URL types, check by URL.
// Returns whether it exists, the existing knowledge object (if any), and possible error.
CheckKnowledgeExists(
ctx context.Context,
tenantID uint,
tenantID uint64,
kbID string,
params *types.KnowledgeCheckParams,
) (bool, *types.Knowledge, error)
// AminusB returns the difference set of A and B.
AminusB(ctx context.Context, Atenant uint, A string, Btenant uint, B string) ([]string, error)
AminusB(ctx context.Context, Atenant uint64, A string, Btenant uint64, B string) ([]string, error)
UpdateKnowledgeColumn(ctx context.Context, id string, column string, value interface{}) error
// CountKnowledgeByKnowledgeBaseID counts the number of knowledge items in a knowledge base.
CountKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) (int64, error)
CountKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint64, kbID string) (int64, error)
// CountKnowledgeByStatus counts the number of knowledge items with the specified parse status.
CountKnowledgeByStatus(ctx context.Context, tenantID uint, kbID string, parseStatuses []string) (int64, error)
CountKnowledgeByStatus(ctx context.Context, tenantID uint64, kbID string, parseStatuses []string) (int64, error)
}
+1 -1
View File
@@ -126,7 +126,7 @@ type KnowledgeBaseRepository interface {
// Returns:
// - List of knowledge base objects
// - Possible errors such as database errors, etc.
ListKnowledgeBasesByTenantID(ctx context.Context, tenantID uint) ([]*types.KnowledgeBase, error)
ListKnowledgeBasesByTenantID(ctx context.Context, tenantID uint64) ([]*types.KnowledgeBase, error)
// UpdateKnowledgeBase updates a knowledge base record
// Parameters:
+12 -13
View File
@@ -12,22 +12,22 @@ type MCPServiceRepository interface {
Create(ctx context.Context, service *types.MCPService) error
// GetByID retrieves an MCP service by ID and tenant ID
GetByID(ctx context.Context, tenantID uint, id string) (*types.MCPService, error)
GetByID(ctx context.Context, tenantID uint64, id string) (*types.MCPService, error)
// List retrieves all MCP services for a tenant
List(ctx context.Context, tenantID uint) ([]*types.MCPService, error)
List(ctx context.Context, tenantID uint64) ([]*types.MCPService, error)
// ListEnabled retrieves all enabled MCP services for a tenant
ListEnabled(ctx context.Context, tenantID uint) ([]*types.MCPService, error)
ListEnabled(ctx context.Context, tenantID uint64) ([]*types.MCPService, error)
// ListByIDs retrieves MCP services by multiple IDs for a tenant
ListByIDs(ctx context.Context, tenantID uint, ids []string) ([]*types.MCPService, error)
ListByIDs(ctx context.Context, tenantID uint64, ids []string) ([]*types.MCPService, error)
// Update updates an MCP service
Update(ctx context.Context, service *types.MCPService) error
// Delete deletes an MCP service (soft delete)
Delete(ctx context.Context, tenantID uint, id string) error
Delete(ctx context.Context, tenantID uint64, id string) error
}
// MCPServiceService defines the interface for MCP service business logic
@@ -36,27 +36,26 @@ type MCPServiceService interface {
CreateMCPService(ctx context.Context, service *types.MCPService) error
// GetMCPServiceByID retrieves an MCP service by ID
GetMCPServiceByID(ctx context.Context, tenantID uint, id string) (*types.MCPService, error)
GetMCPServiceByID(ctx context.Context, tenantID uint64, id string) (*types.MCPService, error)
// ListMCPServices lists all MCP services for a tenant
ListMCPServices(ctx context.Context, tenantID uint) ([]*types.MCPService, error)
ListMCPServices(ctx context.Context, tenantID uint64) ([]*types.MCPService, error)
// ListMCPServicesByIDs retrieves multiple MCP services by IDs
ListMCPServicesByIDs(ctx context.Context, tenantID uint, ids []string) ([]*types.MCPService, error)
ListMCPServicesByIDs(ctx context.Context, tenantID uint64, ids []string) ([]*types.MCPService, error)
// UpdateMCPService updates an MCP service
UpdateMCPService(ctx context.Context, service *types.MCPService) error
// DeleteMCPService deletes an MCP service
DeleteMCPService(ctx context.Context, tenantID uint, id string) error
DeleteMCPService(ctx context.Context, tenantID uint64, id string) error
// TestMCPService tests the connection to an MCP service and returns available tools/resources
TestMCPService(ctx context.Context, tenantID uint, id string) (*types.MCPTestResult, error)
TestMCPService(ctx context.Context, tenantID uint64, id string) (*types.MCPTestResult, error)
// GetMCPServiceTools retrieves the list of tools from an MCP service
GetMCPServiceTools(ctx context.Context, tenantID uint, id string) ([]*types.MCPTool, error)
GetMCPServiceTools(ctx context.Context, tenantID uint64, id string) ([]*types.MCPTool, error)
// GetMCPServiceResources retrieves the list of resources from an MCP service
GetMCPServiceResources(ctx context.Context, tenantID uint, id string) ([]*types.MCPResource, error)
GetMCPServiceResources(ctx context.Context, tenantID uint64, id string) ([]*types.MCPResource, error)
}
+3 -3
View File
@@ -34,18 +34,18 @@ type ModelRepository interface {
// Create creates a model
Create(ctx context.Context, model *types.Model) error
// GetByID gets a model by ID
GetByID(ctx context.Context, tenantID uint, id string) (*types.Model, error)
GetByID(ctx context.Context, tenantID uint64, id string) (*types.Model, error)
// List lists all models
List(
ctx context.Context,
tenantID uint,
tenantID uint64,
modelType types.ModelType,
source types.ModelSource,
) ([]*types.Model, error)
// Update updates a model
Update(ctx context.Context, model *types.Model) error
// Delete deletes a model
Delete(ctx context.Context, tenantID uint, id string) error
Delete(ctx context.Context, tenantID uint64, id string) error
// ClearDefaultByType clears the default flag for all models of a specific type, optionally excluding a specific model ID
ClearDefaultByType(ctx context.Context, tenantID uint, modelType types.ModelType, excludeID string) error
}
+4 -4
View File
@@ -56,13 +56,13 @@ type SessionRepository interface {
// Create creates a session
Create(ctx context.Context, session *types.Session) (*types.Session, error)
// Get gets a session
Get(ctx context.Context, tenantID uint, id string) (*types.Session, error)
Get(ctx context.Context, tenantID uint64, id string) (*types.Session, error)
// GetByTenantID gets all sessions of a tenant
GetByTenantID(ctx context.Context, tenantID uint) ([]*types.Session, error)
GetByTenantID(ctx context.Context, tenantID uint64) ([]*types.Session, error)
// GetPagedByTenantID gets paged sessions of a tenant
GetPagedByTenantID(ctx context.Context, tenantID uint, page *types.Pagination) ([]*types.Session, int64, error)
GetPagedByTenantID(ctx context.Context, tenantID uint64, page *types.Pagination) ([]*types.Session, int64, error)
// Update updates a session
Update(ctx context.Context, session *types.Session) error
// Delete deletes a session
Delete(ctx context.Context, tenantID uint, id string) error
Delete(ctx context.Context, tenantID uint64, id string) error
}
+4 -4
View File
@@ -22,9 +22,9 @@ type KnowledgeTagService interface {
type KnowledgeTagRepository interface {
Create(ctx context.Context, tag *types.KnowledgeTag) error
Update(ctx context.Context, tag *types.KnowledgeTag) error
GetByID(ctx context.Context, tenantID uint, id string) (*types.KnowledgeTag, error)
ListByKB(ctx context.Context, tenantID uint, kbID string) ([]*types.KnowledgeTag, error)
Delete(ctx context.Context, tenantID uint, id string) error
GetByID(ctx context.Context, tenantID uint64, id string) (*types.KnowledgeTag, error)
ListByKB(ctx context.Context, tenantID uint64, kbID string) ([]*types.KnowledgeTag, error)
Delete(ctx context.Context, tenantID uint64, id string) error
// CountReferences returns number of knowledges and chunks that reference the tag.
CountReferences(ctx context.Context, tenantID uint, kbID string, tagID string) (knowledgeCount int64, chunkCount int64, err error)
CountReferences(ctx context.Context, tenantID uint64, kbID string, tagID string) (knowledgeCount int64, chunkCount int64, err error)
}
+7 -7
View File
@@ -11,17 +11,17 @@ type TenantService interface {
// CreateTenant creates a tenant
CreateTenant(ctx context.Context, tenant *types.Tenant) (*types.Tenant, error)
// GetTenantByID gets a tenant by ID
GetTenantByID(ctx context.Context, id uint) (*types.Tenant, error)
GetTenantByID(ctx context.Context, id uint64) (*types.Tenant, error)
// ListTenants lists all tenants
ListTenants(ctx context.Context) ([]*types.Tenant, error)
// UpdateTenant updates a tenant
UpdateTenant(ctx context.Context, tenant *types.Tenant) (*types.Tenant, error)
// DeleteTenant deletes a tenant
DeleteTenant(ctx context.Context, id uint) error
DeleteTenant(ctx context.Context, id uint64) error
// UpdateAPIKey updates the API key
UpdateAPIKey(ctx context.Context, id uint) (string, error)
UpdateAPIKey(ctx context.Context, id uint64) (string, error)
// ExtractTenantIDFromAPIKey extracts the tenant ID from the API key
ExtractTenantIDFromAPIKey(apiKey string) (uint, error)
ExtractTenantIDFromAPIKey(apiKey string) (uint64, error)
}
// TenantRepository defines the tenant repository interface
@@ -29,13 +29,13 @@ type TenantRepository interface {
// CreateTenant creates a tenant
CreateTenant(ctx context.Context, tenant *types.Tenant) error
// GetTenantByID gets a tenant by ID
GetTenantByID(ctx context.Context, id uint) (*types.Tenant, error)
GetTenantByID(ctx context.Context, id uint64) (*types.Tenant, error)
// ListTenants lists all tenants
ListTenants(ctx context.Context) ([]*types.Tenant, error)
// UpdateTenant updates a tenant
UpdateTenant(ctx context.Context, tenant *types.Tenant) error
// DeleteTenant deletes a tenant
DeleteTenant(ctx context.Context, id uint) error
DeleteTenant(ctx context.Context, id uint64) error
// AdjustStorageUsed adjusts the storage used for a tenant
AdjustStorageUsed(ctx context.Context, tenantID uint, delta int64) error
AdjustStorageUsed(ctx context.Context, tenantID uint64, delta int64) error
}
+1 -1
View File
@@ -27,7 +27,7 @@ type Knowledge struct {
// Unique identifier of the knowledge
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
// Tenant ID
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
// ID of the knowledge base
KnowledgeBaseID string `json:"knowledge_base_id"`
// Optional tag ID for categorization within a knowledge base
+1 -1
View File
@@ -46,7 +46,7 @@ type KnowledgeBase struct {
// Description of the knowledge base
Description string `yaml:"description" json:"description"`
// Tenant ID
TenantID uint `yaml:"tenant_id" json:"tenant_id"`
TenantID uint64 `yaml:"tenant_id" json:"tenant_id"`
// Chunking configuration
ChunkingConfig ChunkingConfig `yaml:"chunking_config" json:"chunking_config" gorm:"type:json"`
// Image processing configuration
+1 -1
View File
@@ -21,7 +21,7 @@ const (
// MCPService represents an MCP (Model Context Protocol) service configuration
type MCPService struct {
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
TenantID uint `json:"tenant_id" gorm:"index"`
TenantID uint64 `json:"tenant_id" gorm:"index"`
Name string `json:"name" gorm:"type:varchar(255);not null"`
Description string `json:"description" gorm:"type:text"`
Enabled bool `json:"enabled" gorm:"default:true;index"`
+1 -1
View File
@@ -54,7 +54,7 @@ type Model struct {
// Unique identifier of the model
ID string `yaml:"id" json:"id" gorm:"type:varchar(36);primaryKey"`
// Tenant ID
TenantID uint `yaml:"tenant_id" json:"tenant_id"`
TenantID uint64 `yaml:"tenant_id" json:"tenant_id"`
// Name of the model
Name string `yaml:"name" json:"name"`
// Type of the model
+3 -3
View File
@@ -77,7 +77,7 @@ type Session struct {
// Description
Description string `json:"description"`
// Tenant ID
TenantID uint `json:"tenant_id" gorm:"index"`
TenantID uint64 `json:"tenant_id" gorm:"index"`
// Strategy configuration
KnowledgeBaseID string `json:"knowledge_base_id"` // 关联的知识库ID
@@ -93,8 +93,8 @@ type Session struct {
RerankThreshold float64 `json:"rerank_threshold"` // 排序阈值
SummaryModelID string `json:"summary_model_id"` // 总结模型ID
SummaryParameters *SummaryConfig `json:"summary_parameters" gorm:"type:json"` // 总结模型参数
AgentConfig *SessionAgentConfig `json:"agent_config" gorm:"type:jsonb"` // Agent 配置(会话级别,仅存储enabled和knowledge_bases)
ContextConfig *ContextConfig `json:"context_config" gorm:"type:jsonb"` // 上下文管理配置(可选)
AgentConfig *SessionAgentConfig `json:"agent_config" gorm:"type:jsonb"` // Agent 配置(会话级别,仅存储enabled和knowledge_bases)
ContextConfig *ContextConfig `json:"context_config" gorm:"type:jsonb"` // 上下文管理配置(可选)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
+1 -1
View File
@@ -9,7 +9,7 @@ type KnowledgeTag struct {
// Unique identifier of the tag (UUID)
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
// Tenant ID
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
// Knowledge base ID that this tag belongs to
KnowledgeBaseID string `json:"knowledge_base_id" gorm:"type:varchar(36);index"`
// Tag name, unique within the same knowledge base
+1 -1
View File
@@ -11,7 +11,7 @@ import (
// Tenant represents the tenant
type Tenant struct {
// ID
ID uint `yaml:"id" json:"id" gorm:"primaryKey"`
ID uint64 `yaml:"id" json:"id" gorm:"primaryKey"`
// Name
Name string `yaml:"name" json:"name"`
// Description
+2 -2
View File
@@ -19,7 +19,7 @@ type User struct {
// Avatar URL of the user
Avatar string `json:"avatar" gorm:"type:varchar(500)"`
// Tenant ID that the user belongs to
TenantID uint `json:"tenant_id" gorm:"index"`
TenantID uint64 `json:"tenant_id" gorm:"index"`
// Whether the user is active
IsActive bool `json:"is_active" gorm:"default:true"`
// Creation time of the user
@@ -93,7 +93,7 @@ type UserInfo struct {
Username string `json:"username"`
Email string `json:"email"`
Avatar string `json:"avatar"`
TenantID uint `json:"tenant_id"`
TenantID uint64 `json:"tenant_id"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`