Sfoglia il codice sorgente

Merge branch 'gn_2.6_add_ppt_cover_1121@guomengyuan'

# Conflicts:
#	controllers/ppt_v2.go
#	routers/router.go
gmy 2 settimane fa
parent
commit
cc08659b09

+ 32 - 0
controllers/data_manage/chart_info.go

@@ -167,6 +167,38 @@ func (this *ChartInfoController) ChartInfoAdd() {
 		return
 	}
 
+	// 来源字数校验
+	type SourcesFrom struct {
+		Text string `json:"text"`
+	}
+
+	if req.SourcesFrom != "" && len(req.SourcesFrom) > 0 {
+		var sourcesFrom SourcesFrom
+		err = json.Unmarshal([]byte(req.SourcesFrom), &sourcesFrom)
+		if err != nil {
+			return
+		}
+		if len(sourcesFrom.Text) > 50 {
+			br.Msg = "字数已达上限!"
+			br.ErrMsg = "来源文本字数已达上限,请修改!"
+			return
+		}
+	}
+
+	// 说明字数校验
+	if req.Instructions != "" && len(req.Instructions) > 0 {
+		var instructions SourcesFrom
+		err = json.Unmarshal([]byte(req.Instructions), &instructions)
+		if err != nil {
+			return
+		}
+		if len(instructions.Text) > 100 {
+			br.Msg = "字数已达上限!"
+			br.ErrMsg = "说明文本字数已达上限,请修改!"
+			return
+		}
+	}
+
 	chartInfo, err, errMsg, isSendEmail := data.AddChartInfo(req, sysUser.AdminId, sysUser.RealName, this.Lang)
 	if err != nil {
 		br.Msg = "保存失败"

+ 18 - 0
controllers/data_manage/excel/excel_info.go

@@ -107,6 +107,24 @@ func (c *ExcelInfoController) Add() {
 		}
 	}
 
