Browse Source

ppt 新增 中间页封底页

gmy 3 months ago
parent
commit
3d106509d0

+ 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
 	}

+ 123 - 2
controllers/image_conf_controller.go

@@ -1,6 +1,11 @@
 package controllers
 
-import "eta_gn/eta_api/models"
+import (
+	"encoding/json"
+	"eta_gn/eta_api/models"
+	"eta_gn/eta_api/utils"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
 
 type ImageConfController struct {
 	BaseAuthController
@@ -27,10 +32,126 @@ func (this *ImageConfController) AddImageMaterial() {
 		br.Ret = 408
 		return
 	}
-	var req map[string]interface{}
+	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
+}
+
+// AddImageMaterial
+// @Title 根据条件查询图片素材
+// @Description 根据条件查询图片素材
+// @Success
+// @router /add/get/image/material [get]
+func (this *ImageConfController) getImageMaterialList() {
+	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, err := this.GetInt("ImageType")
+	if err != nil {
+		return
+	}
+	if imageType <= 0 {
+		br.Msg = "请选择图片类型!"
+		br.ErrMsg = "请选择图片类型!"
+		return
+	}
+	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 += ` AND conf_type=? `
+	pars = append(pars, confType)
+
+	condition += ` AND image_type=? `
+	pars = append(pars, imageType)
+
+	if imageName != "" {
+		condition += ` AND image_name LIKE '%` + imageName + `%' `
+	}
+
+	condition += ` ORDER BY modify_time DESC `
+
+	condition += ` LIMIT ?, ? `
+	pars = append(pars, pageSize, startSize)
+
+	imageConfList, err := models.GetImageConfByCondition(condition, pars)
+
+	br.Msg = "操作成功"
+	br.Ret = 200
+	br.Data = imageConfList
+	return
 }

+ 22 - 2
models/image_conf.go

@@ -1,6 +1,9 @@
 package models
 
-import "time"
+import (
+	"eta_gn/eta_api/global"
+	"time"
+)
 
 type ImageConf struct {
 	ImageConfId int       `gorm:"primaryKey;column:image_conf_id;type:int(10) unsigned;not null"`
@@ -12,4 +15,21 @@ type ImageConf struct {
 	ImageType   int       `gorm:"column:image_type;type:tinyint(4) unsigned;not null;default:1" description:"图片类型 1-封面图 2-背景图 3-封底图"`
 }
 
-//
+// 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
+	return
+}
+
+// GetImageConfByCondition 根据条件查询图片素材
+func GetImageConfByCondition(condition string, pars []interface{}) (list []*ImageConf, err error) {
+	err = global.DmSQL["rddp"].Where(condition, pars...).Find(&list).Error
+	return
+}