From 0bac6b67e85e00b785b6ab527e0cbc8bad04638c Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期二, 02 七月 2019 20:43:51 +0800
Subject: [PATCH] default dbIp=127.0.0.1
---
controllers/eventPush.go | 115 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 57 insertions(+), 58 deletions(-)
diff --git a/controllers/eventPush.go b/controllers/eventPush.go
index b604fcd..18f8a49 100644
--- a/controllers/eventPush.go
+++ b/controllers/eventPush.go
@@ -8,44 +8,43 @@
)
type EventPushController struct {
-
}
type EventPushVo struct {
- Id string `json:"id"`
- Name string `json:"name"`
- TimeStart string `json:"time_start"`
- TimeEnd string `json:"time_end"`
- IsSatisfyAll bool `json:"is_satisfy_all"`
- RuleText string `json:"rule_text"`
- Enable bool `json:"enable"`
- LinkType string `json:"link_type"`
- LinkDevice string `json:"link_device"`
+ Id string `json:"id"`
+ Name string `json:"name"`
+ TimeStart string `json:"time_start"`
+ TimeEnd string `json:"time_end"`
+ IsSatisfyAll bool `json:"is_satisfy_all"`
+ RuleText string `json:"rule_text"`
+ Enable bool `json:"enable"`
+ LinkType string `json:"link_type"`
+ LinkDevice string `json:"link_device"`
IpPorts []EventPushServerPortVo `json:"ip_ports"`
- Urls []EventUrlVo `json:"urls"`
- Rules []EventPushRuleVo `json:"rules"`
+ Urls []EventUrlVo `json:"urls"`
+ Rules []EventPushRuleVo `json:"rules"`
}
type EventPushRuleVo struct {
- Id string `json:"id"`
- TopicType string `json:"topic_type"`//鍙傛暟涓婚,鐩墠鍒嗕负浜旂被锛堟憚鍍忔満銆佸簳搴撱�佷换鍔°�佷汉鍛樸�佹姤璀︾瓑绾э級
- TopicArg string `json:"topic_arg"`//涓婚瀵瑰簲鐨勫叿浣撳弬鏁�
- Operator string `json:"operator"`
+ Id string `json:"id"`
+ TopicType string `json:"topic_type"` //鍙傛暟涓婚,鐩墠鍒嗕负浜旂被锛堟憚鍍忔満銆佸簳搴撱�佷换鍔°�佷汉鍛樸�佹姤璀︾瓑绾э級
+ TopicArg string `json:"topic_arg"` //涓婚瀵瑰簲鐨勫叿浣撳弬鏁�
+ Operator string `json:"operator"`
OperatorType string `json:"operator_type"`
- RuleValue string `json:"rule_value"`
- EventPushId string `json:"event_push_id"`
+ RuleValue string `json:"rule_value"`
+ EventPushId string `json:"event_push_id"`
}
type EventPushServerPortVo struct {
ServerIp string `json:"server_ip"`
- Port int `json:"port"`
- Enable bool `json:"enable"`
+ Port int `json:"port"`
+ Enable bool `json:"enable"`
}
type EventUrlVo struct {
- Url string `json:"url"`
- Enable bool `json:"enable"`
+ Url string `json:"url"`
+ Enable bool `json:"enable"`
}
// @Summary 浜嬩欢鎺ㄩ�佷繚瀛�
@@ -55,19 +54,19 @@
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/eventPush/save [post]
-func (epc EventPushController) Save(c *gin.Context){
+func (epc EventPushController) Save(c *gin.Context) {
var saveBody EventPushVo
- if err := c.BindJSON(&saveBody);err !=nil {
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if err := c.BindJSON(&saveBody); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.EventPushApi
paramBody := util.Struct2Map(saveBody)
flag, data := api.Save(paramBody)
if flag {
- util.ResponseFormat(c,code.Success,data)
+ util.ResponseFormat(c, code.Success, data)
} else {
- util.ResponseFormat(c,code.ComError,data)
+ util.ResponseFormat(c, code.ComError, data)
}
}
@@ -80,19 +79,19 @@
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/eventPush/findByEventTopic [get]
-func (epc EventPushController) FindByEventTopic(c *gin.Context){
+func (epc EventPushController) FindByEventTopic(c *gin.Context) {
topic := c.Query("topic")
childType := c.Query("type")
- if topic == ""{
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if topic == "" {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.EventPushApi
flag, data := api.FindByEventTopic(topic, childType)
if flag {
- util.ResponseFormat(c,code.Success,data)
+ util.ResponseFormat(c, code.Success, data)
} else {
- util.ResponseFormat(c,code.ComError,data)
+ util.ResponseFormat(c, code.ComError, data)
}
}
@@ -104,14 +103,14 @@
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/eventPush/findAll [get]
-func (controller EventPushController) FindAll(c *gin.Context){
+func (controller EventPushController) FindAll(c *gin.Context) {
name := c.Query("name")
var api dbapi.EventPushApi
- flag,data := api.FindAll(name)
+ flag, data := api.FindAll(name)
if flag {
- util.ResponseFormat(c,code.Success,data)
- } else{
- util.ResponseFormat(c,code.ComError,"")
+ util.ResponseFormat(c, code.Success, data)
+ } else {
+ util.ResponseFormat(c, code.ComError, "")
}
}
@@ -123,24 +122,24 @@
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/eventPush/getById [get]
-func (controller EventPushController) GetById(c *gin.Context){
+func (controller EventPushController) GetById(c *gin.Context) {
id := c.Query("id")
- if id == ""{
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if id == "" {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.EventPushApi
- flag,data := api.GetById(id)
+ flag, data := api.GetById(id)
if flag {
- util.ResponseFormat(c,code.Success, data)
- } else{
- util.ResponseFormat(c,code.ComError,"")
+ util.ResponseFormat(c, code.Success, data)
+ } else {
+ util.ResponseFormat(c, code.ComError, "")
}
}
type ChangeStatusVo struct {
- Id string `json:"id"`
- Enable bool `json:"enable"`
+ Id string `json:"id"`
+ Enable bool `json:"enable"`
}
// @Summary 鏀瑰彉enable鐘舵��
@@ -151,19 +150,19 @@
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/eventPush/changeStatus [post]
-func (controller EventPushController) ChangeStatus(c *gin.Context){
+func (controller EventPushController) ChangeStatus(c *gin.Context) {
var statusBody ChangeStatusVo
err := c.BindJSON(&statusBody)
- if err !=nil {
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.EventPushApi
flag, data := api.ChangeStatus(statusBody.Id, statusBody.Enable)
- if flag{
- util.ResponseFormat(c,code.Success,data)
+ if flag {
+ util.ResponseFormat(c, code.Success, data)
} else {
- util.ResponseFormat(c,code.ComError,data)
+ util.ResponseFormat(c, code.ComError, data)
}
}
@@ -176,17 +175,17 @@
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/eventPush/delete [post]
-func (controller EventPushController) Delete(c *gin.Context){
+func (controller EventPushController) Delete(c *gin.Context) {
id := c.PostForm("id")
- if id ==""{
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if id == "" {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.EventPushApi
flag, data := api.Delete(id)
- if flag{
- util.ResponseFormat(c,code.Success,data)
+ if flag {
+ util.ResponseFormat(c, code.Success, data)
} else {
- util.ResponseFormat(c,code.ComError,data)
+ util.ResponseFormat(c, code.ComError, data)
}
}
--
Gitblit v1.8.0