+	// 来源字数校验
+	type SourcesFrom struct {
+		Text string `json:"text"`
+	}
+
+	if req.SourcesFrom != "" && len(req.SourcesFrom) > 0 {
+		var sourcesFrom SourcesFrom
+		err = json.Unmarshal([]byte(req.SourcesFrom), &sourcesFrom)
+		if err != nil {
+			return
+		}
+		if len(sourcesFrom.Text) > 50 {
+			br.Msg = "字数已达上限!"
+			br.ErrMsg = "来源文本字数已达上限,请修改!"
+			return
+		}
+	}
+
 	if req.ParentId > 0 {
 		parentExcelInfo, e := excel3.GetExcelInfoById(req.ParentId)
 		if e != nil {

+ 19 - 0
controllers/data_manage/range_analysis/chart_info.go

@@ -183,6 +183,25 @@ func (this *RangeChartChartInfoController) Add() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+
+	// 来源字数校验
+	type SourcesFrom struct {
+		Text string `json:"text"`
+	}
+
+	if req.SourcesFrom != "" && len(req.SourcesFrom) > 0 {
+		var sourcesFrom SourcesFrom
+		err = json.Unmarshal([]byte(req.SourcesFrom), &sourcesFrom)
+		if err != nil {
+			return
+		}
+		if len(sourcesFrom.Text) > 50 {
+			br.Msg = "字数已达上限!"
+			br.ErrMsg = "来源文本字数已达上限,请修改!"
+			return
+		}
+	}
+
 	if req.DateType == 0 {
 		req.DateType = 3
 	}

+ 300 - 0
controllers/image_conf_controller.go

@@ -0,0 +1,300 @@
+package controllers
+
+import (
+	"encoding/json"
+	"eta_gn/eta_api/models"
+	"eta_gn/eta_api/utils"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type ImageConfController struct {
+	BaseAuthController
+}
+
+// GetImageMaterial
+// @Title 根据条件查询图片素材
+// @Description 根据条件查询图片素材
+// @Success 200 {object} models.ImageConf
+// @router /get/image/material [get]
+func (this *ImageConfController) GetImageMaterial() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	confType, err := this.GetInt("ConfType")
+	if err != nil {
+		return
+	}
+	if confType <= 0 {
+		br.Msg = "请选择配置类型!"
+		br.ErrMsg = "请选择配置类型!"
+		return
+	}
+	imageType, _ := this.GetInt("ImageType")
+
+	imageName := this.GetString("ImageName")
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize := paging.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	condition += ` conf_type=? `
+	pars = append(pars, confType)
+
+	if imageType > 0 {
+		condition += ` AND image_type=? `
+		pars = append(pars, imageType)
+	}
+
+	if imageName != "" {
+		condition += ` AND image_name LIKE '%` + imageName + `%' `
+	}
+
+	count, err := models.GetImageConfByConditionCount(condition, pars)
+	if err != nil {
+		return
+	}
+	pagingItem := paging.GetPaging(currentIndex, pageSize, int(count))
+	var ImageConfPage models.ImageConfPage
+	ImageConfPage.Paging = pagingItem
+
+	if count <= 0 {
+		ImageConfPage.List = []*models.ImageConf{}
+
+		br.Msg = "操作成功"
+		br.Ret = 200
+		br.Data = ImageConfPage
+		return
+	}
+
+	condition += ` ORDER BY create_time asc `
+
+	condition += ` LIMIT ?, ? `
+	pars = append(pars, startSize, pageSize)
+
+	imageConfList, err := models.GetImageConfByCondition(condition, pars)
+
+	ImageConfPage.List = imageConfList
+
+	br.Msg = "操作成功"
+	br.Ret = 200
+	br.Data = ImageConfPage
+	return
+}
+
+// AddImageMaterial
+// @Title 新增图片素材
+// @Description 新增图片素材
+// @Success 200
+// @router /add/image/material [post]
+func (this *ImageConfController) AddImageMaterial() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req []*models.ImageConf
+	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + e.Error()
+		return
+	}
+
+	// 校验图片名称是否重复
+	for _, item := range req {
+		if item.ImageType <= 0 {
+			br.Msg = "请选择图片类型!"
+			br.ErrMsg = "请选择图片类型!"
+			return
+		}
+
+		if item.Url == "" {
+			br.Msg = "请上传图片!"
+			br.ErrMsg = "请上传图片!"
+			return
+		}
+
+		// 校验名称是否重复
+		imageConfByName, err := models.GetImageConfByName(item.ImageName)
+		if err != nil {
+			return
+		}
+		if imageConfByName != nil {
+			br.Msg = "图片名称已存在,请重新上传!"
+			br.ErrMsg = "图片名称已存在,请重新上传!"
+			return
+		}
+	}
+
+	err := models.BatchAddImageMaterials(req, len(req))
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+
+	br.Msg = "操作成功"
+	br.Ret = 200
+	return
+}
+
+// EditImageMaterial
+// @Title 修改图片素材
+// @Description 修改图片素材
+// @Success 200
+// @router /edit/image/material [post]
+func (this *ImageConfController) EditImageMaterial() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req *models.ImageConf
+	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + e.Error()
+		return
+	}
+
+	if req.ImageType <= 0 {
+		br.Msg = "请选择图片类型!"
+		br.ErrMsg = "请选择图片类型!"
+		return
+	}
+
+	if req.Url == "" {
+		br.Msg = "请上传图片!"
+		br.ErrMsg = "请上传图片!"
+		return
+	}
+
+	// 校验名称是否重复
+	imageConfByName, err := models.GetImageConfByName(req.ImageName)
+	if err != nil {
+		return
+	}
+	if imageConfByName != nil && imageConfByName.ImageConfId != req.ImageConfId {
+		br.Msg = "图片名称已存在,请重新上传!"
+		br.ErrMsg = "图片名称已存在,请重新上传!"
+		return
+	}
+
+	imageConf, err := models.GetImageConfById(req.ImageConfId)
+	if err != nil {
+		return
+	}
+	if imageConf.ImageConfId == 0 {
+		br.Msg = "该素材已被删除"
+		br.ErrMsg = "操作失败,Err: 该素材已被删除"
+		return
+	}
+
+	err = models.EditImageMaterial(req)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+
+	br.Msg = "操作成功"
+	br.Ret = 200
+	return
+}
+
+// DeleteImageMaterial
+// @Title 删除图片素材
+// @Description 删除图片素材
+// @Success 200
+// @router /delete/image/material [post]
+func (this *ImageConfController) DeleteImageMaterial() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	type DeleteReq struct {
+		ImageConfId int `json:"ImageConfId"`
+	}
+	var req []DeleteReq
+	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + e.Error()
+		return
+	}
+
+	var imageConfIds []int
+	for _, deleteReq := range req {
+		// 查看图片是否被使用
+		count, err := models.GetPptByImageIdCount(deleteReq.ImageConfId)
+		if err != nil {
+			return
+		}
+		if count > 0 {
+			br.Msg = "图片已被使用,不允许删除"
+			br.ErrMsg = "图片已被使用,不允许删除"
+			return
+		}
+		imageConfIds = append(imageConfIds, deleteReq.ImageConfId)
+	}
+
+	err := models.DeleteImageConfByIds(imageConfIds)
+	if err != nil {
+		return
+	}
+
+	br.Msg = "操作成功"
+	br.Ret = 200
+	return
+}

