新增正则和扩展模块

This commit is contained in:
2026-02-11 23:44:09 +08:00
parent 2bca8e2788
commit 4e611d3a5e
47 changed files with 10058 additions and 49 deletions

View File

@@ -0,0 +1,107 @@
package request
import (
common "git.echol.cn/loser/st/server/model/common/request"
)
// CreateExtensionRequest 创建/安装扩展请求
type CreateExtensionRequest struct {
Name string `json:"name" binding:"required,min=1,max=500"`
DisplayName string `json:"displayName"`
Version string `json:"version"`
Author string `json:"author"`
Description string `json:"description"`
Homepage string `json:"homepage"`
Repository string `json:"repository"`
License string `json:"license"`
Tags []string `json:"tags"`
ExtensionType string `json:"extensionType" binding:"required,oneof=ui server hybrid"`
Category string `json:"category"`
Dependencies map[string]string `json:"dependencies"`
Conflicts []string `json:"conflicts"`
ManifestData map[string]interface{} `json:"manifestData" binding:"required"`
ScriptPath string `json:"scriptPath"`
StylePath string `json:"stylePath"`
AssetsPaths []string `json:"assetsPaths"`
Settings map[string]interface{} `json:"settings"`
Options map[string]interface{} `json:"options"`
InstallSource string `json:"installSource"`
SourceURL string `json:"sourceUrl"` // 原始安装 URL用于更新
Branch string `json:"branch"` // Git 分支
AutoUpdate bool `json:"autoUpdate"` // 是否自动更新
Metadata map[string]interface{} `json:"metadata"`
}
// ExtensionListRequest 扩展列表查询请求
type ExtensionListRequest struct {
common.PageInfo
Name string `json:"name" form:"name"` // 扩展名称(模糊搜索)
ExtensionType string `json:"extensionType" form:"extensionType"` // 扩展类型
Category string `json:"category" form:"category"` // 分类
IsEnabled *bool `json:"isEnabled" form:"isEnabled"` // 是否启用
IsInstalled *bool `json:"isInstalled" form:"isInstalled"` // 是否已安装
Tag string `json:"tag" form:"tag"` // 标签过滤
}
// InstallExtensionRequest 安装扩展请求
type InstallExtensionRequest struct {
Source string `json:"source" binding:"required,oneof=url file marketplace"` // 安装来源
URL string `json:"url"` // URL 安装
ManifestData []byte `json:"manifestData"` // 文件安装
MarketplaceID string `json:"marketplaceId"` // 市场安装
}
// UninstallExtensionRequest 卸载扩展请求
type UninstallExtensionRequest struct {
DeleteFiles bool `json:"deleteFiles"` // 是否删除文件
}
// ToggleExtensionRequest 启用/禁用扩展请求
type ToggleExtensionRequest struct {
IsEnabled *bool `json:"isEnabled"` // 使用指针类型,允许 false 值
}
// UpdateExtensionSettingsRequest 更新扩展配置请求
type UpdateExtensionSettingsRequest struct {
Settings map[string]interface{} `json:"settings" binding:"required"`
}
// ImportExtensionRequest 导入扩展请求
type ImportExtensionRequest struct {
Format string `json:"format" binding:"required,oneof=zip folder"`
}
// ExportExtensionRequest 导出扩展请求
type ExportExtensionRequest struct {
Format string `json:"format" binding:"required,oneof=zip folder"`
IncludeAssets bool `json:"includeAssets"` // 是否包含资源文件
}
// ExtensionStatsRequest 扩展统计请求
type ExtensionStatsRequest struct {
ExtensionID uint `json:"extensionId" binding:"required"`
Action string `json:"action" binding:"required,oneof=usage error load"` // 统计类型
Value int `json:"value"`
}
// InstallExtensionFromGitRequest 从 Git URL 安装扩展请求
type InstallExtensionFromGitRequest struct {
GitUrl string `json:"gitUrl" binding:"required"` // Git 仓库 URL
Branch string `json:"branch" binding:"omitempty,max=100"` // 分支名称(可选,默认 main
}
// InstallExtensionFromURLRequest 从 URL 安装扩展请求(智能识别 Git URL 或 Manifest URL
type InstallExtensionFromURLRequest struct {
URL string `json:"url" binding:"required"` // Git 仓库 URL 或 Manifest.json URL
Branch string `json:"branch"` // Git 分支名称(可选,默认 main
}
// UpdateExtensionRequest 更新扩展请求
type UpdateExtensionRequest struct {
Force bool `json:"force"` // 是否强制更新(忽略本地修改)
DisplayName string `json:"displayName"`
Description string `json:"description"`
Settings map[string]interface{} `json:"settings"`
Options map[string]interface{} `json:"options"`
Metadata map[string]interface{} `json:"metadata"`
}

View File

