noticeRecordService.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package service
  2. import (
  3. "iot_manager_service/app/warn/dao"
  4. "iot_manager_service/app/warn/model"
  5. )
  6. var NoticeRecordService = new(noticeRecordService)
  7. type noticeRecordService struct{}
  8. func (s noticeRecordService) List(tenantId string, filter model.RequestNoticeRecordFilter) ([]model.ResposeNoticeRecordData, int64, error) {
  9. var list []model.ResposeNoticeRecordData
  10. dao := dao.NoticeRecord{}
  11. records, total, err := dao.GetList(filter)
  12. for _, record := range records {
  13. var SendUser, ArmClassifyName string
  14. if record.ArmClassify == 1 {
  15. SendUser = record.NoticeSet.DevUserIdsName
  16. ArmClassifyName = "运维"
  17. } else {
  18. SendUser = record.NoticeSet.BusinessUserIdsName
  19. ArmClassifyName = "业务"
  20. }
  21. status := record.Status
  22. sendStatusName := "失败"
  23. if status == 1 {
  24. sendStatusName = "成功"
  25. }
  26. list = append(list, model.ResposeNoticeRecordData{
  27. ID: int(record.ID),
  28. RecordID: int(record.ID),
  29. SendUser: SendUser,
  30. SendTime: record.CreatedAt.Format("2006-01-02 15:04:05"),
  31. SendType: record.SendType,
  32. SendValue: record.SendValue,
  33. ClassifyName: ArmClassifyName,
  34. TenantID: record.NoticeSet.TenantId,
  35. ArmContend: record.Content,
  36. SendName: record.SendName,
  37. SendTypeName: record.SendTypeName,
  38. SendStatusName: sendStatusName,
  39. })
  40. }
  41. return list, total, err
  42. }