You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
4.8 KiB
74 lines
4.8 KiB
package console
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
)
|
|
|
|
// ============================ 第三方服务类别 (svc_category) ============================
|
|
//
|
|
// 2026-09-14 之前类别是三处写死的常量:admin 前端的 SCAT 数组(标签/颜色)、console 的 svcCat*
|
|
// (模板与会议编排的类别映射)、comm 的 SvcCat*(真正带运行时语义的四个)。运营想加一个新类别
|
|
// 或改个名字都得改代码发版。现在类别落库、后台可增删改,但要分清两种东西:
|
|
//
|
|
// - **展示属性**(label/short/color/bg/sort/enabled):任何类别都可改,纯后台分组用。
|
|
// - **运行时语义**:只挂在 comm.SvcCat*(MT=3 用于 user_translate、AST=4 VIP 过期停发、
|
|
// MCP=10 特殊字段与工具发现、IdVerify=11 服务端专用永不下发)以及模板/会议编排引用的
|
|
// 内置 id(1/2/5/8/9)上。**这些 id 不能改也不能删**,改了运行时找不到;后台把它们标成 builtin。
|
|
// 自定义类别(id ≥ 100)只有分组作用,不会因为叫「实名」就获得「不下发」的保护——
|
|
// server_only 是从 comm 里读出来的只读属性,不落库、后台改不了,这是刻意的:
|
|
// 它守的是主账号密钥不出网关,不该由一个勾选框决定。
|
|
//
|
|
// 删除自定义类别前会查 svc_config.categories 与 third_svc_template.category 的引用,
|
|
// 有引用一律拒绝——否则那些服务在后台会掉进「未分类」,看着像丢了。
|
|
|
|
// SvcCategory 第三方服务类别(表 TableSvcCategory)。
|
|
type SvcCategory struct {
|
|
Id int32 `gorm:"column:id;primaryKey" json:"id"` // 内置 1~12;自定义从 100 起由服务端分配
|
|
Label string `gorm:"column:label;size:64" json:"label"` // 全称,如「STT 语音识别」
|
|
Short string `gorm:"column:short;size:16" json:"short"` // 卡片角标,如「STT」
|
|
Color string `gorm:"column:color;size:16" json:"color"` // 角标前景色
|
|
Bg string `gorm:"column:bg;size:16" json:"bg"` // 角标背景色
|
|
Sort int32 `gorm:"column:sort" json:"sort"` // 展示排序,越小越靠前
|
|
Builtin bool `gorm:"column:builtin" json:"builtin"` // seed 内置:id 不可改、不可删(运行时/模板按 id 引用)
|
|
Voice bool `gorm:"column:voice" json:"voice"` // 音频输出类:新建服务时按音色表预填 languages(原前端 VOICE_CATS)
|
|
Enabled bool `gorm:"column:enabled" json:"enabled"` // 停用后不在新增向导里出现,已归入的服务照常展示
|
|
|
|
// ServerOnly 只读:来自 comm.IsServerOnlySvc,读列表时现算,不落库、后台改不了。
|
|
ServerOnly bool `gorm:"-" json:"server_only"`
|
|
}
|
|
|
|
func (SvcCategory) TableName() string { return comm.TableSvcCategory }
|
|
|
|
// svcCategoryCustomIdStart 自定义类别 id 起点。1~99 留给内置(现在用到 12)。
|
|
const svcCategoryCustomIdStart int32 = 100
|
|
|
|
// builtinSvcCategories 与 admin 原 SCAT 数组逐项对应(顺序即默认 sort),末尾是后加的「应用参数」。
|
|
// ⚠️ 这里的 id 与 comm.SvcCat* / console svcCat* 是同一套数字,改任何一处都要三处同改。
|
|
func builtinSvcCategories() []SvcCategory {
|
|
list := []SvcCategory{
|
|
{Id: svcCatSTT, Label: "STT 语音识别", Short: "STT", Color: "#0369a1", Bg: "#dbeafe"},
|
|
{Id: svcCatASRFile, Label: "录音文件识别", Short: "录音识别", Color: "#0e7490", Bg: "#cffafe"},
|
|
{Id: svcCatTTS, Label: "TTS 语音合成", Short: "TTS", Color: "#7c3aed", Bg: "#ede9fe", Voice: true},
|
|
{Id: svcCatMT, Label: "MT 机器翻译", Short: "MT", Color: "#059669", Bg: "#dcfce7"},
|
|
{Id: svcCatAST, Label: "AST 端到端翻译", Short: "AST", Color: "#c2410c", Bg: "#fff7ed", Voice: true},
|
|
{Id: svcCatLLM, Label: "LLM 文本大模型", Short: "文本LLM", Color: "#b45309", Bg: "#fef9c3"},
|
|
{Id: svcCatLLMVision, Label: "多媒体大模型", Short: "多媒体LLM", Color: "#9333ea", Bg: "#f3e8ff"},
|
|
{Id: svcCatSTS, Label: "STS 端到端对话", Short: "STS", Color: "#be185d", Bg: "#fce7f3", Voice: true},
|
|
{Id: svcCatStorage, Label: "存储 OSS/COS", Short: "存储", Color: "#475569", Bg: "#f1f5f9"},
|
|
{Id: svcCatMCP, Label: "MCP 服务", Short: "MCP", Color: "#0d9488", Bg: "#ccfbf1"},
|
|
{Id: svcCatIdVerify, Label: "身份证校验", Short: "实名", Color: "#9f1239", Bg: "#ffe4e6"},
|
|
// 应用参数(2026-09-14):非凭据的应用级业务参数,原「应用参数」标签页(业务库 config 表)下线后的唯一入口。
|
|
{Id: svcCatAppParams, Label: "应用参数", Short: "参数", Color: "#334155", Bg: "#e2e8f0"},
|
|
}
|
|
for i := range list {
|
|
list[i].Builtin = true
|
|
list[i].Enabled = true
|
|
list[i].Sort = int32(i)
|
|
}
|
|
return list
|
|
}
|
|
|
|
// fillSvcCategoryRuntime 补上只读的运行时属性。
|
|
func fillSvcCategoryRuntime(c *SvcCategory) {
|
|
c.ServerOnly = comm.IsServerOnlySvcCat(c.Id)
|
|
}
|
|
|