picture.go 634 B

12345678910111213141516171819202122232425262728293031323334
  1. package app
  2. import (
  3. "github.com/sirupsen/logrus"
  4. "gorm.io/gorm"
  5. "lcfns/global"
  6. "lcfns/model/app"
  7. )
  8. type PictureService struct {
  9. }
  10. func (ps *PictureService) SaveEventPicture(pic *app.Picture, picData *app.PictureData) {
  11. err := global.Db.Transaction(func(tx *gorm.DB) error {
  12. err := global.Db.Create(picData).Error
  13. if err != nil {
  14. return err
  15. }
  16. pic.DataId = picData.ID
  17. err = global.Db.Create(pic).Error
  18. if err != nil {
  19. return err
  20. }
  21. return nil
  22. })
  23. if err != nil {
  24. logrus.WithField("eventId", pic.EventId).Error("图片保存失败")
  25. }
  26. }
  27. // Picture 获取图片
  28. func (ps *PictureService) Picture() {
  29. }