noticeRecordService.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 int, 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. //fmt.Printf("record = %v", record)
  14. var SendUser, ArmClassifyName string
  15. if record.ArmClassify == 1 {
  16. SendUser = record.NoticeSet.DevUserIdsName
  17. ArmClassifyName = "运维"
  18. } else {
  19. SendUser = record.NoticeSet.BusinessUserIdsName
  20. ArmClassifyName = "业务"
  21. }
  22. status := record.Status
  23. sendStatusName := "失败"
  24. if status == 1 {
  25. sendStatusName = "成功"
  26. }
  27. list = append(list, model.ResposeNoticeRecordData{
  28. ID: int(record.ID),
  29. RecordID: int(record.ID),
  30. SendUser: SendUser,
  31. SendTime: record.CreatedAt.Format("2006-01-02 15:04:05"),
  32. SendType: record.SendType,
  33. SendValue: record.SendValue,
  34. ClassifyName: ArmClassifyName,
  35. TenantID: record.NoticeSet.TenantId,
  36. ArmContend: record.Content,
  37. SendName: record.SendName,
  38. SendTypeName: record.SendTypeName,
  39. SendStatusName: sendStatusName,
  40. })
  41. }
  42. return list, total, err
  43. }