This commit is contained in:
2026-07-01 17:10:45 +08:00
parent cc7490175a
commit 34b0a89f74
8 changed files with 1 additions and 183 deletions
+1 -2
View File
@@ -21,6 +21,7 @@ services:
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY --from=builder /build/config.yml .
COPY --from=builder /build/main .
EXPOSE 80
CMD ["./main"]
@@ -28,7 +29,5 @@ services:
ports:
- "80:80"
volumes:
- /data/video-factory/config.yml:/app/config.yml
- /data/video-factory/short_drama.db:/app/short_drama.db
- /data/video-factory/workspace:/app/workspace
restart: unless-stopped
-23
View File
@@ -13,29 +13,6 @@ var Character = &characterDao{}
type characterDao struct{}
func init() {
ctx := context.Background()
if _, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+public.TableNameCharacter+` (
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 演员ID
drama_id INTEGER NOT NULL DEFAULT 0, -- 短剧ID
name TEXT NOT NULL DEFAULT '', -- 演员名称
description TEXT NOT NULL DEFAULT '', -- 演员描述
voice_path TEXT NOT NULL DEFAULT '', -- 声音文件路径
portrait_path TEXT NOT NULL DEFAULT '', -- 形象文件路径
created_at DATETIME, -- 创建时间
updated_at DATETIME, -- 更新时间
deleted_at DATETIME -- 删除时间
)`); err != nil {
g.Log().Warningf(ctx, "创建演员表失败: %v", err)
}
// 迁移:清理旧字段
for _, col := range []string{"voice_type", "portrait_url", "image_base64"} {
if _, err := g.DB().Exec(ctx, `ALTER TABLE `+public.TableNameCharacter+` DROP COLUMN `+col); err != nil {
g.Log().Warningf(ctx, "删除演员表旧字段 %s 失败(可能已删除): %v", col, err)
}
}
}
func (d *characterDao) Insert(ctx context.Context, data *entity.Character) (id int64, err error) {
m := gconv.Map(data, gconv.MapOption{Tags: []string{"orm"}})
delete(m, "id")
-22
View File
@@ -14,28 +14,6 @@ var Drama = &dramaDao{}
type dramaDao struct{}
func init() {
ctx := context.Background()
// 建表(IF NOT EXISTS 对新库生效,已存在的表跳过)
if _, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+public.TableNameDrama+` (
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 短剧ID
title TEXT NOT NULL UNIQUE, -- 短剧标题
style TEXT NOT NULL DEFAULT '', -- 短剧风格
episode_duration INTEGER NOT NULL DEFAULT 0, -- 单集时长(秒)
episode_count INTEGER NOT NULL DEFAULT 0, -- 剧集数量
created_at DATETIME, -- 创建时间
updated_at DATETIME, -- 更新时间
deleted_at DATETIME -- 删除时间
)`); err != nil {
g.Log().Warningf(ctx, "创建短剧表失败: %v", err)
}
// 对已存在的旧表补充唯一索引
if _, err := g.DB().Exec(ctx,
"CREATE UNIQUE INDEX IF NOT EXISTS idx_short_drama_title ON "+public.TableNameDrama+"(title)"); err != nil {
g.Log().Warningf(ctx, "创建短剧标题唯一索引失败: %v", err)
}
}
func (d *dramaDao) IncrementEpCount(ctx context.Context, dramaId int64) error {
_, err := g.DB().Model(public.TableNameDrama).Ctx(ctx).
Data(g.Map{"episode_count": gdb.Raw("episode_count + 1")}).
-28
View File
@@ -13,34 +13,6 @@ var Episode = &episodeDao{}
type episodeDao struct{}
func init() {
ctx := context.Background()
if _, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+public.TableNameEpisode+` (
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 剧集ID
drama_id INTEGER NOT NULL DEFAULT 0, -- 短剧ID
idx INTEGER NOT NULL DEFAULT 0, -- 剧集序号
title TEXT NOT NULL DEFAULT '', -- 剧集标题
script TEXT NOT NULL DEFAULT '', -- 剧集脚本
status TEXT NOT NULL DEFAULT 'pending', -- 生成状态
video_url TEXT NOT NULL DEFAULT '', -- 视频URL
created_at DATETIME, -- 创建时间
updated_at DATETIME, -- 更新时间
deleted_at DATETIME -- 删除时间
)`); err != nil {
g.Log().Warningf(ctx, "创建剧集表失败: %v", err)
}
// 迁移:删除 generation_mode 列(已由模型配置动态决定)
if _, err := g.DB().Exec(ctx, `ALTER TABLE `+public.TableNameEpisode+` DROP COLUMN generation_mode`); err != nil {
g.Log().Debugf(ctx, "删除 generation_mode 列失败(可能已删除): %v", err)
}
// 迁移:清理旧字段
for _, col := range []string{"tech_script", "script_path", "tech_script_path", "description_path", "duration"} {
if _, err := g.DB().Exec(ctx, `ALTER TABLE `+public.TableNameEpisode+` DROP COLUMN `+col); err != nil {
g.Log().Warningf(ctx, "删除剧集表旧字段 %s 失败(可能已删除): %v", col, err)
}
}
}
func (d *episodeDao) Insert(ctx context.Context, data *entity.Episode) (id int64, err error) {
m := gconv.Map(data, gconv.MapOption{Tags: []string{"orm"}})
delete(m, "id")
-56
View File
@@ -13,62 +13,6 @@ var GenerationTask = &generationTaskDao{}
type generationTaskDao struct{}
func init() {
ctx := context.Background()
if _, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+public.TableNameGenerationTask+` (
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 任务ID
drama_id INTEGER NOT NULL DEFAULT 0, -- 短剧ID
episode_id INTEGER NOT NULL DEFAULT 0, -- 剧集ID
segment_idx INTEGER NOT NULL DEFAULT 0, -- 段索引
status TEXT NOT NULL DEFAULT 'pending', -- 任务状态
error_message TEXT NOT NULL DEFAULT '',
created_at DATETIME,
updated_at DATETIME
)`); err != nil {
g.Log().Warningf(ctx, "创建生成任务表失败: %v", err)
}
// 迁移:添加 segment_idx 列(旧表升级)
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` ADD COLUMN segment_idx INTEGER NOT NULL DEFAULT 0`); err != nil {
g.Log().Debugf(ctx, "添加 segment_idx 列失败(可能已存在): %v", err)
}
// 迁移:添加 script_path 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` ADD COLUMN script_path TEXT NOT NULL DEFAULT ''`); err != nil {
g.Log().Debugf(ctx, "添加 script_path 列失败(可能已存在): %v", err)
}
// 迁移:添加 video_task_id 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` ADD COLUMN video_task_id TEXT NOT NULL DEFAULT ''`); err != nil {
g.Log().Debugf(ctx, "添加 video_task_id 列失败(可能已存在): %v", err)
}
// 迁移:添加 video_url 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` ADD COLUMN video_url TEXT NOT NULL DEFAULT ''`); err != nil {
g.Log().Debugf(ctx, "添加 video_url 列失败(可能已存在): %v", err)
}
// 迁移:添加 num_segments 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` ADD COLUMN num_segments INTEGER NOT NULL DEFAULT 1`); err != nil {
g.Log().Debugf(ctx, "添加 num_segments 列失败(可能已存在): %v", err)
}
// 迁移:删除废弃的 current_step 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` DROP COLUMN current_step`); err != nil {
g.Log().Debugf(ctx, "删除 current_step 列失败(可能已不存在): %v", err)
}
// 迁移:删除废弃的 total_steps 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` DROP COLUMN total_steps`); err != nil {
g.Log().Debugf(ctx, "删除 total_steps 列失败(可能已不存在): %v", err)
}
// 迁移:删除废弃的 steps_data 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameGenerationTask+` DROP COLUMN steps_data`); err != nil {
g.Log().Debugf(ctx, "删除 steps_data 列失败(可能已不存在): %v", err)
}
}
func (d *generationTaskDao) Insert(ctx context.Context, data *entity.GenerationTask) (id int64, err error) {
m := gconv.Map(data, gconv.MapOption{Tags: []string{"orm"}})
delete(m, "id")
-20
View File
@@ -13,26 +13,6 @@ var ModelConfig = &modelConfigDao{}
type modelConfigDao struct{}
func init() {
ctx := context.Background()
_, _ = g.DB().Model(public.TableNameModelConfig).Ctx(ctx).Where("1=1").Limit(1).One() // 触发表创建
// 迁移:添加 video_model_category 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameModelConfig+` ADD COLUMN video_model_category TEXT NOT NULL DEFAULT 't2v'`); err != nil {
g.Log().Debugf(ctx, "添加 video_model_category 列失败(可能已存在): %v", err)
}
// 迁移:删除无意义的 video_max_duration 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameModelConfig+` DROP COLUMN video_max_duration`); err != nil {
g.Log().Debugf(ctx, "删除 video_max_duration 列失败(可能不存在): %v", err)
}
// 迁移:添加 video_no_duration_support 列
if _, err := g.DB().Exec(ctx,
`ALTER TABLE `+public.TableNameModelConfig+` ADD COLUMN video_no_duration_support INTEGER NOT NULL DEFAULT 0`); err != nil {
g.Log().Debugf(ctx, "添加 video_no_duration_support 列失败(可能已存在): %v", err)
}
}
// GetFirst 获取第一条配置行
func (d *modelConfigDao) GetFirst(ctx context.Context) (res *entity.ModelConfig, err error) {
r, err := g.DB().Model(public.TableNameModelConfig).Ctx(ctx).OrderAsc("id").Limit(1).One()
-16
View File
@@ -13,22 +13,6 @@ var Prop = &propDao{}
type propDao struct{}
func init() {
ctx := context.Background()
if _, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+public.TableNameProp+` (
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 道具ID
drama_id INTEGER NOT NULL DEFAULT 0, -- 短剧ID
name TEXT NOT NULL DEFAULT '', -- 道具名称
description TEXT NOT NULL DEFAULT '', -- 道具描述
image_path TEXT NOT NULL DEFAULT '', -- 道具图片路径
created_at DATETIME, -- 创建时间
updated_at DATETIME, -- 更新时间
deleted_at DATETIME -- 删除时间
)`); err != nil {
g.Log().Warningf(ctx, "创建道具表失败: %v", err)
}
}
func (d *propDao) Insert(ctx context.Context, data *entity.Prop) (id int64, err error) {
m := gconv.Map(data, gconv.MapOption{Tags: []string{"orm"}})
delete(m, "id")
-16
View File
@@ -13,22 +13,6 @@ var Scene = &sceneDao{}
type sceneDao struct{}
func init() {
ctx := context.Background()
if _, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+public.TableNameScene+` (
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 场景ID
drama_id INTEGER NOT NULL DEFAULT 0, -- 短剧ID
name TEXT NOT NULL DEFAULT '', -- 场景名称
description TEXT NOT NULL DEFAULT '', -- 场景描述
image_path TEXT NOT NULL DEFAULT '', -- 场景图片路径
created_at DATETIME, -- 创建时间
updated_at DATETIME, -- 更新时间
deleted_at DATETIME -- 删除时间
)`); err != nil {
g.Log().Warningf(ctx, "创建场景表失败: %v", err)
}
}
func (d *sceneDao) Insert(ctx context.Context, data *entity.Scene) (id int64, err error) {
m := gconv.Map(data, gconv.MapOption{Tags: []string{"orm"}})
delete(m, "id")