限制黄反长度
This commit is contained in:
commit
97d05aad91
File diff suppressed because it is too large
Load Diff
@ -28,17 +28,16 @@ import (
|
||||
// InitTasks 初始化定时任务
|
||||
func InitTasks() error {
|
||||
cm := GetCronManager()
|
||||
err := cm.AddTask("refreshWorkApprovalStatus", "0 */1 * * * *", RefreshApprovalStatusTask)
|
||||
err := cm.AddTask("refreshWorkApprovalStatus", "0 */5 * * * *", RefreshApprovalStatusTask)
|
||||
err = cm.AddTask("artistAutoConfirm", "0 */1 * * * *", ArtistAutoConfirmTask)
|
||||
err = cm.AddTask("refreshPublishStatus", "0 */5 * * * *", PublishTask)
|
||||
err = cm.AddTask("scheduledPublish", "0 */1 * * * *", ScheduledPublishTask) //FIXME正式30分钟一次
|
||||
err = cm.AddTask("scheduledPublish", "0 */30 * * * *", ScheduledPublishTask)
|
||||
|
||||
err = cm.AddTask("artistAutoConfirmAnalysis", "0 */1 * * * *", ArtistAutoConfirmAnalysisTask)
|
||||
err = cm.AddTask("refreshWorkAnalysisApprovalStatus", "0 */5 * * * *", RefreshWorkAnalysisApprovalStatusTask)
|
||||
err = cm.AddTask("artistAutoConfirmReport", "0 */1 * * * *", ArtistAutoConfirmReportTask)
|
||||
err = cm.AddTask("refreshCompetitiveReportApprovalStatus", "0 */5 * * * *", RefreshCompetitiveReportApprovalStatusTask)
|
||||
err = cm.AddTask("refreshArtistOrder", "0 */5 * * * *", RefreshArtistOrderTask)
|
||||
|
||||
//余量表每月1号更新定时任务
|
||||
err = cm.AddTask("updateBundleBalance", "0 0 0 1 * *", UpdateBundleBalance)
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ func AIChat(ctx *gin.Context) {
|
||||
service.Error(ctx, errors.New("参数错误 "))
|
||||
return
|
||||
}
|
||||
req.Seed = time.Now().UnixNano()
|
||||
req.Seed = time.Now().Unix()
|
||||
resp, err := qwen.Chat(req)
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
|
||||
@ -1236,7 +1236,8 @@ func CreatInvoice(c *gin.Context) {
|
||||
fmt.Println("发票时间数据获取完成")
|
||||
err = createInvoice(orderRecord.UserId, orderRecord.UserNum, orderRecord.UserName, orderRecord.Address, orderRecord.Phone, orderRecord.BundleName, orderRecord.OrderNo, "1", amountType, orderRecord.TotalAmount, payTimeString, payTimeString, applyTime)
|
||||
if err != nil {
|
||||
service.Error(c, errors.New("生成发票失败"))
|
||||
fmt.Println("生成发票失败:", err)
|
||||
service.Error(c, errors.New("生成发票失败:"+err.Error()))
|
||||
return
|
||||
}
|
||||
service.Success(c, "生成发票成功")
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fonchain-fiee/api/accountFiee"
|
||||
"fonchain-fiee/api/aryshare"
|
||||
"fonchain-fiee/api/bundle"
|
||||
"fonchain-fiee/api/cast"
|
||||
@ -17,6 +18,7 @@ import (
|
||||
"fonchain-fiee/pkg/utils"
|
||||
"fonchain-fiee/pkg/utils/stime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -511,13 +513,82 @@ func ArtistMetricsSeries(ctx *gin.Context) {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
if req.ArtistUUID == "" {
|
||||
service.Error(ctx, errors.New("参数错误"))
|
||||
return
|
||||
}
|
||||
|
||||
subNum := ""
|
||||
if strings.HasPrefix(strings.ToUpper(req.ArtistUUID), "FE") {
|
||||
subNum = req.ArtistUUID
|
||||
} else {
|
||||
artistID, err := strconv.ParseUint(req.ArtistUUID, 10, 64)
|
||||
if err != nil {
|
||||
service.Error(ctx, errors.New("艺人编号格式不正确"))
|
||||
return
|
||||
}
|
||||
infoResp, err := service.AccountFieeProvider.Info(context.Background(), &accountFiee.InfoRequest{
|
||||
ID: artistID,
|
||||
Domain: "app",
|
||||
})
|
||||
if err != nil {
|
||||
service.Error(ctx, errors.New("自媒体用户查询失败"))
|
||||
return
|
||||
}
|
||||
if infoResp == nil || infoResp.SubNum == "" {
|
||||
service.Error(ctx, errors.New("自媒体用户不存在"))
|
||||
return
|
||||
}
|
||||
subNum = infoResp.SubNum
|
||||
}
|
||||
|
||||
subInfoResp, err1 := service.AccountFieeProvider.SubNumGetInfo(context.Background(), &accountFiee.SubNumGetInfoRequest{
|
||||
SubNum: subNum,
|
||||
Domain: "app",
|
||||
})
|
||||
|
||||
if err1 != nil {
|
||||
err1 = errors.New("自媒体用户查询失败")
|
||||
service.Error(ctx, err1)
|
||||
return
|
||||
}
|
||||
if subInfoResp == nil || subInfoResp.Id == 0 {
|
||||
err1 = errors.New("自媒体用户不存在")
|
||||
service.Error(ctx, err1)
|
||||
return
|
||||
}
|
||||
req.ArtistUUID = fmt.Sprint(subInfoResp.Id)
|
||||
newCtx := NewCtxWithUserInfo(ctx)
|
||||
|
||||
var accountConsumptionNumber int32
|
||||
var videoCount int64
|
||||
var imageCount int64
|
||||
dataListResp, err := service.CastProvider.ArtistDataList(newCtx, &cast.ArtistDataListReq{
|
||||
SubNum: subNum,
|
||||
Page: 1,
|
||||
PageSize: 1,
|
||||
})
|
||||
if err == nil && dataListResp != nil && len(dataListResp.Data) > 0 && dataListResp.Data[0] != nil {
|
||||
accountConsumptionNumber = dataListResp.Data[0].AccountConsumptionNumber
|
||||
videoCount = dataListResp.Data[0].VideoCount
|
||||
imageCount = dataListResp.Data[0].ImageCount
|
||||
}
|
||||
|
||||
resp, err := service.CastProvider.ArtistMetricsSeries(newCtx, req)
|
||||
if err != nil {
|
||||
err = errors.New("查询失败")
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
service.Success(ctx, resp)
|
||||
|
||||
raw, _ := json.Marshal(resp)
|
||||
respMap := make(map[string]interface{})
|
||||
_ = json.Unmarshal(raw, &respMap)
|
||||
respMap["accountConsumptionNumber"] = accountConsumptionNumber
|
||||
respMap["videoCount"] = videoCount
|
||||
respMap["imageCount"] = imageCount
|
||||
|
||||
service.Success(ctx, respMap)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -7,138 +7,19 @@ import (
|
||||
"fonchain-fiee/api/aryshare"
|
||||
"fonchain-fiee/api/cast"
|
||||
"fonchain-fiee/cmd/config"
|
||||
"fonchain-fiee/pkg/common/qwen"
|
||||
modelQwen "fonchain-fiee/pkg/model/qwen"
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/service/check"
|
||||
"fonchain-fiee/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xuri/excelize/v2"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Test(ctx *gin.Context) {
|
||||
action := ctx.PostForm("action")
|
||||
if action == "" {
|
||||
// 打开Excel文件
|
||||
excelPath := "./data/脚本.xlsx"
|
||||
f, err := excelize.OpenFile(excelPath)
|
||||
if err != nil {
|
||||
service.Error(ctx, fmt.Errorf("打开Excel文件失败: %v", err))
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// 获取第一个工作表名称
|
||||
sheets := f.GetSheetList()
|
||||
if len(sheets) == 0 {
|
||||
service.Error(ctx, errors.New("Excel文件中没有工作表"))
|
||||
return
|
||||
}
|
||||
sheetName := sheets[0]
|
||||
|
||||
// 读取所有行
|
||||
rows, err := f.GetRows(sheetName)
|
||||
if err != nil {
|
||||
service.Error(ctx, fmt.Errorf("读取工作表失败: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
if len(rows) < 2 {
|
||||
service.Error(ctx, errors.New("Excel文件中没有数据行"))
|
||||
return
|
||||
}
|
||||
|
||||
// 找到"标题"和"脚本内容"列的索引
|
||||
header := rows[0]
|
||||
titleColIndex := -1
|
||||
scriptColIndex := -1
|
||||
|
||||
for i, cell := range header {
|
||||
if cell == "标题" {
|
||||
titleColIndex = i
|
||||
}
|
||||
if cell == "脚本内容" {
|
||||
scriptColIndex = i
|
||||
}
|
||||
}
|
||||
|
||||
if titleColIndex == -1 || scriptColIndex == -1 {
|
||||
service.Error(ctx, errors.New("未找到'标题'或'脚本'列"))
|
||||
return
|
||||
}
|
||||
|
||||
// 统计处理信息
|
||||
processedCount := 0
|
||||
errorCount := 0
|
||||
|
||||
// 遍历数据行(从第2行开始,跳过表头)
|
||||
for i := 1; i < len(rows); i++ {
|
||||
row := rows[i]
|
||||
|
||||
// 确保行至少有标题列
|
||||
if len(row) <= titleColIndex {
|
||||
continue
|
||||
}
|
||||
|
||||
title := row[titleColIndex]
|
||||
script := ""
|
||||
if len(row) > scriptColIndex {
|
||||
script = row[scriptColIndex]
|
||||
}
|
||||
|
||||
// 如果脚本列为空且标题不为空,则请求千问API
|
||||
if script == "" && title != "" {
|
||||
// 调用千问API生成脚本
|
||||
resp, err := qwen.Chat(modelQwen.ChatRequest{
|
||||
Model: "qwen3-max",
|
||||
Messages: []modelQwen.Message{
|
||||
{
|
||||
Role: "user",
|
||||
Content: []modelQwen.Content{
|
||||
{
|
||||
Type: "text",
|
||||
Text: fmt.Sprintf("请为以下标题生成一个视频脚本:\n%s,字数50-100,模板是这样的:山水清音,心旷神怡。远山如黛,近水含烟。笔墨间,山水清音,尽显自然之美。", title),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Seed: time.Now().UnixNano(),
|
||||
EnableSearch: false,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
// 记录错误但继续处理下一行
|
||||
errorCount++
|
||||
continue
|
||||
}
|
||||
|
||||
// 获取生成的脚本内容
|
||||
generatedScript := ""
|
||||
if len(resp.Choices) > 0 {
|
||||
generatedScript = resp.Choices[0].Message.Content
|
||||
}
|
||||
|
||||
// 将生成的脚本写入Excel
|
||||
cellName, _ := excelize.CoordinatesToCellName(scriptColIndex+1, i+1)
|
||||
if err := f.SetCellValue(sheetName, cellName, generatedScript); err != nil {
|
||||
errorCount++
|
||||
continue
|
||||
}
|
||||
processedCount++
|
||||
}
|
||||
}
|
||||
|
||||
// 保存Excel文件
|
||||
if err := f.Save(); err != nil {
|
||||
service.Error(ctx, fmt.Errorf("保存Excel文件失败: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
service.Success(ctx, map[string]interface{}{
|
||||
"message": "处理完成",
|
||||
"processed": processedCount,
|
||||
"errors": errorCount,
|
||||
"now": time.Now().Unix(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -64,6 +64,15 @@ func UpdateWorkImageCore(ctx *gin.Context, req *cast.UpdateWorkImageReq) (*cast.
|
||||
cache.RedisClient.Del(lockKey)
|
||||
}()
|
||||
fmt.Println(ok)
|
||||
// 检查并截取 title 和 content 长度(支持中文)
|
||||
titleRunes := []rune(req.Title)
|
||||
if len(titleRunes) > 600 {
|
||||
req.Title = string(titleRunes[:600])
|
||||
}
|
||||
contentRunes := []rune(req.Content)
|
||||
if len(contentRunes) > 600 {
|
||||
req.Content = string(contentRunes[:600])
|
||||
}
|
||||
if err = SecurityText(req.Title); err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("标题未通过黄反,原因:%s", err.Error()))
|
||||
}
|
||||
@ -298,6 +307,15 @@ func UpdateWorkVideoCore(ctx *gin.Context, req *cast.UpdateWorkVideoReq) (*cast.
|
||||
defer func() {
|
||||
cache.RedisClient.Del(lockKey)
|
||||
}()
|
||||
// 检查并截取 title 和 content 长度(支持中文)
|
||||
titleRunes := []rune(req.Title)
|
||||
if len(titleRunes) > 600 {
|
||||
req.Title = string(titleRunes[:600])
|
||||
}
|
||||
contentRunes := []rune(req.Content)
|
||||
if len(contentRunes) > 600 {
|
||||
req.Content = string(contentRunes[:600])
|
||||
}
|
||||
if err = SecurityText(req.Title); err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("标题未通过黄反,原因:%s", err.Error()))
|
||||
}
|
||||
@ -1600,6 +1618,11 @@ func ImportWorkBatch(ctx *gin.Context) {
|
||||
|
||||
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()
|
||||
@ -1615,6 +1638,11 @@ func ImportWorkBatch(ctx *gin.Context) {
|
||||
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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user