视频会议保存

This commit is contained in:
duoaohui
2026-05-18 21:23:00 +08:00
parent fb965cc8c4
commit 5a5706c236
20 changed files with 1211 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
// Package model 提供 transcribe 模块的数据库模型
package model
import "time"
// Transcript 会议录制语音转写结果,对应 meeting_transcripts 表
//
// 一对一关联 meeting_recordings.idunique 索引),同一段录制只保留最新一份转写结果,
// 重新触发转写会就地更新保持状态机pending → running → ready/failed
//
// 字段设计:
// - Text拼接后的全文便于列表/搜索
// - SegmentsJSONB 数组 [{start,end,text}],便于按时间轴渲染字幕
// - Provider/ModelCode本次实际使用的 LLM 配置快照,调试/审计用
// - ErrorMsg失败原因HTTP 错误 / Key 不可用 / 文件下载失败等)
//
// PostgreSQL JSONB 字段在 GORM 里用 string 承载,由 service 层 json.Marshal/Unmarshal。
type Transcript struct {
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"`
RecordingID int64 `json:"recording_id" gorm:"not null;uniqueIndex:uk_transcripts_recording"` // 唯一关联录制
RoomID int64 `json:"room_id" gorm:"not null;index:idx_transcripts_room"` // 冗余 room_id 便于按会议批量查
Status string `json:"status" gorm:"size:16;not null;default:pending"` // pending / running / ready / failed
Text string `json:"text" gorm:"type:text;not null;default:''"`
Segments string `json:"segments" gorm:"type:jsonb;not null;default:'[]'"` // JSON 数组字符串
Language string `json:"language" gorm:"size:16;not null;default:''"`
DurationSec int `json:"duration_sec" gorm:"not null;default:0"`
ProviderCode string `json:"provider_code" gorm:"size:32;not null;default:''"` // 来自 t_llm_provider.provider_code
ModelCode string `json:"model_code" gorm:"size:64;not null;default:''"` // 来自 t_llm_model.model_code
KeyID int64 `json:"key_id" gorm:"not null;default:0"` // 来自 t_llm_key.id便于追踪 key 用量
ErrorMsg string `json:"error_msg" gorm:"size:512;not null;default:''"`
StartedAt *time.Time `json:"started_at" gorm:"type:timestamp(0)"`
FinishedAt *time.Time `json:"finished_at" gorm:"type:timestamp(0)"`
CreatedAt time.Time `json:"created_at" gorm:"not null;autoCreateTime;type:timestamp(0)"`
UpdatedAt time.Time `json:"updated_at" gorm:"not null;autoUpdateTime;type:timestamp(0)"`
}
// TableName 指定数据库表名
func (Transcript) TableName() string {
return "meeting_transcripts"
}
// 状态常量
const (
TranscriptStatusPending = "pending"
TranscriptStatusRunning = "running"
TranscriptStatusReady = "ready"
TranscriptStatusFailed = "failed"
)