chore: make codes the repository root
This commit is contained in:
186
internal/model/models.go
Normal file
186
internal/model/models.go
Normal file
@@ -0,0 +1,186 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Tenant struct {
|
||||
Base
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
Slug string `json:"slug" gorm:"size:64;not null;uniqueIndex"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Base
|
||||
Username string `json:"username" gorm:"size:64;not null;uniqueIndex"`
|
||||
PasswordHash string `json:"-" gorm:"size:255;not null"`
|
||||
DisplayName string `json:"display_name" gorm:"size:128;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
Name string `json:"name" gorm:"size:64;not null"`
|
||||
Code string `json:"code" gorm:"size:64;not null"`
|
||||
Permissions datatypes.JSON `json:"permissions" gorm:"type:json;not null"`
|
||||
}
|
||||
|
||||
type TenantMember struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
UserID uint64 `json:"user_id" gorm:"not null;index"`
|
||||
RoleID uint64 `json:"role_id" gorm:"not null;index"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
}
|
||||
|
||||
type Scenario struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
Industry string `json:"industry" gorm:"size:64;not null"`
|
||||
RoleName string `json:"role_name" gorm:"size:64;not null"`
|
||||
Goal string `json:"goal" gorm:"type:text;not null"`
|
||||
TriggerText string `json:"trigger_text" gorm:"type:text;not null"`
|
||||
Visibility string `json:"visibility" gorm:"size:24;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
CreatedBy uint64 `json:"created_by" gorm:"not null"`
|
||||
}
|
||||
|
||||
type ScenarioField struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
ScenarioID uint64 `json:"scenario_id" gorm:"not null;index"`
|
||||
FieldKey string `json:"field_key" gorm:"size:64;not null"`
|
||||
FieldName string `json:"field_name" gorm:"size:128;not null"`
|
||||
FieldType string `json:"field_type" gorm:"size:32;not null"`
|
||||
Required bool `json:"required" gorm:"not null"`
|
||||
Options datatypes.JSON `json:"options" gorm:"type:json;not null"`
|
||||
Validation datatypes.JSON `json:"validation" gorm:"type:json;not null"`
|
||||
SortOrder int `json:"sort_order" gorm:"not null"`
|
||||
}
|
||||
|
||||
type SOP struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
ScenarioID uint64 `json:"scenario_id" gorm:"not null;index"`
|
||||
Name string `json:"name" gorm:"size:128;not null"`
|
||||
Description string `json:"description" gorm:"type:text;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
CreatedBy uint64 `json:"created_by" gorm:"not null"`
|
||||
}
|
||||
|
||||
type SOPVersion struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
SOPID uint64 `json:"sop_id" gorm:"not null;index"`
|
||||
Version int `json:"version" gorm:"not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
StartNodeKey string `json:"start_node_key" gorm:"size:64;not null"`
|
||||
PublishedAt *time.Time `json:"published_at"`
|
||||
CreatedBy uint64 `json:"created_by" gorm:"not null"`
|
||||
ReviewedBy *uint64 `json:"reviewed_by"`
|
||||
}
|
||||
|
||||
type SOPNode struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
SOPVersionID uint64 `json:"sop_version_id" gorm:"not null;index"`
|
||||
NodeKey string `json:"node_key" gorm:"size:64;not null"`
|
||||
Type string `json:"type" gorm:"size:32;not null"`
|
||||
Title string `json:"title" gorm:"size:128;not null"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
Config datatypes.JSON `json:"config" gorm:"type:json;not null"`
|
||||
PositionX int `json:"position_x" gorm:"not null"`
|
||||
PositionY int `json:"position_y" gorm:"not null"`
|
||||
}
|
||||
|
||||
type SOPEdge struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
SOPVersionID uint64 `json:"sop_version_id" gorm:"not null;index"`
|
||||
SourceNodeKey string `json:"source_node_key" gorm:"size:64;not null"`
|
||||
TargetNodeKey string `json:"target_node_key" gorm:"size:64;not null"`
|
||||
Condition datatypes.JSON `json:"condition" gorm:"type:json;not null"`
|
||||
Priority int `json:"priority" gorm:"not null"`
|
||||
}
|
||||
|
||||
type KnowledgeCard struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
ScenarioID uint64 `json:"scenario_id" gorm:"not null;index"`
|
||||
Title string `json:"title" gorm:"size:128;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
CreatedBy uint64 `json:"created_by" gorm:"not null"`
|
||||
}
|
||||
|
||||
type KnowledgeCardVersion struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
KnowledgeCardID uint64 `json:"knowledge_card_id" gorm:"not null;index"`
|
||||
Version int `json:"version" gorm:"not null"`
|
||||
Content datatypes.JSON `json:"content" gorm:"type:json;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
}
|
||||
|
||||
type SOPRun struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
SOPID uint64 `json:"sop_id" gorm:"not null;index"`
|
||||
SOPVersionID uint64 `json:"sop_version_id" gorm:"not null;index"`
|
||||
OperatorID uint64 `json:"operator_id" gorm:"not null;index"`
|
||||
CurrentNodeKey string `json:"current_node_key" gorm:"size:64;not null"`
|
||||
Status string `json:"status" gorm:"size:24;not null"`
|
||||
Answers datatypes.JSON `json:"answers" gorm:"type:json;not null"`
|
||||
Result string `json:"result" gorm:"size:64;not null"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
CompletedAt *time.Time `json:"completed_at"`
|
||||
}
|
||||
|
||||
type SOPRunEvent struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
RunID uint64 `json:"run_id" gorm:"not null;index"`
|
||||
NodeKey string `json:"node_key" gorm:"size:64;not null"`
|
||||
Action string `json:"action" gorm:"size:64;not null"`
|
||||
Payload datatypes.JSON `json:"payload" gorm:"type:json;not null"`
|
||||
}
|
||||
|
||||
type SOPFeedback struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
RunID uint64 `json:"run_id" gorm:"not null;index"`
|
||||
UserID uint64 `json:"user_id" gorm:"not null;index"`
|
||||
Score int `json:"score" gorm:"not null"`
|
||||
Comment string `json:"comment" gorm:"type:text;not null"`
|
||||
}
|
||||
|
||||
func (SOPFeedback) TableName() string { return "sop_feedback" }
|
||||
|
||||
type AuditLog struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
UserID uint64 `json:"user_id" gorm:"not null;index"`
|
||||
Action string `json:"action" gorm:"size:64;not null"`
|
||||
Resource string `json:"resource" gorm:"size:64;not null"`
|
||||
ResourceID uint64 `json:"resource_id" gorm:"not null"`
|
||||
Payload datatypes.JSON `json:"payload" gorm:"type:json;not null"`
|
||||
}
|
||||
|
||||
type RefreshToken struct {
|
||||
Base
|
||||
TenantID uint64 `json:"tenant_id" gorm:"not null;index"`
|
||||
UserID uint64 `json:"user_id" gorm:"not null;index"`
|
||||
TokenHash string `json:"-" gorm:"size:64;not null;uniqueIndex"`
|
||||
ExpiresAt time.Time `json:"expires_at" gorm:"not null"`
|
||||
RevokedAt *time.Time `json:"revoked_at"`
|
||||
}
|
||||
Reference in New Issue
Block a user