From 9303b69ea569bcb5e581147543a3fd58e90d0d25 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期四, 20 八月 2020 20:05:23 +0800
Subject: [PATCH] add get buckets contrl

---
 controllers/eventPush.go |  202 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 202 insertions(+), 0 deletions(-)

diff --git a/controllers/eventPush.go b/controllers/eventPush.go
index 2d32936..4580206 100644
--- a/controllers/eventPush.go
+++ b/controllers/eventPush.go
@@ -1 +1,203 @@
 package controllers
+
+import (
+	"basic.com/dbapi.git"
+	"github.com/gin-gonic/gin"
+	"webserver/extend/code"
+	"webserver/extend/util"
+)
+
+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"`
+
+	IpPorts []EventPushServerPortVo `json:"ip_ports"`
+	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"`
+	OperatorType string `json:"operator_type"`
+	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"`
+}
+
+type EventUrlVo struct {
+	Url    string `json:"url"`
+	Enable bool   `json:"enable"`
+}
+
+// @Security ApiKeyAuth
+// @Summary 浜嬩欢鎺ㄩ�佷繚瀛�
+// @Description 浜嬩欢鎺ㄩ�佷繚瀛�
+// @Accept json
+// @Produce json
+// @Tags 浜嬩欢鎺ㄩ��
+// @Param SaveArgs body controllers.EventPushVo true "鏃堕棿鎺ㄩ�佷繚瀛樺弬鏁�"
+// @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) {
+	var saveBody EventPushVo
+	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)
+	} else {
+		util.ResponseFormat(c, code.ComError, data)
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏍规嵁浜嬩欢鎺ㄩ�佷富棰樼殑涓�绾у拰浜岀骇閫夐」鑾峰彇鏈�鍚庝笅鎷夎彍鍗曞垪琛�
+// @Description  鏍规嵁浜嬩欢鎺ㄩ�佷富棰樼殑涓�绾у拰浜岀骇閫夐」鑾峰彇鏈�鍚庝笅鎷夎彍鍗曞垪琛�
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 浜嬩欢鎺ㄩ��
+// @Param topic query string true "涓�绾т富棰橀�夐」,渚嬪锛歝amera(鎽勫儚鏈�)"
+// @Param type query string true "瀛愰�夐」绫诲瀷锛屼緥濡傦細name锛堝悕绉帮級鎴朼ddr锛堜綅缃級"
+// @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) {
+	topic := c.Query("topic")
+	childType := c.Query("type")
+	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)
+	} else {
+		util.ResponseFormat(c, code.ComError, data)
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏌ュ叏閮�
+// @Description  鏌ュ叏閮�
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 浜嬩欢鎺ㄩ��
+// @Param name query string false "浜嬩欢鍚嶇О"
+// @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) {
+	name := c.Query("name")
+	var api dbapi.EventPushApi
+	flag, data := api.FindAll(name)
+	if flag {
+		util.ResponseFormat(c, code.Success, data)
+	} else {
+		util.ResponseFormat(c, code.ComError, "")
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 浜嬩欢鎺ㄩ�佺紪杈�
+// @Description  浜嬩欢鎺ㄩ�佺紪杈�
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 浜嬩欢鎺ㄩ��
+// @Param id query string true "id"
+// @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) {
+	id := c.Query("id")
+	if id == "" {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+		return
+	}
+	var api dbapi.EventPushApi
+	flag, data := api.GetById(id)
+	if flag {
+		util.ResponseFormat(c, code.Success, data)
+	} else {
+		util.ResponseFormat(c, code.ComError, "")
+	}
+}
+
+type ChangeStatusVo struct {
+	Id     string `json:"id"`
+	Enable bool   `json:"enable"`
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏀瑰彉enable鐘舵��
+// @Description  鏀瑰彉enable鐘舵��
+// @Accept json
+// @Produce json
+// @Tags 浜嬩欢鎺ㄩ��
+// @Param statusBody body controllers.ChangeStatusVo true "鍙傛暟缁撴瀯"
+// @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) {
+	var statusBody ChangeStatusVo
+	err := c.BindJSON(&statusBody)
+	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)
+	} else {
+		util.ResponseFormat(c, code.ComError, data)
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏍规嵁id鍒犻櫎
+// @Description  鏍规嵁id鍒犻櫎
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 浜嬩欢鎺ㄩ��
+// @Param id formData string true "id"
+// @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) {
+	id := c.PostForm("id")
+	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)
+	} else {
+		util.ResponseFormat(c, code.ComError, data)
+	}
+}

--
Gitblit v1.8.0