mysql_image.go 803 B

12345678910111213141516171819202122232425262728
  1. package dao
  2. import (
  3. "go-common/app/admin/ep/merlin/model"
  4. pkgerr "github.com/pkg/errors"
  5. )
  6. // Images Search all images in db.
  7. func (d *Dao) Images() (images []*model.Image, err error) {
  8. err = pkgerr.WithStack(d.db.Where("status = ?", model.AliveImageStatus).Find(&images).Error)
  9. return
  10. }
  11. // AddImage Create new image in db.
  12. func (d *Dao) AddImage(image *model.Image) error {
  13. return pkgerr.WithStack(d.db.Create(image).Error)
  14. }
  15. // UpdateImage Update image in db.
  16. func (d *Dao) UpdateImage(image *model.Image) error {
  17. return pkgerr.WithStack(d.db.Model(&model.Image{}).Updates(image).Error)
  18. }
  19. // DelImage Delete image in db.
  20. func (d *Dao) DelImage(iID int64) error {
  21. return pkgerr.WithStack(d.db.Model(&model.Image{}).Where("id = ?", iID).Update("status", model.DeletedImageStatus).Error)
  22. }