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.
66 lines
4.3 KiB
66 lines
4.3 KiB
package console
|
|
|
|
// 依赖服务配置(svcconfig) 与 通话翻译配置(calltranslate) 的本地数据模型。
|
|
//
|
|
// yunyan-sas 的 pb 没有这些定义且禁止改 proto,故在 console 模块用本地 Go struct + gorm/json tag 定义。
|
|
// 字段移植自 deep_server 的 db.proto(DBThirdSvcConfig / ThirdSvcFieldItem / DBThirdSvcRegionOverride /
|
|
// DBCallTranslatePair),并与 admin 前端(serviceconfig.vue / calltranslate.vue) 的 JSON 契约精确对齐。
|
|
//
|
|
// 嵌套字段([]SvcField / map[string]string)借助 gorm `serializer:json` tag 存为 jsonb 列,
|
|
// gorm v1.26 AutoMigrate + 读写自动 Marshal/Unmarshal,无需手动处理。
|
|
// region / mode 直接用 int32(与前端 JSON 一致),不依赖 pb 的 Region/TranslateMode 枚举。
|
|
|
|
// SvcField 依赖服务的自定义字段项(内嵌于 ThirdSvcConfig.fields jsonb 列)。
|
|
// 加密字段:DefValue 存 AES-GCM 密文;API 对加密字段只返回 "[encrypted]" 占位,
|
|
// 更新时若传空串/占位符则保留原密文不变。
|
|
type SvcField struct {
|
|
Key string `json:"key"` // 字段名,同服务内唯一,如 secret_key
|
|
Description string `json:"description"` // 字段用途描述,前端展示
|
|
Encrypted bool `json:"encrypted"` // 是否加密存储
|
|
DefValue string `json:"def_value"` // 默认值(全区域共用;加密字段存 AES-GCM 密文)
|
|
Sort int32 `json:"sort"` // 展示排序,越小越靠前
|
|
}
|
|
|
|
// ThirdSvcConfig 依赖服务配置(表:third_svc_config)。每行 = 一个第三方服务(如火山引擎/阿里云)。
|
|
// categories 存逗号分隔的 ServiceCategory 枚举值,如 "1,2,3"。
|
|
type ThirdSvcConfig struct {
|
|
Id string `gorm:"column:id;size:64;primaryKey" json:"id"`
|
|
Name string `gorm:"column:name;size:64" json:"name"`
|
|
Categories string `gorm:"column:categories;size:64" json:"categories"`
|
|
Description string `gorm:"column:description" json:"description"`
|
|
Enable bool `gorm:"column:enable" json:"enable"`
|
|
Fields []SvcField `gorm:"column:fields;type:jsonb;serializer:json" json:"fields"`
|
|
Createtime int64 `gorm:"column:createtime" json:"createtime"`
|
|
Updatetime int64 `gorm:"column:updatetime" json:"updatetime"`
|
|
}
|
|
|
|
// SvcRegionOverride 依赖服务区域字段覆盖(表:third_svc_region_override)。
|
|
// 每行 = 一个服务 × 一个区域的覆盖集合(仅存有差异的字段)。
|
|
// 某字段 key 不在 Overrides 中则继承 ThirdSvcConfig.fields 内对应字段的 DefValue。
|
|
type SvcRegionOverride struct {
|
|
Id uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
|
SvcId string `gorm:"column:svc_id;size:64;uniqueIndex:uidx_svc_region" json:"svc_id"`
|
|
Region int32 `gorm:"column:region;uniqueIndex:uidx_svc_region" json:"region"`
|
|
Overrides map[string]string `gorm:"column:overrides;type:jsonb;serializer:json" json:"overrides"`
|
|
Updatetime int64 `gorm:"column:updatetime" json:"updatetime"`
|
|
}
|
|
|
|
// CallTranslatePair 通话翻译语言对配置(表:call_translate_pair)。
|
|
// 每条记录定义一个区域下"源语言→目标语言"的翻译服务编排。
|
|
// mode=0 走三段式(asr/mt/tts_svc_id 有效);mode=1 走端到端(ast_svc_id 有效)。
|
|
// bidir=true 时业务侧自动映射反向(dst→src),复用同一套服务。
|
|
type CallTranslatePair struct {
|
|
Id uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
|
Region int32 `gorm:"column:region;uniqueIndex:uidx_region_lang" json:"region"`
|
|
SrcLang string `gorm:"column:src_lang;size:16;uniqueIndex:uidx_region_lang" json:"src_lang"`
|
|
DstLang string `gorm:"column:dst_lang;size:16;uniqueIndex:uidx_region_lang" json:"dst_lang"`
|
|
Bidir bool `gorm:"column:bidir" json:"bidir"`
|
|
Mode int32 `gorm:"column:mode" json:"mode"`
|
|
AsrSvcId string `gorm:"column:asr_svc_id;size:64" json:"asr_svc_id"`
|
|
MtSvcId string `gorm:"column:mt_svc_id;size:64" json:"mt_svc_id"`
|
|
TtsSvcId string `gorm:"column:tts_svc_id;size:64" json:"tts_svc_id"`
|
|
AstSvcId string `gorm:"column:ast_svc_id;size:64" json:"ast_svc_id"`
|
|
Enable bool `gorm:"column:enable" json:"enable"`
|
|
Createtime int64 `gorm:"column:createtime" json:"createtime"`
|
|
Updatetime int64 `gorm:"column:updatetime" json:"updatetime"`
|
|
}
|
|
|