@@ -0,0 +1,88 @@
package request
import (
"git.echol.cn/loser/st/server/model/app"
common "git.echol.cn/loser/st/server/model/common/request"
)
// CreateRegexScriptRequest 创建正则脚本请求
type CreateRegexScriptRequest struct {
ScriptName string `json:"scriptName" binding:"required"`
Description string `json:"description"`
FindRegex string `json:"findRegex" binding:"required"`
ReplaceString string `json:"replaceString"`
Enabled bool `json:"enabled"`
IsGlobal bool `json:"isGlobal"`
TrimStrings bool `json:"trimStrings"`
OnlyFormat bool `json:"onlyFormat"`
RunOnEdit bool `json:"runOnEdit"`
SubstituteRegex bool `json:"substituteRegex"`
MinDepth *int `json:"minDepth"`
MaxDepth *int `json:"maxDepth"`
Placement string `json:"placement"`
AffectMinDepth *int `json:"affectMinDepth"`
AffectMaxDepth *int `json:"affectMaxDepth"`
LinkedChars []string `json:"linkedChars"`
ScriptData map[string]interface{} `json:"scriptData"`
}
// UpdateRegexScriptRequest 更新正则脚本请求
type UpdateRegexScriptRequest struct {
ScriptName string `json:"scriptName"`
Description string `json:"description"`
FindRegex string `json:"findRegex"`
ReplaceString string `json:"replaceString"`
Enabled *bool `json:"enabled"`
IsGlobal *bool `json:"isGlobal"`
TrimStrings *bool `json:"trimStrings"`
OnlyFormat *bool `json:"onlyFormat"`
RunOnEdit *bool `json:"runOnEdit"`
SubstituteRegex *bool `json:"substituteRegex"`
MinDepth *int `json:"minDepth"`
MaxDepth *int `json:"maxDepth"`
Placement string `json:"placement"`
AffectMinDepth *int `json:"affectMinDepth"`
AffectMaxDepth *int `json:"affectMaxDepth"`
LinkedChars []string `json:"linkedChars"`
ScriptData map[string]interface{} `json:"scriptData"`
}
// RegexScriptListRequest 正则脚本列表查询请求
type RegexScriptListRequest struct {
common.PageInfo
ScriptName string `json:"scriptName" form:"scriptName"` // 脚本名称(模糊搜索)
IsGlobal *bool `json:"isGlobal" form:"isGlobal"` // 是否全局
Enabled *bool `json:"enabled" form:"enabled"` // 是否启用
CharacterID *uint `json:"characterId" form:"characterId"` // 关联角色ID
}
// LinkCharacterToRegexRequest 关联角色到正则脚本请求
type LinkCharacterToRegexRequest struct {
CharacterIDs []uint `json:"characterIds" binding:"required"`
}
// TestRegexScriptRequest 测试正则脚本请求
type TestRegexScriptRequest struct {
FindRegex string `json:"findRegex" binding:"required"`
ReplaceString string `json:"replaceString"`
TestInput string `json:"testInput" binding:"required"`
TrimStrings bool `json:"trimStrings"`
SubstituteRegex bool `json:"substituteRegex"`
}
// ApplyRegexScriptsRequest 应用正则脚本请求
type ApplyRegexScriptsRequest struct {
Text string `json:"text" binding:"required"`
RegexIDs []uint `json:"regexIds"` // 指定要应用的脚本ID列表
CharacterID *uint `json:"characterId"` // 角色ID自动应用关联的脚本
Placement string `json:"placement"` // 应用位置
MinDepth *int `json:"minDepth"` // 最小深度
MaxDepth *int `json:"maxDepth"` // 最大深度
UseGlobal bool `json:"useGlobal"` // 是否应用全局脚本
}
// ImportRegexScriptsRequest 导入正则脚本请求
type ImportRegexScriptsRequest struct {
Scripts []app.AIRegexScript `json:"scripts" binding:"required"`
OverwriteMode string `json:"overwriteMode"` // skip, overwrite, merge
}

View File

@@ -1,6 +1,9 @@
package request
import "git.echol.cn/loser/st/server/model/app"
import (
"git.echol.cn/loser/st/server/model/app"
common "git.echol.cn/loser/st/server/model/common/request"
)
// CreateWorldBookRequest 创建世界书请求
type CreateWorldBookRequest struct {
@@ -20,7 +23,7 @@ type UpdateWorldBookRequest struct {
// WorldBookListRequest 世界书列表查询请求
type WorldBookListRequest struct {
PageInfo
common.PageInfo
BookName string `json:"bookName" form:"bookName"` // 世界书名称(模糊搜索)
IsGlobal *bool `json:"isGlobal" form:"isGlobal"` // 是否全局
CharacterID *uint `json:"characterId" form:"characterId"` // 关联角色ID