emailqueuestatus.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package models
  15. import (
  16. "time"
  17. "yunion.io/x/pkg/errors"
  18. "yunion.io/x/onecloud/pkg/cloudcommon/db"
  19. )
  20. type SEmailQueueStatusManager struct {
  21. db.SModelBaseManager
  22. }
  23. type SEmailQueueStatus struct {
  24. db.SModelBase
  25. Id int64 `primary:"true" list:"user"`
  26. SentAt time.Time `list:"user"`
  27. Status string `width:"16" charset:"ascii" default:"queued" list:"user"`
  28. Results string `list:"user" charset:"utf8"`
  29. }
  30. var EmailQueueStatusManager *SEmailQueueStatusManager
  31. func init() {
  32. EmailQueueStatusManager = &SEmailQueueStatusManager{
  33. SModelBaseManager: db.NewModelBaseManager(SEmailQueueStatus{}, "emailqueue_status_tbl", "emailqueue_status", "emailqueue_status"),
  34. }
  35. EmailQueueStatusManager.SetVirtualObject(EmailQueueStatusManager)
  36. }
  37. func (manager *SEmailQueueStatusManager) fetchEmailQueueStatus(ids []int64) (map[int64]SEmailQueueStatus, error) {
  38. q := manager.Query().In("id", ids)
  39. results := make([]SEmailQueueStatus, 0)
  40. err := q.All(&results)
  41. if err != nil {
  42. return nil, errors.Wrap(err, "query.All")
  43. }
  44. ret := make(map[int64]SEmailQueueStatus)
  45. for i := range results {
  46. eqs := results[i]
  47. ret[eqs.Id] = eqs
  48. }
  49. return ret, nil
  50. }