Compare commits

...

5 Commits

Author SHA1 Message Date
bx1834938347-prog
8d2cdd958d Merge branch 'dev' of http://gitea.tools.fontree.cn:3000/fiee/fonchain-fiee into dev 2026-03-13 11:20:08 +08:00
bx1834938347-prog
9ace3b2b6d 解决合并冲突 2026-03-13 11:19:49 +08:00
bx1834938347-prog
36e3dce21f feat:新增图文增加黄反,视频脚本导出excel 2026-03-13 11:11:31 +08:00
JNG
c33fa06382 11 2026-03-12 16:31:35 +08:00
JNG
6c7575c4ec Merge branch 'jng-QuestionnairePDF-0311' 2026-03-12 09:31:14 +08:00
5 changed files with 102 additions and 33 deletions

View File

@ -64,6 +64,7 @@ func MediaRouter(r *gin.RouterGroup) {
script.POST("update", serviceCast.UpdateVideoScript)
script.POST("detail", serviceCast.VideoScriptDetail)
script.POST("list", serviceCast.ListVideoScripts)
script.POST("export-excel", serviceCast.VideoScripExportExcel)
script.POST("import-batch", serviceCast.ImportBatch)
script.POST("update-approval", serviceCast.UpdateScriptApproval)
script.POST("delete", serviceCast.DeleteVideoScript)

View File

@ -77,6 +77,7 @@ func NewRouter() *gin.Engine {
privateGroup.POST("generate/captcha", account.GenerateCaptcha) //生成滑块验证码
privateGroup.POST("validate/captcha", account.ValidateCaptcha) //验证滑块验证码
privateGroup.POST("check/register", account.CheckRegister) //校验是否注册
privateGroup.GET("get/ip", account.GetIP)
acRoute := privateGroup.Group("/user")
acRoute.Use(middleware.CheckLogin(service.AccountFieeProvider))
{

View File

@ -124,6 +124,50 @@ func ListVideoScripts(ctx *gin.Context) {
return
}
var videoScripMap = map[uint32]string{1: "草稿", 2: "审核中", 3: "审核通过", 4: "审核不通过"}
func VideoScripExportExcel(ctx *gin.Context) {
var req *cast.ListVideoScriptsReq
var err error
if err = ctx.ShouldBind(&req); err != nil {
service.Error(ctx, err)
return
}
newCtx := NewCtxWithUserInfo(ctx)
resp, err := service.CastProvider.ListVideoScripts(newCtx, req)
if err != nil {
service.Error(ctx, err)
return
}
titleList := []string{
"用户编号", "艺人", "艺人手机号", "引用次数", "状态", "脚本标题", "脚本内容", "创建人", "创建时间",
}
var dataList []interface{}
for _, task := range resp.Data {
data := []interface{}{
task.ArtistName,
task.ArtistName,
task.ArtistPhone,
task.QuoteCount,
videoScripMap[task.Status],
task.Title,
task.Content,
task.CreatorName,
task.CreatedDate,
}
dataList = append(dataList, &data)
}
content, err := utils.ToExcelByType(titleList, dataList, "slice", "")
if err != nil {
service.Error(ctx, errors.New("生成excel失败"))
}
utils.ResponseXls(ctx, content, fmt.Sprintf("视频脚本_%s.xlsx", time.Now().Format(time.DateTime)))
return
}
// DeleteVideoScript 删除视频脚本
func DeleteVideoScript(ctx *gin.Context) {
var req *cast.DeleteVideoScriptReq

View File

@ -1516,6 +1516,10 @@ func GetBalanceLayout(ctx *gin.Context) {
service.Success(ctx, j)
}
var (
EnableSecurityCheck = true //是否打开批量导入图文
)
func ImportWorkBatch(ctx *gin.Context) {
excelFile, err := ctx.FormFile("file")
var (
@ -1587,6 +1591,7 @@ func ImportWorkBatch(ctx *gin.Context) {
Source: 3,
}
var artistNum string
//检测艺人编号
if len(row) > 1 && utils.CleanString(row[1]) != "" {
artistNum = utils.CleanString(row[1])
artistSubNum := utils.CleanString(row[1])
@ -1608,7 +1613,6 @@ func ImportWorkBatch(ctx *gin.Context) {
Domain: "app",
})
//}
if err != nil {
temp.Remark = fmt.Sprintf("自媒体用户查询失败:%s", err.Error())
zap.L().Error("AccountFieeProvider.SubNumGetInfo", zap.Error(err))
@ -1627,44 +1631,37 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.ArtistPhoneAreaCode = subInfoResp.TelAreaCode
temp.ArtistSubNum = subInfoResp.SubNum
}
//检测标题
if len(row) > 7 {
temp.Title = utils.CleanString(row[7])
// 检查并截取 title 长度(支持中文)
titleRunes := []rune(temp.Title)
if len(titleRunes) > 600 {
temp.Title = string(titleRunes[:600])
}
ok, _err := check.SecurityText(temp.Title)
if _err != nil {
temp.Remark = _err.Error()
req.ImageWorks = append(req.ImageWorks, temp)
break
}
if !ok {
temp.Remark = "标题黄反审核未通过"
req.ImageWorks = append(req.ImageWorks, temp)
break
if EnableSecurityCheck {
_err := SecurityText(temp.Title)
if _err != nil {
temp.Remark = "标题黄反审核未通过"
req.ImageWorks = append(req.ImageWorks, temp)
break
}
}
}
//检测内容
if len(row) > 8 {
temp.Content = utils.CleanString(row[8])
if temp.Content != "" {
// 检查并截取 content 长度(支持中文)
contentRunes := []rune(temp.Content)
if len(contentRunes) > 600 {
temp.Content = string(contentRunes[:600])
}
ok, _err := check.SecurityText(temp.Content)
if _err != nil {
temp.Remark = _err.Error()
req.ImageWorks = append(req.ImageWorks, temp)
break
}
if !ok {
temp.Remark = "内容黄反审核未通过"
req.ImageWorks = append(req.ImageWorks, temp)
break
if EnableSecurityCheck {
_err := SecurityText(temp.Title)
if _err != nil {
temp.Remark = "标题黄反审核未通过"
req.ImageWorks = append(req.ImageWorks, temp)
break
}
}
// 处理内容中的标签:提取、验证并批量导入,以及自动生成标签
processedContent, err := processContentAndAutoTags(ctx, temp.Content)
@ -1677,6 +1674,7 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.Content = processedContent
}
}
//检测图片
for i := 10; i <= 20; i++ {
if len(row) > i {
if utils.CleanString(row[i]) != "" {
@ -1702,6 +1700,7 @@ func ImportWorkBatch(ctx *gin.Context) {
req.ImageWorks = append(req.ImageWorks, temp)
continue
}
//检测tiktok账号
if len(row) > 2 && utils.CleanString(row[2]) != "" {
mediaInfoResp, err = service.CastProvider.MediaInfo(context.Background(), &cast.MediaInfoReq{
ArtistUuid: temp.ArtistUuid,
@ -1731,6 +1730,7 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[2]))
temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
}
//检测ins账号
if len(row) > 3 && utils.CleanString(row[3]) != "" {
mediaInfoResp, err = service.CastProvider.MediaInfo(context.Background(), &cast.MediaInfoReq{
ArtistUuid: temp.ArtistUuid,
@ -1760,6 +1760,7 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[3]))
temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
}
//检测dm账号
if len(row) > 4 && utils.CleanString(row[4]) != "" {
temp.Remark = fmt.Sprintf("DM不能发图文")
zap.L().Error("CastProvider.MediaInfo", zap.Error(err))
@ -1788,7 +1789,7 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[4]))
temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)*/
}
// YouTube账号第F列row[5]
// 检测油管账号
if len(row) > 5 && utils.CleanString(row[5]) != "" {
temp.Remark = fmt.Sprintf("Youtube不能发图文")
zap.L().Error("CastProvider.MediaInfo", zap.Error(err))
@ -1817,7 +1818,7 @@ func ImportWorkBatch(ctx *gin.Context) {
// temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[5]))
// temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
}
// Bluesky账号第G列row[6]
//检测blueSky账号
if len(row) > 6 && utils.CleanString(row[6]) != "" {
mediaInfoResp, err = service.CastProvider.MediaInfo(context.Background(), &cast.MediaInfoReq{
ArtistUuid: temp.ArtistUuid,
@ -1847,6 +1848,7 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[6]))
temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
}
//最后检测数据
if artistNum == "" {
temp.Remark = "艺人编号不能为空"
req.ImageWorks = append(req.ImageWorks, temp)

View File

@ -9,6 +9,7 @@ import (
apiCast "fonchain-fiee/api/cast"
"fonchain-fiee/pkg/config"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/cast"
"image"
"image/draw"
"image/jpeg"
@ -654,27 +655,47 @@ func downloadAndUploadToBucket(imageURL string) (string, error) {
//url := fmt.Sprintf("%s/%s", config.ConfigData.Oss.CdnHost, fileName)
func (p *BatchProcessor) generateTitleAndContent(req *excelData) (string, string, error) {
var title, content string
var err error
if req.PhotoUrl != "" {
title, content, err := NewAiGenerator().GenerateTitleAndContentFromImage(
title, content, err = NewAiGenerator().GenerateTitleAndContentFromImage(
req.PhotoUrl,
req.TitleRequire,
req.ContentRequire,
)
if err != nil {
return "", "", fmt.Errorf("图生文失败: %v", err)
return "", "", fmt.Errorf("图生文失败: %w", err)
}
return title, content, nil
} else {
title, content, err := NewAiGenerator().GenerateTitleAndContentFromText(
title, content, err = NewAiGenerator().GenerateTitleAndContentFromText(
req.TitleRequire,
req.ContentRequire,
)
if err != nil {
return "", "", fmt.Errorf("生成内容失败: %v", err)
return "", "", fmt.Errorf("生成内容失败: %w", err)
}
return title, content, nil
}
if err = p.securityCheck(title, content); err != nil {
return "", "", err
}
return title, content, nil
}
func (p *BatchProcessor) securityCheck(title, content string) error {
// 标题审核
if err := cast.SecurityText(title); err != nil {
return fmt.Errorf("标题未通过黄反,原因:%w", err)
}
// 内容审核
if err := cast.SecurityText(content); err != nil {
return fmt.Errorf("内容未通过黄反,原因:%w", err)
}
return nil
}
func (p *BatchProcessor) generateImage(req *excelData) (string, error) {