Compare commits

..

No commits in common. "8d2cdd958d749d3204d498932aff53560cefa6b6" and "492446e39bda143bec297717ee898dc8cfdf5c42" have entirely different histories.

5 changed files with 33 additions and 102 deletions

View File

@ -64,7 +64,6 @@ 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,7 +77,6 @@ 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,50 +124,6 @@ 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,10 +1516,6 @@ func GetBalanceLayout(ctx *gin.Context) {
service.Success(ctx, j)
}
var (
EnableSecurityCheck = true //是否打开批量导入图文
)
func ImportWorkBatch(ctx *gin.Context) {
excelFile, err := ctx.FormFile("file")
var (
@ -1591,7 +1587,6 @@ 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])
@ -1613,6 +1608,7 @@ 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))
@ -1631,37 +1627,44 @@ 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])
}
if EnableSecurityCheck {
_err := SecurityText(temp.Title)
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 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])
}
if EnableSecurityCheck {
_err := SecurityText(temp.Title)
ok, _err := check.SecurityText(temp.Content)
if _err != nil {
temp.Remark = "标题黄反审核未通过"
temp.Remark = _err.Error()
req.ImageWorks = append(req.ImageWorks, temp)
break
}
if !ok {
temp.Remark = "内容黄反审核未通过"
req.ImageWorks = append(req.ImageWorks, temp)
break
}
// 处理内容中的标签:提取、验证并批量导入,以及自动生成标签
processedContent, err := processContentAndAutoTags(ctx, temp.Content)
@ -1674,7 +1677,6 @@ func ImportWorkBatch(ctx *gin.Context) {
temp.Content = processedContent
}
}
//检测图片
for i := 10; i <= 20; i++ {
if len(row) > i {
if utils.CleanString(row[i]) != "" {
@ -1700,7 +1702,6 @@ 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,
@ -1730,7 +1731,6 @@ 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,7 +1760,6 @@ 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))
@ -1789,7 +1788,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))
@ -1818,7 +1817,7 @@ func ImportWorkBatch(ctx *gin.Context) {
// temp.MediaAccountNames = append(temp.MediaAccountNames, utils.CleanString(row[5]))
// temp.MediaAccountUuids = append(temp.MediaAccountUuids, mediaInfoResp.Info.MediaAccountUuid)
}
//检测blueSky账号
// Bluesky账号第G列row[6]
if len(row) > 6 && utils.CleanString(row[6]) != "" {
mediaInfoResp, err = service.CastProvider.MediaInfo(context.Background(), &cast.MediaInfoReq{
ArtistUuid: temp.ArtistUuid,
@ -1848,7 +1847,6 @@ 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,7 +9,6 @@ import (
apiCast "fonchain-fiee/api/cast"
"fonchain-fiee/pkg/config"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/cast"
"image"
"image/draw"
"image/jpeg"
@ -655,47 +654,27 @@ 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("图生文失败: %w", err)
return "", "", fmt.Errorf("图生文失败: %v", 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("生成内容失败: %w", err)
return "", "", fmt.Errorf("生成内容失败: %v", err)
}
}
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) {