Browse Source

Merge branch 'gn_2.6_add_ppt_cover_1121@guomengyuan' into debug

gmy 4 months ago
parent
commit
5242004bc4
3 changed files with 122 additions and 97 deletions
  1. 6 0
      controllers/ppt_report.go
  2. 37 27
      controllers/ppt_v2.go
  3. 79 70
      models/ppt_v2.go

+ 6 - 0
controllers/ppt_report.go

@@ -390,6 +390,9 @@ func (this *PptV2Controller) CreateReport() {
 		newItem.BackgroundImg = inheritPpt.BackgroundImg
 		newItem.CurrentBackgroundImg = inheritPpt.CurrentBackgroundImg
 		newItem.BackCoverImg = inheritPpt.BackCoverImg
+		newItem.CurrentBackgroundImgId = inheritPpt.CurrentBackgroundImgId
+		newItem.BackCoverImgId = inheritPpt.BackCoverImgId
+		newItem.BackgroundImgId = inheritPpt.BackgroundImgId
 		newItem.ReportType = inheritPpt.ReportType
 		newItem.PptDate = inheritPpt.PptDate
 		newItem.Content = inheritPpt.Content
@@ -403,6 +406,9 @@ func (this *PptV2Controller) CreateReport() {
 		newItem.BackgroundImg = req.FirstPage.ImgUrl
 		newItem.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
 		newItem.BackCoverImg = req.FirstPage.BackCoverImg
+		newItem.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
+		newItem.BackCoverImgId = req.FirstPage.BackCoverImgId
+		newItem.BackgroundImgId = req.FirstPage.BackgroundImgId
 		newItem.ReportType = req.FirstPage.ReportType
 		newItem.PptDate = req.FirstPage.PptDate
 		newItem.Content = req.Content

+ 37 - 27
controllers/ppt_v2.go

@@ -257,6 +257,9 @@ func (this *PptV2Controller) EditPpt() {
 	pptInfo.BackgroundImg = req.FirstPage.ImgUrl
 	pptInfo.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
 	pptInfo.BackCoverImg = req.FirstPage.BackCoverImg
+	pptInfo.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
+	pptInfo.BackCoverImgId = req.FirstPage.BackCoverImgId
+	pptInfo.BackgroundImgId = req.FirstPage.BackgroundImgId
 	pptInfo.Title = req.FirstPage.Title
 	pptInfo.ReportType = req.FirstPage.ReportType
 	pptInfo.PptDate = req.FirstPage.PptDate
@@ -264,7 +267,7 @@ func (this *PptV2Controller) EditPpt() {
 	pptInfo.CoverContent = req.CoverContent
 	pptInfo.ModifyTime = time.Now()
 	pptInfo.TitleSetting = req.TitleSetting
-	err = pptInfo.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "CoverContent", "TitleSetting"})
+	err = pptInfo.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "CurrentBackgroundImgId", "BackCoverImgId", "BackgroundImgId", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "CoverContent", "TitleSetting"})
 	if err != nil {
 		br.Msg = "编辑失败"
 		br.ErrMsg = "编辑失败,Err:" + err.Error()
@@ -322,17 +325,19 @@ func (this *PptV2Controller) EditPpt() {
 	// 日志记录
 	{
 		logInfo := &models.PptV2SaveLog{
-			PptId:         pptInfo.PptId,
-			TemplateType:  pptInfo.TemplateType,
-			BackgroundImg: pptInfo.BackgroundImg,
-			Title:         pptInfo.Title,
-			ReportType:    pptInfo.ReportType,
-			PptDate:       pptInfo.PptDate,
-			Content:       pptInfo.Content,
-			CoverContent:  pptInfo.CoverContent,
-			AdminId:       this.SysUser.AdminId,
-			AdminRealName: this.SysUser.RealName,
-			CreateTime:    time.Now(),
+			PptId:                pptInfo.PptId,
+			TemplateType:         pptInfo.TemplateType,
+			BackgroundImg:        pptInfo.BackgroundImg,
+			CurrentBackgroundImg: pptInfo.CurrentBackgroundImg,
+			BackCoverImg:         pptInfo.BackCoverImg,
+			Title:                pptInfo.Title,
+			ReportType:           pptInfo.ReportType,
+			PptDate:              pptInfo.PptDate,
+			Content:              pptInfo.Content,
+			CoverContent:         pptInfo.CoverContent,
+			AdminId:              this.SysUser.AdminId,
+			AdminRealName:        this.SysUser.RealName,
+			CreateTime:           time.Now(),
 		}
 		_, err = models.AddPptV2SaveLog(logInfo)
 	}
@@ -788,8 +793,11 @@ func (this *PptV2Controller) SaveLog() {
 	}
 	pptItem.TemplateType = req.FirstPage.TemplateType
 	pptItem.BackgroundImg = req.FirstPage.ImgUrl
-	pptItem.CurrentBackgroundImg = req.CurrentBackgroundImg
-	pptItem.BackCoverImg = req.BackCoverImg
+	pptItem.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
+	pptItem.BackCoverImg = req.FirstPage.BackCoverImg
+	pptItem.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
+	pptItem.BackCoverImgId = req.FirstPage.BackCoverImgId
+	pptItem.BackgroundImgId = req.FirstPage.BackgroundImgId
 	pptItem.Title = req.FirstPage.Title
 	pptItem.ReportType = req.FirstPage.ReportType
 	pptItem.PptDate = req.FirstPage.PptDate
@@ -797,7 +805,7 @@ func (this *PptV2Controller) SaveLog() {
 	pptItem.ModifyTime = time.Now()
 	pptItem.TitleSetting = req.TitleSetting
 	pptItem.PptPage = len(pptContent)
-	err = pptItem.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "TitleSetting", "ppt_page"})
+	err = pptItem.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "CurrentBackgroundImgId", "BackCoverImgId", "BackgroundImgId", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "TitleSetting", "ppt_page"})
 	if err != nil {
 		br.Msg = "自动保存失败"
 		br.ErrMsg = fmt.Sprintf("自动保存PPT失败, ID: %d, Err: %v", pptItem.PptId, err)
@@ -835,18 +843,20 @@ func (this *PptV2Controller) SaveLog() {
 
 	//日志记录
 	logInfo := &models.PptV2SaveLog{
-		PptId:         int(req.PptId),
-		TemplateType:  req.FirstPage.TemplateType,
-		BackgroundImg: req.FirstPage.ImgUrl,
-		Title:         req.FirstPage.Title,
-		ReportType:    req.FirstPage.ReportType,
-		PptDate:       req.FirstPage.PptDate,
-		Content:       req.Content,
-		CoverContent:  req.CoverContent,
-		AdminId:       this.SysUser.AdminId,
-		AdminRealName: this.SysUser.RealName,
-		CreateTime:    time.Now(),
-		TitleSetting:  req.TitleSetting,
+		PptId:                int(req.PptId),
+		TemplateType:         req.FirstPage.TemplateType,
+		BackgroundImg:        req.FirstPage.ImgUrl,
+		CurrentBackgroundImg: req.FirstPage.CurrentBackgroundImg,
+		BackCoverImg:         req.FirstPage.BackCoverImg,
+		Title:                req.FirstPage.Title,
+		ReportType:           req.FirstPage.ReportType,
+		PptDate:              req.FirstPage.PptDate,
+		Content:              req.Content,
+		CoverContent:         req.CoverContent,
+		AdminId:              this.SysUser.AdminId,
+		AdminRealName:        this.SysUser.RealName,
+		CreateTime:           time.Now(),
+		TitleSetting:         req.TitleSetting,
 	}
 	_, e = models.AddPptV2SaveLog(logInfo)
 	if e != nil {

+ 79 - 70
models/ppt_v2.go

@@ -12,41 +12,44 @@ import (
 
 // PptV2 表
 type PptV2 struct {
-	PptId                int       `gorm:"column:ppt_id;primaryKey;autoIncrement:true" description:"ppt的Id"`
-	TemplateType         int       `gorm:"column:template_type" description:"模版类型"`
-	BackgroundImg        string    `gorm:"column:background_img" description:"现在实际存的封面图(前端改动太大,不知道该字段之前谁定义的)"`
-	Title                string    `gorm:"column:title" description:"标题"`
-	ReportType           string    `gorm:"column:report_type" description:"报告类型"`
-	PptDate              string    `gorm:"column:ppt_date" description:"选择日期"`
-	Content              string    `gorm:"column:content" description:"ppt内容"`
-	PptUrl               string    `gorm:"column:ppt_url" description:"ppt下载地址"`
-	PptxUrl              string    `gorm:"column:pptx_url" description:"pptx下载地址"`
-	CreateTime           time.Time `gorm:"column:create_time" description:"创建时间"`
-	ModifyTime           time.Time `gorm:"column:modify_time" description:"修改时间"`
-	AdminId              int       `gorm:"column:admin_id" description:"系统用户id"`
-	AdminRealName        string    `gorm:"column:admin_real_name" description:"系统用户名称"`
-	PptVersion           int8      `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
-	ReportId             int       `gorm:"column:report_id" description:"关联的报告ID"`
-	ReportCode           string    `gorm:"column:report_code" description:"关联的报告code"`
-	IsShare              int8      `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
-	PublishTime          time.Time `gorm:"column:publish_time" description:"发布时间"`
-	CoverContent         string    `gorm:"column:cover_content" description:"PPT内容-JSON"`
-	PptPage              int       `gorm:"column:ppt_page" description:"PPT页数"`
-	TitleSetting         string    `gorm:"column:title_setting" description:"PPT标题设置"`
-	ClassifyId           int       `gorm:"column:classify_id" description:"报告分类ID"`
-	AddType              int       `gorm:"column:add_type" description:"新增方式:1-新增报告;2-继承报告"`
-	InheritReportId      int       `gorm:"column:inherit_report_id" description:"继承的报告ID"`
-	CollaborateType      int       `gorm:"column:collaborate_type" description:"协作方式:1-个人;2-多人协作"`
-	CollaborateUsers     string    `gorm:"column:collaborate_users" description:"协作人IDs, 英文逗号分隔"`
-	IsPublicPublish      int       `gorm:"column:is_public_publish" description:"是否公开发布:1-是;2-否"`
-	SubmitTime           time.Time `gorm:"column:submit_time" description:"提交时间"`
-	ApproveTime          time.Time `gorm:"column:approve_time" description:"审批时间"`
-	ReportSource         int       `gorm:"column:report_source" description:"报告来源:1-系统内;2-智力共享"`
-	OutReportId          string    `gorm:"column:out_report_id" description:"外部报告ID(或编码)"`
-	State                int       `gorm:"column:state" description:"报告状态:1-未发布;2-已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
-	TopicEndTime         time.Time `gorm:"column:topic_end_time" description:"课题结束时间"`
-	CurrentBackgroundImg string    `gorm:"column:current_background_img" description:"背景图片"`
-	BackCoverImg         string    `gorm:"column:back_cover_img" description:"封底图片"`
+	PptId                  int       `gorm:"column:ppt_id;primaryKey;autoIncrement:true" description:"ppt的Id"`
+	TemplateType           int       `gorm:"column:template_type" description:"模版类型"`
+	BackgroundImg          string    `gorm:"column:background_img" description:"现在实际存的封面图(前端改动太大,不知道该字段之前谁定义的)"`
+	Title                  string    `gorm:"column:title" description:"标题"`
+	ReportType             string    `gorm:"column:report_type" description:"报告类型"`
+	PptDate                string    `gorm:"column:ppt_date" description:"选择日期"`
+	Content                string    `gorm:"column:content" description:"ppt内容"`
+	PptUrl                 string    `gorm:"column:ppt_url" description:"ppt下载地址"`
+	PptxUrl                string    `gorm:"column:pptx_url" description:"pptx下载地址"`
+	CreateTime             time.Time `gorm:"column:create_time" description:"创建时间"`
+	ModifyTime             time.Time `gorm:"column:modify_time" description:"修改时间"`
+	AdminId                int       `gorm:"column:admin_id" description:"系统用户id"`
+	AdminRealName          string    `gorm:"column:admin_real_name" description:"系统用户名称"`
+	PptVersion             int8      `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
+	ReportId               int       `gorm:"column:report_id" description:"关联的报告ID"`
+	ReportCode             string    `gorm:"column:report_code" description:"关联的报告code"`
+	IsShare                int8      `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
+	PublishTime            time.Time `gorm:"column:publish_time" description:"发布时间"`
+	CoverContent           string    `gorm:"column:cover_content" description:"PPT内容-JSON"`
+	PptPage                int       `gorm:"column:ppt_page" description:"PPT页数"`
+	TitleSetting           string    `gorm:"column:title_setting" description:"PPT标题设置"`
+	ClassifyId             int       `gorm:"column:classify_id" description:"报告分类ID"`
+	AddType                int       `gorm:"column:add_type" description:"新增方式:1-新增报告;2-继承报告"`
+	InheritReportId        int       `gorm:"column:inherit_report_id" description:"继承的报告ID"`
+	CollaborateType        int       `gorm:"column:collaborate_type" description:"协作方式:1-个人;2-多人协作"`
+	CollaborateUsers       string    `gorm:"column:collaborate_users" description:"协作人IDs, 英文逗号分隔"`
+	IsPublicPublish        int       `gorm:"column:is_public_publish" description:"是否公开发布:1-是;2-否"`
+	SubmitTime             time.Time `gorm:"column:submit_time" description:"提交时间"`
+	ApproveTime            time.Time `gorm:"column:approve_time" description:"审批时间"`
+	ReportSource           int       `gorm:"column:report_source" description:"报告来源:1-系统内;2-智力共享"`
+	OutReportId            string    `gorm:"column:out_report_id" description:"外部报告ID(或编码)"`
+	State                  int       `gorm:"column:state" description:"报告状态:1-未发布;2-已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
+	TopicEndTime           time.Time `gorm:"column:topic_end_time" description:"课题结束时间"`
+	CurrentBackgroundImg   string    `gorm:"column:current_background_img" description:"背景图片"`
+	BackCoverImg           string    `gorm:"column:back_cover_img" description:"封底图片"`
+	CurrentBackgroundImgId int       `gorm:"column:current_background_img_id" description:"背景图片id"`
+	BackCoverImgId         int       `gorm:"column:back_cover_img_id" description:"封底图片id"`
+	BackgroundImgId        int       `gorm:"column:background_img_id" description:"封面图id"`
 }
 
 type PptV2Item struct {
@@ -129,21 +132,22 @@ func DeletePptV2(pptId int) (err error) {
 type AddPptV2Req struct {
 	PptId     int64 `description:"ppt_id"`
 	FirstPage struct {
-		Title                string `description:"标题"`
-		ReportType           string `description:"类型"`
-		PptDate              string `description:"日期"`
-		ImgUrl               string `description:"封面图片"`
-		CurrentBackgroundImg string `description:"背景图片"`
-		BackCoverImg         string `description:"封底图片"`
-		BackIndex            int    `description:"背景图片下标"`
-		TemplateType         int    `description:"模版id"`
+		Title                  string `description:"标题"`
+		ReportType             string `description:"类型"`
+		PptDate                string `description:"日期"`
+		ImgUrl                 string `description:"封面图片"`
+		CurrentBackgroundImg   string `description:"背景图片"`
+		BackCoverImg           string `description:"封底图片"`
+		CurrentBackgroundImgId int    `description:"背景图片id"`
+		BackCoverImgId         int    `description:"封底图片id"`
+		BackgroundImgId        int    `description:"封面图id"`
+		BackIndex              int    `description:"背景图片下标"`
+		TemplateType           int    `description:"模版id"`
 	} `description:"首页"`
-	Content              string `description:"ppt的json数据"`
-	GroupId              int64  `description:"目录id"`
-	CoverContent         string `description:"封面图内容-JSON数据"`
-	TitleSetting         string `description:"PPT标题设置"`
-	CurrentBackgroundImg string `description:"背景图片"`
-	BackCoverImg         string `description:"封底图片"`
+	Content      string `description:"ppt的json数据"`
+	GroupId      int64  `description:"目录id"`
+	CoverContent string `description:"封面图内容-JSON数据"`
+	TitleSetting string `description:"PPT标题设置"`
 }
 
 type AddPptResp struct {
@@ -201,19 +205,21 @@ func AddPptV2PublishRecord(item *PptV2PublishRecord) (lastId int64, err error) {
 
 // PptV2SaveLog ppt记录表
 type PptV2SaveLog struct {
-	Id            int       `gorm:"column:id;primaryKey;autoIncrement" description:"自增Id"`
-	PptId         int       `gorm:"column:ppt_id" description:"ppt的Id"`
-	TemplateType  int       `gorm:"column:template_type" description:"模版类型"`
-	BackgroundImg string    `gorm:"column:background_img" description:"背景图片"`
-	Title         string    `gorm:"column:title" description:"标题"`
-	ReportType    string    `gorm:"column:report_type" description:"报告类型"`
-	PptDate       string    `gorm:"column:ppt_date" description:"选择日期"`
-	Content       string    `gorm:"column:content" description:"ppt内容"`
-	AdminId       int       `gorm:"column:admin_id" description:"系统用户id"`
-	AdminRealName string    `gorm:"column:admin_real_name" description:"系统用户名称"`
-	CreateTime    time.Time `gorm:"column:create_time" description:"创建时间"`
-	CoverContent  string    `gorm:"column:cover_content" description:"PPT内容-JSON"`
-	TitleSetting  string    `gorm:"column:title_setting" description:"PPT标题设置"`
+	Id                   int       `gorm:"column:id;primaryKey;autoIncrement" description:"自增Id"`
+	PptId                int       `gorm:"column:ppt_id" description:"ppt的Id"`
+	TemplateType         int       `gorm:"column:template_type" description:"模版类型"`
+	BackgroundImg        string    `gorm:"column:background_img" description:"背景图片"`
+	Title                string    `gorm:"column:title" description:"标题"`
+	ReportType           string    `gorm:"column:report_type" description:"报告类型"`
+	PptDate              string    `gorm:"column:ppt_date" description:"选择日期"`
+	Content              string    `gorm:"column:content" description:"ppt内容"`
+	AdminId              int       `gorm:"column:admin_id" description:"系统用户id"`
+	AdminRealName        string    `gorm:"column:admin_real_name" description:"系统用户名称"`
+	CreateTime           time.Time `gorm:"column:create_time" description:"创建时间"`
+	CoverContent         string    `gorm:"column:cover_content" description:"PPT内容-JSON"`
+	TitleSetting         string    `gorm:"column:title_setting" description:"PPT标题设置"`
+	CurrentBackgroundImg string    `gorm:"column:current_background_img" description:"背景图片"`
+	BackCoverImg         string    `gorm:"column:back_cover_img" description:"封底图片"`
 }
 
 // AddPptV2SaveLog 新增PPT日志
@@ -448,14 +454,17 @@ type PptReportCreateReq struct {
 	CollaborateType    int    `description:"协作方式,1:个人,2:多人协作。默认:1"`
 	CollaborateUserIds []int  `description:"协作人IDs"`
 	FirstPage          struct {
-		Title                string `description:"标题"`
-		ReportType           string `description:"类型"`
-		PptDate              string `description:"日期"`
-		ImgUrl               string `description:"图片"`
-		CurrentBackgroundImg string `description:"背景图片"`
-		BackCoverImg         string `description:"封底图片"`
-		BackIndex            int    `description:"背景图片下标"`
-		TemplateType         int    `description:"模版id"`
+		Title                  string `description:"标题"`
+		ReportType             string `description:"类型"`
+		PptDate                string `description:"日期"`
+		ImgUrl                 string `description:"图片"`
+		CurrentBackgroundImg   string `description:"背景图片"`
+		BackCoverImg           string `description:"封底图片"`
+		CurrentBackgroundImgId int    `description:"背景图片id"`
+		BackCoverImgId         int    `description:"封底图片id"`
+		BackgroundImgId        int    `description:"封面图id"`
+		BackIndex              int    `description:"背景图片下标"`
+		TemplateType           int    `description:"模版id"`
 	} `description:"首页"`
 	Content      string `description:"ppt的json数据"`
 	CoverContent string `description:"封面图内容-JSON数据"`