images_sources.go 925 B

1234567891011121314151617181920212223242526272829303132
  1. package image
  2. import (
  3. "eta/eta_mini_ht_api/models"
  4. "time"
  5. )
  6. type ImageSource struct {
  7. Id int `gorm:"column:id;primary_key;autoIncrement:'id'"`
  8. ImgName string `gorm:"column:img_name"`
  9. SrcUrl string `gorm:"column:src_url"`
  10. PermissionId int `gorm:"column:permission_id"`
  11. Deleted bool `gorm:"deleted"`
  12. CreatedTime time.Time `gorm:"column:created_time"`
  13. UpdatedTime time.Time `gorm:"column:updated_time"`
  14. }
  15. func (i *ImageSource) TableName() string {
  16. return "image_sources"
  17. }
  18. func GetIdsByPermissionId(permissionId int) (ids []int, err error) {
  19. db := models.Main()
  20. err = db.Model(&ImageSource{}).Select("id").Where("permission_id = ? and deleted = 0", permissionId).Scan(&ids).Error
  21. return
  22. }
  23. func GetImageSrc(id int) (src string, err error) {
  24. db := models.Main()
  25. err = db.Model(&ImageSource{}).Select("src_url").Where("id = ?", id).Scan(&src).Error
  26. return
  27. }