Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/eta/1.8.3' into fix/1.8.3

Roc 7 mēneši atpakaļ
vecāks
revīzija
ba20ea5e62
2 mainītis faili ar 38 papildinājumiem un 0 dzēšanām
  1. 17 0
      models/report.go
  2. 21 0
      services/report_v2.go

+ 17 - 0
models/report.go

@@ -650,6 +650,23 @@ func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, play
 	return
 }
 
+// ModifyReportVideoByNoVideo
+// @Description: 修改无音频的报告音频信息
+// @author: Roc
+// @datetime 2024-07-25 18:03:05
+// @param reportId int
+// @param videoUrl string
+// @param videoName string
+// @param videoSize string
+// @param playSeconds float64
+// @return err error
+func ModifyReportVideoByNoVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? AND video_url=""`
+	_, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
+	return
+}
+
 type ReportItem struct {
 	Id                 int       `orm:"column(id)" description:"报告Id"`
 	AddType            int       `description:"新增方式:1:新增报告,2:继承报告"`

+ 21 - 0
services/report_v2.go

@@ -11,6 +11,7 @@ import (
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/file"
 	"github.com/rdlucklib/rdluck_tools/http"
+	"html"
 	"os"
 	"path"
 	"strconv"
@@ -1380,9 +1381,12 @@ func UpdateReportVideo(reportInfo *models.Report) {
 		if err != nil {
 			return
 		}
+
+		reportContent := ""
 		for _, chapter := range chapterList {
 			if chapter.PublishState == 2 {
 				reportChapterIdList = append(reportChapterIdList, chapter.ReportChapterId)
+				reportContent += chapter.Content
 			}
 		}
 		if len(reportChapterIdList) > 0 {
@@ -1391,6 +1395,23 @@ func UpdateReportVideo(reportInfo *models.Report) {
 				utils.FileLog.Info(fmt.Sprintf("%d报告音频生产失败:%s", reportInfo.Id, err.Error()))
 			}
 		}
+
+		// 生成汇总音频
+
+		{
+			if reportInfo.VideoUrl != "" && reportInfo.VideoName != "" && reportInfo.VideoSize != "" && reportInfo.VideoPlaySeconds != "" {
+				return
+			}
+			videoUrl, videoName, videoSize, videoPlaySeconds, e := CreateReportVideo(reportInfo.Title, html.UnescapeString(reportContent), time.Now().Format(utils.FormatDateTime))
+			if e != nil {
+				err = e
+				return
+			}
+
+			// 修改报告的音频信息
+			err = models.ModifyReportVideoByNoVideo(reportInfo.Id, videoUrl, videoName, videoSize, videoPlaySeconds)
+
+		}
 	} else {
 		err := CreateVideo(reportInfo)
 		if err != nil {