1
This commit is contained in:
@@ -17,6 +17,10 @@ type FieldDef struct {
|
||||
}
|
||||
|
||||
// ContentTypeFields 每种内容类型的字段配置
|
||||
var AspectRatioOptions = []string{
|
||||
"9:16竖屏", "16:9横屏", "1:1方形",
|
||||
}
|
||||
|
||||
var ContentTypeFields = map[string][]FieldDef{
|
||||
TypeShortDrama: {
|
||||
{Key: "题材", Label: "题材", Type: "select", Options: ShortDramaThemes, Required: true},
|
||||
@@ -28,9 +32,7 @@ var ContentTypeFields = map[string][]FieldDef{
|
||||
TypeAdVideo: {
|
||||
{Key: "广告类型", Label: "广告类型", Type: "select", Options: AdTypes, Required: true},
|
||||
{Key: "产品行业", Label: "产品行业", Type: "select", Options: AdIndustries, Required: true},
|
||||
{Key: "广告时长", Label: "广告时长(秒)", Type: "select", Options: AdDurations, Required: true},
|
||||
{Key: "情感基调", Label: "情感基调", Type: "select", Options: AdEmotions, Required: true},
|
||||
{Key: "画面比例", Label: "画面比例", Type: "select", Options: AdAspectRatios, Required: true},
|
||||
{Key: "口播类型", Label: "口播类型", Type: "select", Options: AdNarrationTypes, Required: true},
|
||||
},
|
||||
}
|
||||
@@ -68,17 +70,11 @@ var AdIndustries = []string{
|
||||
"金融服务", "游戏娱乐", "母婴亲子", "宠物用品",
|
||||
}
|
||||
|
||||
var AdDurations = []string{"15", "30", "45", "60"}
|
||||
|
||||
var AdEmotions = []string{
|
||||
"温馨感人", "搞笑幽默", "专业权威",
|
||||
"潮流时尚", "热血激情", "文艺清新",
|
||||
}
|
||||
|
||||
var AdAspectRatios = []string{
|
||||
"9:16竖屏", "16:9横屏", "1:1方形",
|
||||
}
|
||||
|
||||
var AdNarrationTypes = []string{
|
||||
"有旁白配音", "无旁白纯画面", "演员对白", "品牌代言人出镜",
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func (c *drama) List(ctx context.Context, req *dto.ListDramaReq) (res *dto.ListD
|
||||
}
|
||||
|
||||
func (c *drama) Create(ctx context.Context, req *dto.CreateDramaReq) (res *dto.CreateDramaRes, err error) {
|
||||
id, err := service.DramaService.Create(ctx, req.Title, req.Type, req.Config, int64(req.EpisodeDuration))
|
||||
id, err := service.DramaService.Create(ctx, req.Title, req.Type, req.Config, req.AspectRatio, int64(req.EpisodeDuration))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (c *drama) Get(ctx context.Context, req *dto.GetDramaReq) (res *dto.GetDram
|
||||
}
|
||||
|
||||
func (c *drama) Update(ctx context.Context, req *dto.UpdateDramaReq) (res *struct{}, err error) {
|
||||
return nil, service.DramaService.Update(ctx, req.Id, req.Title, req.Type, req.Config, int64(req.EpisodeDuration))
|
||||
return nil, service.DramaService.Update(ctx, req.Id, req.Title, req.Type, req.Config, req.AspectRatio, int64(req.EpisodeDuration))
|
||||
}
|
||||
|
||||
func (c *drama) Delete(ctx context.Context, req *dto.DeleteDramaReq) (res *struct{}, err error) {
|
||||
|
||||
@@ -22,7 +22,8 @@ func init() {
|
||||
title TEXT NOT NULL UNIQUE, -- 标题
|
||||
type TEXT NOT NULL DEFAULT '短剧', -- 内容类型(短剧/漫剧/广告视频)
|
||||
config TEXT NOT NULL DEFAULT '{}', -- 类型专属配置(JSON)
|
||||
episode_duration INTEGER NOT NULL DEFAULT 0, -- 单集时长(秒)
|
||||
aspect_ratio TEXT NOT NULL DEFAULT '', -- 画面比例
|
||||
episode_duration INTEGER NOT NULL DEFAULT 0, -- 时长(秒)
|
||||
episode_count INTEGER NOT NULL DEFAULT 0, -- 剧集数量
|
||||
created_at DATETIME, -- 创建时间
|
||||
updated_at DATETIME, -- 更新时间
|
||||
@@ -40,6 +41,7 @@ func init() {
|
||||
_, _ = g.DB().Exec(ctx, "ALTER TABLE "+public.TableNameDrama+" ADD COLUMN config TEXT NOT NULL DEFAULT '{}'")
|
||||
// 数据迁移:将旧 style 字段值写入 config(仅对 config 为空的旧记录生效)
|
||||
_, _ = g.DB().Exec(ctx, "UPDATE "+public.TableNameDrama+" SET config = '{\"题材\":\"' || style || '\"}', type = '短剧' WHERE config = '{}' AND style != '' AND style IS NOT NULL")
|
||||
_, _ = g.DB().Exec(ctx, "ALTER TABLE "+public.TableNameDrama+" ADD COLUMN aspect_ratio TEXT NOT NULL DEFAULT ''")
|
||||
}
|
||||
|
||||
func (d *dramaDao) IncrementEpCount(ctx context.Context, dramaId int64) error {
|
||||
|
||||
@@ -47,7 +47,8 @@ type CreateDramaReq struct {
|
||||
Title string `v:"required" json:"title" dc:"标题"`
|
||||
Type string `v:"required" json:"type" dc:"内容类型(短剧/漫剧/广告视频)"`
|
||||
Config string `json:"config" dc:"类型专属配置(JSON格式)"`
|
||||
EpisodeDuration int `json:"episodeDuration" dc:"单集时长(秒/短剧漫剧)"`
|
||||
AspectRatio string `json:"aspectRatio" dc:"画面比例"`
|
||||
EpisodeDuration int `json:"episodeDuration" dc:"时长(秒)"`
|
||||
}
|
||||
|
||||
type CreateDramaRes struct {
|
||||
@@ -75,12 +76,12 @@ type GetDramaRes struct {
|
||||
// ==================== Update ====================
|
||||
|
||||
type UpdateDramaReq struct {
|
||||
g.Meta `path:"/update" method:"post" tags:"短剧管理" summary:"更新短剧"`
|
||||
Id int64 `json:"id" dc:"短剧ID"`
|
||||
Title string `v:"required" json:"title" dc:"标题"`
|
||||
Type string `json:"type" dc:"内容类型"`
|
||||
Config string `json:"config" dc:"类型专属配置(JSON格式)"`
|
||||
EpisodeDuration int `json:"episodeDuration" dc:"单集时长(秒/短剧漫剧)"`
|
||||
AspectRatio string `json:"aspectRatio" dc:"画面比例"`
|
||||
EpisodeDuration int `json:"episodeDuration" dc:"时长(秒)"`
|
||||
}
|
||||
|
||||
// ==================== Delete ====================
|
||||
|
||||
@@ -7,7 +7,8 @@ type Drama struct {
|
||||
Title string `orm:"title" json:"title" dc:"标题"`
|
||||
Type string `orm:"type" json:"type" dc:"内容类型(短剧/漫剧/广告视频)"`
|
||||
Config string `orm:"config" json:"config" dc:"类型专属配置(JSON格式)"`
|
||||
EpisodeDuration int64 `orm:"episode_duration" json:"episodeDuration" dc:"单集时长(秒/仅短剧漫剧)"`
|
||||
AspectRatio string `orm:"aspect_ratio" json:"aspectRatio" dc:"画面比例"`
|
||||
EpisodeDuration int64 `orm:"episode_duration" json:"episodeDuration" dc:"时长(秒)"`
|
||||
EpCount int `orm:"episode_count" json:"epCount" dc:"剧集数量"`
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt" dc:"更新时间"`
|
||||
|
||||
@@ -37,7 +37,7 @@ const (
|
||||
DefaultFirstFramePath = "default_first_frame.png" // 图生视频默认首帧图片路径
|
||||
)
|
||||
|
||||
func (s *dramaService) Create(ctx context.Context, title, contentType, config string, episodeDuration int64) (int64, error) {
|
||||
func (s *dramaService) Create(ctx context.Context, title, contentType, config, aspectRatio string, episodeDuration int64) (int64, error) {
|
||||
existing, _ := dao.Drama.GetByTitle(ctx, title)
|
||||
if existing != nil {
|
||||
return 0, fmt.Errorf("标题已存在: %s", title)
|
||||
@@ -47,6 +47,7 @@ func (s *dramaService) Create(ctx context.Context, title, contentType, config st
|
||||
Title: title,
|
||||
Type: contentType,
|
||||
Config: config,
|
||||
AspectRatio: aspectRatio,
|
||||
EpisodeDuration: episodeDuration,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -110,7 +111,7 @@ func (s *dramaService) Get(ctx context.Context, id int64) (*entity.Drama, []*ent
|
||||
return d, characters, episodes, scenes, props, backgroundMusic, tasks, nil
|
||||
}
|
||||
|
||||
func (s *dramaService) Update(ctx context.Context, id int64, title, contentType, config string, episodeDuration int64) error {
|
||||
func (s *dramaService) Update(ctx context.Context, id int64, title, contentType, config, aspectRatio string, episodeDuration int64) error {
|
||||
d, err := dao.Drama.GetOne(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -132,6 +133,9 @@ func (s *dramaService) Update(ctx context.Context, id int64, title, contentType,
|
||||
if config != "" {
|
||||
d.Config = config
|
||||
}
|
||||
if aspectRatio != "" {
|
||||
d.AspectRatio = aspectRatio
|
||||
}
|
||||
if episodeDuration > 0 {
|
||||
d.EpisodeDuration = episodeDuration
|
||||
}
|
||||
@@ -1565,22 +1569,16 @@ func formatDramaConfig(contentType, configStr string) string {
|
||||
return strings.Join(parts, ",")
|
||||
}
|
||||
if contentType == "广告视频" {
|
||||
parts := make([]string, 0, 6)
|
||||
parts := make([]string, 0, 5)
|
||||
if v, ok := cfg["广告类型"]; ok {
|
||||
parts = append(parts, "广告类型:"+v)
|
||||
}
|
||||
if v, ok := cfg["产品行业"]; ok {
|
||||
parts = append(parts, "产品行业:"+v)
|
||||
}
|
||||
if v, ok := cfg["广告时长"]; ok {
|
||||
parts = append(parts, "广告时长:"+v+"秒")
|
||||
}
|
||||
if v, ok := cfg["情感基调"]; ok {
|
||||
parts = append(parts, "情感基调:"+v)
|
||||
}
|
||||
if v, ok := cfg["画面比例"]; ok {
|
||||
parts = append(parts, "画面比例:"+v)
|
||||
}
|
||||
if v, ok := cfg["口播类型"]; ok {
|
||||
parts = append(parts, "口播类型:"+v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user