()
| 63 | } |
| 64 | |
| 65 | func (c *MainController) AddRouter() { |
| 66 | if !CheckAccount(c.Ctx) { |
| 67 | c.Redirect("/login", 302) |
| 68 | return |
| 69 | } |
| 70 | WebAlertRouterJson := AlertRouterJson{} |
| 71 | logsign := "[" + LogsSign() + "]" |
| 72 | logs.Info(logsign, string(c.Ctx.Input.RequestBody)) |
| 73 | json.Unmarshal(c.Ctx.Input.RequestBody, &WebAlertRouterJson) |
| 74 | rules, err := json.Marshal(WebAlertRouterJson.Rules) |
| 75 | if WebAlertRouterJson.RouterId == "" { |
| 76 | tpl_id_int, _ := strconv.Atoi(WebAlertRouterJson.RouterTplId) |
| 77 | err = models.AddAlertRouter(0, tpl_id_int, WebAlertRouterJson.RouterName, string(rules), WebAlertRouterJson.RouterPurl, WebAlertRouterJson.RouterPat, WebAlertRouterJson.RouterPatRR, WebAlertRouterJson.RouterSendResolved) |
| 78 | } else { |
| 79 | id, _ := strconv.Atoi(WebAlertRouterJson.RouterId) |
| 80 | tpl_id_int, _ := strconv.Atoi(WebAlertRouterJson.RouterTplId) |
| 81 | err = models.UpdateAlertRouter(id, tpl_id_int, WebAlertRouterJson.RouterName, string(rules), WebAlertRouterJson.RouterPurl, WebAlertRouterJson.RouterPat, WebAlertRouterJson.RouterPatRR, WebAlertRouterJson.RouterSendResolved) |
| 82 | } |
| 83 | var resp interface{} |
| 84 | resp = err |
| 85 | if err != nil { |
| 86 | resp = err.Error() |
| 87 | } |
| 88 | c.Data["json"] = resp |
| 89 | c.ServeJSON() |
| 90 | } |
| 91 | |
| 92 | // router edit |
| 93 | func (c *MainController) RouterEdit() { |
nothing calls this directly
no test coverage detected