浏览代码

ppt 新增 中间页封底页

gmy 4 月之前
父节点
当前提交
45d7998ef6
共有 2 个文件被更改,包括 11 次插入13 次删除
  1. 6 11
      controllers/image_conf_controller.go
  2. 5 2
      models/image_conf.go

+ 6 - 11
controllers/image_conf_controller.go

@@ -42,15 +42,8 @@ func (this *ImageConfController) GetImageMaterial() {
 		br.ErrMsg = "请选择配置类型!"
 		return
 	}
-	imageType, err := this.GetInt("ImageType")
-	if err != nil {
-		return
-	}
-	if imageType <= 0 {
-		br.Msg = "请选择图片类型!"
-		br.ErrMsg = "请选择图片类型!"
-		return
-	}
+	imageType, _ := this.GetInt("ImageType")
+
 	imageName := this.GetString("ImageName")
 
 	pageSize, _ := this.GetInt("PageSize")
@@ -70,8 +63,10 @@ func (this *ImageConfController) GetImageMaterial() {
 	condition += ` AND conf_type=? `
 	pars = append(pars, confType)
 
-	condition += ` AND image_type=? `
-	pars = append(pars, imageType)
+	if imageType > 0 {
+		condition += ` AND image_type=? `
+		pars = append(pars, imageType)
+	}
 
 	if imageName != "" {
 		condition += ` AND image_name LIKE '%` + imageName + `%' `

+ 5 - 2
models/image_conf.go

@@ -6,7 +6,7 @@ import (
 )
 
 type ImageConf struct {
-	ImageConfId int       `gorm:"primaryKey;column:image_conf_id;type:int(10) unsigned;not null"`
+	ImageConfId int       `gorm:"column:image_conf_id;primaryKey;autoIncrement:true"`
 	CreateTime  time.Time `gorm:"column:create_time" description:"消息时间"`
 	ModifyTime  time.Time `gorm:"column:modify_time" description:"更新时间"`
 	ImageName   string    `gorm:"column:image_name;type:varchar(64);not null;default:''" description:"图片名称"`
@@ -25,7 +25,10 @@ func BatchAddImageMaterials(items []*ImageConf, batchSize int) (err error) {
 func GetImageConfByName(imageName string) (item *ImageConf, err error) {
 	item = &ImageConf{}
 	err = global.DmSQL["rddp"].Where("image_name = ?", imageName).First(item).Error
-	return
+	if err.Error() == "record not found" {
+		return nil, nil
+	}
+	return item, nil
 }
 
 // GetImageConfByCondition 根据条件查询图片素材