+ 10 - 0
controllers/ppt_report.go

@@ -414,6 +414,11 @@ func (this *PptV2Controller) CreateReport() {
 		}
 		newItem.TemplateType = inheritPpt.TemplateType
 		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
@@ -425,6 +430,11 @@ func (this *PptV2Controller) CreateReport() {
 	if req.InheritPptId <= 0 {
 		newItem.TemplateType = req.FirstPage.TemplateType
 		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

+ 40 - 53
controllers/ppt_v2.go

@@ -227,17 +227,7 @@ func (this *PptV2Controller) EditPpt() {
 		br.Msg = "标题不能为空"
 		return
 	}
-	//item, err := models.GetPptV2ByTitleAndId(req.FirstPage.Title, this.SysUser.AdminId)
-	//if err != nil && !utils.IsErrNoRow(err) {
-	//	br.Msg = "获取数据异常!"
-	//	br.ErrMsg = "获取数据异常,Err:" + err.Error()
-	//	return
-	//}
-	//if item != nil && item.PptId > 0 && item.PptId != int(req.PptId) {
-	//	br.Msg = "标题已存在,不可重复添加"
-	//	br.IsSendEmail = false
-	//	return
-	//}
+
 	pptInfo, err := models.GetPptV2ById(int(req.PptId))
 	if err != nil {
 		br.Msg = "信息获取失败"
@@ -262,25 +252,14 @@ func (this *PptV2Controller) EditPpt() {
 		}
 	}
 
-	// 判断权限
-	//if pptInfo.AdminId != this.SysUser.AdminId {
-	//	_, err := models.GetPPtGrantConf(pptInfo.PptId, this.SysUser.AdminId)
-	//	if err != nil {
-	//		if utils.IsErrNoRow(err) {
-	//			br.Msg = `该PPT已取消共享,保存失败`
-	//			br.ErrMsg = `该PPT已取消共享,保存失败`
-	//			br.IsSendEmail = false
-	//		} else {
-	//			br.Msg = `保存失败`
-	//			br.ErrMsg = `保存失败,ERR:` + err.Error()
-	//		}
-	//		return
-	//	}
-	//}
-
 	// 修改
 	pptInfo.TemplateType = req.FirstPage.TemplateType
 	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
@@ -288,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", "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()
@@ -346,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)
 	}
@@ -476,7 +457,6 @@ func (this *PptV2Controller) DetailPpt() {
 			hasAuth = true
 		}
 	}
