(search dto.AlertSearch)
| 62 | } |
| 63 | |
| 64 | func (a AlertService) PageAlert(search dto.AlertSearch) (int64, []dto.AlertDTO, error) { |
| 65 | var ( |
| 66 | opts []repo.DBOption |
| 67 | result []dto.AlertDTO |
| 68 | ) |
| 69 | if global.CONF.Base.IsEnterprise { |
| 70 | opts = append(opts, alertRepo.WithByTypeNotIn(eeHiddenAlertTypes)) |
| 71 | } |
| 72 | if search.Status != "" { |
| 73 | opts = append(opts, repo.WithByStatus(search.Status)) |
| 74 | } |
| 75 | if search.Type != "" { |
| 76 | opts = append(opts, alertRepo.WithByType(search.Type)) |
| 77 | } |
| 78 | opts = append(opts, repo.WithOrderDesc("created_at")) |
| 79 | |
| 80 | total, alerts, err := alertRepo.Page(search.Page, search.PageSize, opts...) |
| 81 | if err != nil { |
| 82 | return 0, nil, err |
| 83 | } |
| 84 | |
| 85 | for _, item := range alerts { |
| 86 | |
| 87 | result = append(result, dto.AlertDTO{ |
| 88 | ID: item.ID, |
| 89 | Type: item.Type, |
| 90 | Cycle: item.Cycle, |
| 91 | Count: item.Count, |
| 92 | Method: item.Method, |
| 93 | Title: item.Title, |
| 94 | Project: item.Project, |
| 95 | Status: item.Status, |
| 96 | SendCount: item.SendCount, |
| 97 | AdvancedParams: item.AdvancedParams, |
| 98 | CreateUser: item.CreateUser, |
| 99 | UpdateUser: item.UpdateUser, |
| 100 | CreatedAt: item.CreatedAt, |
| 101 | UpdatedAt: item.UpdatedAt, |
| 102 | }) |
| 103 | } |
| 104 | |
| 105 | return total, result, err |
| 106 | } |
| 107 | |
| 108 | func (a AlertService) GetAlerts() ([]dto.AlertDTO, error) { |
| 109 | var ( |
nothing calls this directly
no test coverage detected