image_conf.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type ImageConf struct {
  7. ImageConfId int `gorm:"primaryKey;column:image_conf_id;type:int(10) unsigned;not null"`
  8. CreateTime time.Time `gorm:"column:create_time" description:"消息时间"`
  9. ModifyTime time.Time `gorm:"column:modify_time" description:"更新时间"`
  10. ImageName string `gorm:"column:image_name;type:varchar(64);not null;default:''" description:"图片名称"`
  11. Url string `gorm:"column:url;type:varchar(512);not null;default:''" description:"图片地址"`
  12. ConfType int `gorm:"column:conf_type;type:tinyint(4) unsigned;not null;default:1" description:"配置类型 1-ppt素材"`
  13. ImageType int `gorm:"column:image_type;type:tinyint(4) unsigned;not null;default:1" description:"图片类型 1-封面图 2-背景图 3-封底图"`
  14. }
  15. // BatchAddImageMaterials 新增图片素材
  16. func BatchAddImageMaterials(items []*ImageConf, batchSize int) (err error) {
  17. err = global.DmSQL["rddp"].CreateInBatches(items, batchSize).Error
  18. return
  19. }
  20. // GetImageConfByName 根据图片名称查询
  21. func GetImageConfByName(imageName string) (item *ImageConf, err error) {
  22. item = &ImageConf{}
  23. err = global.DmSQL["rddp"].Where("image_name = ?", imageName).First(item).Error
  24. return
  25. }
  26. // GetImageConfByCondition 根据条件查询图片素材
  27. func GetImageConfByCondition(condition string, pars []interface{}) (list []*ImageConf, err error) {
  28. err = global.DmSQL["rddp"].Where(condition, pars...).Find(&list).Error
  29. return
  30. }