-
 	// 编辑中
 	editor, e := services.UpdatePptEditing(pptId, 0, sysUser.AdminId, sysUser.RealName, false)
 	if e != nil {
@@ -812,6 +792,11 @@ func (this *PptV2Controller) SaveLog() {
 	}
 	pptItem.TemplateType = req.FirstPage.TemplateType
 	pptItem.BackgroundImg = req.FirstPage.ImgUrl
+	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
@@ -819,7 +804,7 @@ func (this *PptV2Controller) SaveLog() {
 	pptItem.ModifyTime = time.Now()
 	pptItem.TitleSetting = req.TitleSetting
 	pptItem.PptPage = len(pptContent)
-	err = pptItem.Update([]string{"TemplateType", "BackgroundImg", "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)
@@ -857,18 +842,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 {

+ 69 - 0
models/image_conf.go

@@ -0,0 +1,69 @@
+package models
+
+import (
+	"eta_gn/eta_api/global"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type ImageConf struct {
+	ImageConfId int       `gorm:"column:image_conf_id;primaryKey;autoIncrement:true"`
+	CreateTime  time.Time `gorm:"column:create_time;autoCreateTime" description:"消息时间"`
+	ModifyTime  time.Time `gorm:"column:modify_time;autoUpdateTime" description:"更新时间"`
+	ImageName   string    `gorm:"column:image_name;type:varchar(64);not null;default:''" description:"图片名称"`
+	Url         string    `gorm:"column:url;type:varchar(512);not null;default:''" description:"图片地址"`
+	ConfType    int       `gorm:"column:conf_type;type:tinyint(4) unsigned;not null;default:1" description:"配置类型 1-ppt素材"`
+	ImageType   int       `gorm:"column:image_type;type:tinyint(4) unsigned;not null;default:1" description:"图片类型 1-封面图 2-背景图 3-封底图"`
+}
+
+type ImageConfPage struct {
+	List   []*ImageConf
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+// BatchAddImageMaterials 新增图片素材
+func BatchAddImageMaterials(items []*ImageConf, batchSize int) (err error) {
+	err = global.DmSQL["rddp"].CreateInBatches(items, batchSize).Error
+	return
+}
+
+// GetImageConfByName 根据图片名称查询
+func GetImageConfByName(imageName string) (item *ImageConf, err error) {
+	item = &ImageConf{}
+	err = global.DmSQL["rddp"].Where("image_name = ?", imageName).First(item).Error
+	if err != nil && err.Error() == "record not found" {
+		return nil, nil
+	}
+	return item, nil
+}
+
+// GetImageConfByCondition 根据条件查询图片素材
+func GetImageConfByCondition(condition string, pars []interface{}) (list []*ImageConf, err error) {
+	err = global.DmSQL["rddp"].Where(condition, pars...).Find(&list).Error
+	return
+}
+
+// GetImageConfByConditionCount 根据条件查询图片素材数量
+func GetImageConfByConditionCount(condition string, pars []interface{}) (count int64, err error) {
+	err = global.DmSQL["rddp"].Model(&ImageConf{}).Where(condition, pars...).Count(&count).Error
+	return
+}
+
+// EditImageMaterial 修改图片素材
+func EditImageMaterial(item *ImageConf) (err error) {
+	err = global.DmSQL["rddp"].Updates(item).Error
+	return
+}
+
+// GetImageConfById 根据id查询图片素材
+func GetImageConfById(id int) (item *ImageConf, err error) {
+	item = &ImageConf{}
+	err = global.DmSQL["rddp"].Where("image_conf_id = ?", id).First(item).Error
+	return item, err
+}
+
+// DeleteImageConfByIds 根据id批量删除图片素材
+func DeleteImageConfByIds(ids []int) (err error) {
+	err = global.DmSQL["rddp"].Where("image_conf_id IN ?", ids).Delete(&ImageConf{}).Error
+	return
+}

+ 82 - 58
models/ppt_v2.go

@@ -12,39 +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:"课题结束时间"`
+	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 {
@@ -127,12 +132,17 @@ 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:"图片"`
-		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"`
@@ -195,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日志
@@ -477,12 +489,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:"图片"`
-		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数据"`
@@ -495,3 +512,10 @@ func MovePptReportClassify(newClassifyId, originClassifyId int) (err error) {
 	err = global.DmSQL["rddp"].Exec(sql, newClassifyId, originClassifyId).Error
 	return
 }
+
+// GetPptByImageIdCount 根据图片id查询ppt信息
+func GetPptByImageIdCount(imageId int) (count int, err error) {
+	sql := `SELECT COUNT(1) FROM ppt_v2 WHERE current_background_img_id = ? or back_cover_img_id = ? or background_img_id = ?`
+	err = global.DmSQL["rddp"].Raw(sql, imageId, imageId, imageId).Scan(&count).Error
+	return
+}

+ 36 - 0
routers/commentsRouter.go

@@ -6496,6 +6496,42 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"],
+        beego.ControllerComments{
+            Method: "AddImageMaterial",
+            Router: `/add/image/material`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"],
+        beego.ControllerComments{
+            Method: "DeleteImageMaterial",
+            Router: `/delete/image/material`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"],
+        beego.ControllerComments{
+            Method: "EditImageMaterial",
+            Router: `/edit/image/material`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:ImageConfController"],
+        beego.ControllerComments{
+            Method: "GetImageMaterial",
+            Router: `/get/image/material`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta_gn/eta_api/controllers:MeetingProbabilitiesController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:MeetingProbabilitiesController"],
         beego.ControllerComments{
             Method: "Detail",

+ 5 - 0
routers/router.go

@@ -354,6 +354,11 @@ func init() {
 				&controllers.PptV2HistoryController{},
 			),
 		),
+		web.NSNamespace("/image_conf",
+			web.NSInclude(
+				&controllers.ImageConfController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }