dir.go 575 B

1234567891011121314151617181920212223242526
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/upload/model"
  5. "go-common/library/log"
  6. )
  7. // AddDir .
  8. func (s *Service) AddDir(c context.Context, adp *model.AddDirParam) (err error) {
  9. d := &model.DirLimit{}
  10. if err = s.orm.Model(d).
  11. Where(&model.DirLimit{BucketName: adp.BucketName, Dir: adp.DirName}).
  12. Assign(&model.DirLimit{
  13. BucketName: adp.BucketName,
  14. Dir: adp.DirName,
  15. ConfigPic: adp.Pic,
  16. ConfigRate: adp.Rate,
  17. }).
  18. FirstOrCreate(d).Error; err != nil {
  19. log.Error("Failed to add dir (%+v): %v", d, err)
  20. return
  21. }
  22. return
  23. }