add id of result
Change-Id: I921ee4c9525dd40ae57f21fde7ca0640f0ccdd3a
This commit is contained in:
parent
4d341e44bd
commit
c15a83c5a9
@ -85,7 +85,7 @@ class AnomalyDetectSql(object):
|
||||
with session.begin():
|
||||
rule = session.query(models.AnomalyRules).filter_by(id=id).first()
|
||||
if rule is None:
|
||||
return None
|
||||
return "error"
|
||||
if title:
|
||||
rule.title = title
|
||||
if desc:
|
||||
@ -99,7 +99,7 @@ class AnomalyDetectSql(object):
|
||||
if flag:
|
||||
rule.flag = int(flag)
|
||||
rule.update_time = t
|
||||
return rule
|
||||
return None
|
||||
|
||||
def delete_rule(self, id):
|
||||
session = get_session()
|
||||
|
@ -66,11 +66,13 @@ class AnomalyDetectController(wsgi.Controller):
|
||||
return {"code": -1, "msg": "not found"}
|
||||
|
||||
rule = dict()
|
||||
rule["id"] = r.id
|
||||
rule["title"] = r.title
|
||||
rule["desc"] = r.desc
|
||||
rule["keyword"] = r.keyword
|
||||
rule["log_type"] = r.log_type
|
||||
rule["module"] = r.module
|
||||
rule["flag"] = r.flag
|
||||
rule["create_time"] = r.create_time
|
||||
rule["update_time"] = r.update_time
|
||||
return {"code": 0, "msg": "OK", "rule": rule}
|
||||
@ -87,11 +89,13 @@ class AnomalyDetectController(wsgi.Controller):
|
||||
rules = []
|
||||
for r in res:
|
||||
rule = dict()
|
||||
rule["id"] = r.id
|
||||
rule["title"] = r.title
|
||||
rule["desc"] = r.desc
|
||||
rule["keyword"] = r.keyword
|
||||
rule["log_type"] = r.log_type
|
||||
rule["module"] = r.module
|
||||
rule["flag"] = r.flag
|
||||
rule["create_time"] = r.create_time
|
||||
rule["update_time"] = r.update_time
|
||||
rules.append(rule)
|
||||
@ -112,8 +116,8 @@ class AnomalyDetectController(wsgi.Controller):
|
||||
params["module"] = body.get("module", None)
|
||||
params["flag"] = body.get("flag", None)
|
||||
rule = self.api.update_rule(params)
|
||||
if rule:
|
||||
return {"code": 0, "msg": "OK", "rule": rule}
|
||||
if rule is None:
|
||||
return {"code": 0, "msg": "OK"}
|
||||
else:
|
||||
return {"code": -1, "msg": "no found"}
|
||||
|
||||
@ -137,6 +141,7 @@ class AnomalyDetectController(wsgi.Controller):
|
||||
records = []
|
||||
for r in res:
|
||||
record = dict()
|
||||
record["id"] = r.id
|
||||
record["title"] = r.title
|
||||
record["desc"] = r.desc
|
||||
record["keyword"] = r.keyword
|
||||
|
Loading…
x
Reference in New Issue
Block a user