Browse Source

Merge branch 'fix/1.8.3'

Roc 7 months ago
parent
commit
a660b481bb

+ 7 - 1
controllers/report_chapter.go

@@ -255,6 +255,7 @@ func (this *ReportController) EditChapterBaseInfoAndPermission() {
 	if reportInfo.State == 2 {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 
@@ -370,6 +371,7 @@ func (this *ReportController) EditDayWeekChapter() {
 	if reportInfo.State == 2 {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 	// 报告的最后编辑人
@@ -558,6 +560,7 @@ func (this *ReportController) DelChapter() {
 	if reportInfo.State == 2 {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 
@@ -1228,8 +1231,9 @@ func (this *ReportController) VoiceUpload() {
 		reportChapterInfo.VideoKind = 1
 		reportChapterInfo.LastModifyAdminId = this.SysUser.AdminId
 		reportChapterInfo.LastModifyAdminName = this.SysUser.RealName
+		reportInfo.VoiceGenerateType = 1
 		reportChapterInfo.ModifyTime = time.Now()
-		err = reportChapterInfo.UpdateChapter([]string{"VideoUrl", "VideoName", "VideoPlaySeconds", "VideoSize", "VideoKind", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime"})
+		err = reportChapterInfo.UpdateChapter([]string{"VideoUrl", "VideoName", "VideoPlaySeconds", "VideoSize", "VideoKind", "LastModifyAdminId", "LastModifyAdminName", "VoiceGenerateType", "ModifyTime"})
 		if err != nil {
 			br.Msg = "上传失败"
 			br.ErrMsg = "修改报告章节的音频信息失败,Err:" + err.Error()
@@ -1310,6 +1314,7 @@ func (this *ReportController) PublishDayWeekReportChapter() {
 	if reportInfo.State == 2 {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 
@@ -1577,6 +1582,7 @@ func (this *ReportController) EditChapterTitle() {
 	if reportInfo.State == 2 {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 	// 报告的最后编辑人

+ 3 - 0
controllers/report_v2.go

@@ -567,6 +567,7 @@ func (this *ReportController) Edit() {
 	if reportInfo.State == models.ReportStatePublished || reportInfo.State == models.ReportStatePass {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 
@@ -736,6 +737,7 @@ func (this *ReportController) SaveReportContent() {
 	if reportInfo != nil && reportInfo.State == 2 {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 
@@ -1144,6 +1146,7 @@ func (this *ReportController) EditLayoutImg() {
 	if reportInfo.State == models.ReportStatePublished || reportInfo.State == models.ReportStatePass {
 		br.Msg = "该报告已发布,不允许编辑"
 		br.ErrMsg = "该报告已发布,不允许编辑"
+		br.IsSendEmail = false
 		return
 	}
 

+ 2 - 1
controllers/voice.go

@@ -150,8 +150,9 @@ func (this *VoiceController) Upload() {
 		reportInfo.VideoSize = sizeStr
 		reportInfo.LastModifyAdminId = this.SysUser.AdminId
 		reportInfo.LastModifyAdminName = this.SysUser.RealName
+		reportInfo.VoiceGenerateType = 1
 		reportInfo.ModifyTime = time.Now()
-		err = reportInfo.UpdateReport([]string{"VideoUrl", "VideoName", "VideoPlaySeconds", "VideoSize", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime"})
+		err = reportInfo.UpdateReport([]string{"VideoUrl", "VideoName", "VideoPlaySeconds", "VideoSize", "LastModifyAdminId", "LastModifyAdminName", "VoiceGenerateType", "ModifyTime"})
 		if err != nil {
 			br.Msg = "上传失败"
 			br.ErrMsg = "修改报告的音频信息失败,Err:" + err.Error()

+ 35 - 34
models/classify.go

@@ -9,40 +9,41 @@ import (
 )
 
 type Classify struct {
-	Id                int       `orm:"column(id);pk"`
-	ClassifyName      string    `description:"分类名称"`
-	Sort              int       `json:"-"`
-	ParentId          int       `description:"父级分类id"`
-	CreateTime        time.Time `description:"创建时间"`
-	ModifyTime        time.Time `description:"修改时间"`
-	Abstract          string    `description:"栏目简介"`
-	Descript          string    `description:"分享描述"`
-	ReportAuthor      string    `description:"栏目作者"`
-	AuthorDescript    string    `description:"作者简介"`
-	ColumnImgUrl      string    `description:"栏目配图"`
-	HeadImgUrl        string    `description:"头部banner"`
-	AvatarImgUrl      string    `description:"头像"`
-	ReportImgUrl      string    `description:"报告配图"`
-	HomeImgUrl        string    `description:"首页配图"`
-	ClassifyLabel     string    `description:"分类标签"`
-	ShowType          int       `description:"展示类型:1-列表 2-专栏"`
-	HasTeleconference int       `description:"是否有电话会:0-否 1-是"`
-	VipTitle          string    `description:"研究员头衔"`
-	IsShow            int       `description:"是否在小程序显示:1-显示 0-隐藏"`
-	YbFiccSort        int       `description:"小程序FICC页排序"`
-	YbFiccIcon        string    `description:"小程序FICC页icon"`
-	YbFiccPcIcon      string    `description:"小程序PC端FICC页背景图"`
-	YbIconUrl         string    `description:"小程序已购页icon"`
-	YbBgUrl           string    `description:"小程序已购详情背景图"`
-	YbListImg         string    `description:"小程序研报列表封面图"`
-	YbShareBgImg      string    `description:"小程序研报详情分享背景图"`
-	YbRightBanner     string    `description:"Pc端详情页,右侧,报告合集背景图"`
-	RelateTel         int       `description:"是否在电话会中可选: 0-否; 1-是"`
-	RelateVideo       int       `description:"是否在路演视频中可选: 0-否; 1-是"`
-	IsMassSend        int       `description:"1:群发,0:非群发"`
-	Enabled           int       `description:"是否可用,1可用,0禁用"`
-	Level             int       `description:"层级"`
-	HasChild          int       `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
+	Id                   int       `orm:"column(id);pk"`
+	ClassifyName         string    `description:"分类名称"`
+	Sort                 int       `json:"-"`
+	ParentId             int       `description:"父级分类id"`
+	CreateTime           time.Time `description:"创建时间"`
+	ModifyTime           time.Time `description:"修改时间"`
+	Abstract             string    `description:"栏目简介"`
+	Descript             string    `description:"分享描述"`
+	ReportAuthor         string    `description:"栏目作者"`
+	AuthorDescript       string    `description:"作者简介"`
+	ColumnImgUrl         string    `description:"栏目配图"`
+	HeadImgUrl           string    `description:"头部banner"`
+	AvatarImgUrl         string    `description:"头像"`
+	ReportImgUrl         string    `description:"报告配图"`
+	HomeImgUrl           string    `description:"首页配图"`
+	ClassifyLabel        string    `description:"分类标签"`
+	ShowType             int       `description:"展示类型:1-列表 2-专栏"`
+	HasTeleconference    int       `description:"是否有电话会:0-否 1-是"`
+	VipTitle             string    `description:"研究员头衔"`
+	IsShow               int       `description:"是否在小程序显示:1-显示 0-隐藏"`
+	YbFiccSort           int       `description:"小程序FICC页排序"`
+	YbFiccIcon           string    `description:"小程序FICC页icon"`
+	YbFiccPcIcon         string    `description:"小程序PC端FICC页背景图"`
+	YbIconUrl            string    `description:"小程序已购页icon"`
+	YbBgUrl              string    `description:"小程序已购详情背景图"`
+	YbListImg            string    `description:"小程序研报列表封面图"`
+	YbShareBgImg         string    `description:"小程序研报详情分享背景图"`
+	YbRightBanner        string    `description:"Pc端详情页,右侧,报告合集背景图"`
+	RelateTel            int       `description:"是否在电话会中可选: 0-否; 1-是"`
+	RelateVideo          int       `description:"是否在路演视频中可选: 0-否; 1-是"`
+	IsMassSend           int       `description:"1:群发,0:非群发"`
+	Enabled              int       `description:"是否可用,1可用,0禁用"`
+	Level                int       `description:"层级"`
+	HasChild             int       `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
+	ReportDetailShowType int       `description:"报告详情的展示类型:1-拼接;2:目录"`
 }
 
 type ClassifyAddReq struct {

+ 19 - 1
models/report.go

@@ -86,6 +86,7 @@ type Report struct {
 	IsPublicPublish     int8      `description:"是否公开发布,1:是,2:否"`
 	ReportCreateTime    time.Time `description:"报告时间创建时间"`
 	InheritReportId     int       `description:"待继承的报告ID"`
+	VoiceGenerateType   int       `description:"音频生成方式,0:系统生成,1:人工上传"`
 }
 
 type ReportList struct {
@@ -650,6 +651,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:继承报告"`
@@ -705,7 +723,7 @@ func EditReportContent(reportId int, content, contentSub string) (err error) {
 
 func AddReportSaveLog(reportId, adminId int, content, contentSub, contentStruct, canvasColor, adminName string, headResourceId, endResourceId int) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := ` INSERT INTO report_save_log(report_id, content,content_sub,content_struct,canvas_color,head_resource_id,end_resource_id,admin_id,admin_name) VALUES (?,?,?,?,?) `
+	sql := ` INSERT INTO report_save_log(report_id, content,content_sub,content_struct,canvas_color,head_resource_id,end_resource_id,admin_id,admin_name) VALUES (?,?,?,?,?,?,?,?,?) `
 	_, err = o.Raw(sql, reportId, content, contentSub, contentStruct, canvasColor, headResourceId, endResourceId, adminId, adminName).Exec()
 	return
 }

+ 1 - 0
models/report_chapter.go

@@ -42,6 +42,7 @@ type ReportChapter struct {
 	ContentModifyTime   time.Time `description:"内容更新时间"`
 	ReportLayout        int8      `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
 	ReportCreateTime    time.Time `description:"报告时间创建时间"`
+	VoiceGenerateType   int       `description:"音频生成方式,0:系统生成,1:人工上传"`
 }
 
 // ReportChapterItem 报告章节详情

+ 2 - 1
services/classify.go

@@ -265,7 +265,8 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
 	classify.ModifyTime = nowTime
 	classify.Sort = maxSort + 1
 	classify.Enabled = 1
-	classify.ShowType = 1 //默认列表格式
+	classify.ShowType = 1             //默认列表格式
+	classify.ReportDetailShowType = 1 //默认列表格式
 	classify.IsShow = 1
 	classify.Level = level
 	/*classify.Abstract = req.Abstract

+ 22 - 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,13 @@ 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.Title + `。`
+				reportContent += chapter.Content + `。`
 			}
 		}
 		if len(reportChapterIdList) > 0 {
@@ -1391,6 +1396,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 {