From ca0affbce745df4e071dc256c5f47b2a8165a443 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 26 六月 2019 17:00:54 +0800
Subject: [PATCH] pollconfig done

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

diff --git a/controllers/pollConfig.go b/controllers/pollConfig.go
index 2d32936..67ac74f 100644
--- a/controllers/pollConfig.go
+++ b/controllers/pollConfig.go
@@ -1 +1,110 @@
 package controllers
+
+import (
+	"basic.com/dbapi.git"
+	"github.com/gin-gonic/gin"
+	"strconv"
+	"webserver/extend/code"
+	"webserver/extend/util"
+)
+
+type PollConfigController struct {
+
+}
+
+type PollConfig struct {
+	ServerId string `json:"server_id"`//鏈嶅姟鍣╥d
+	PollPeriod int `json:"poll_period"`//杞鍛ㄦ湡
+	Delay int `json:"delay"`//寤舵椂鏃堕棿
+	Enable bool `json:"enable"`//鏄惁鍚敤杞
+}
+
+// @Summary 淇濆瓨杞鍛ㄦ湡
+// @Description 淇濆瓨杞鍛ㄦ湡
+// @Produce json
+// @Tags 杞閰嶇疆
+// @Param period query int 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/pollConfig/savePollPeriod [post]
+func (controller PollConfigController) SavePollPeriod(c *gin.Context){
+	periodStr := c.PostForm("period")
+	period, err := strconv.Atoi(periodStr)
+	if periodStr =="" || err !=nil{
+		util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+		return
+	}
+	var api dbapi.SysSetApi
+	b, data := api.SavePollDelay(period)
+	if b {
+		util.ResponseFormat(c,code.Success,data)
+	} else {
+		util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触")
+	}
+}
+
+// @Summary 淇濆瓨杞寤舵椂
+// @Description 淇濆瓨杞寤舵椂
+// @Produce json
+// @Tags 杞閰嶇疆
+// @Param delay query int 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/pollConfig/savePollDelay [post]
+func (controller PollConfigController) SavePollDelay(c *gin.Context){
+	delayStr := c.PostForm("delay")
+	delay, err := strconv.Atoi(delayStr)
+	if delayStr =="" || err !=nil{
+		util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+		return
+	}
+	var api dbapi.SysSetApi
+	b, data := api.SavePollDelay(delay)
+	if b {
+		util.ResponseFormat(c,code.Success,data)
+	} else {
+		util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触")
+	}
+}
+
+// @Summary 鑾峰彇鏈満杞閰嶇疆
+// @Description 鑾峰彇鏈満杞閰嶇疆
+// @Produce json
+// @Tags 杞閰嶇疆
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/pollConfig/getPollConfig [get]
+func (controller PollConfigController) GetPollConfig(c *gin.Context){
+	var api dbapi.SysSetApi
+	b, data := api.GetPollConfig()
+	if b {
+		util.ResponseFormat(c,code.Success,data)
+	}else{
+		util.ResponseFormat(c,code.ComError,"鏌ヨ澶辫触")
+	}
+}
+
+type PollEnableVo struct {
+	Enable bool `json:"enable"`
+}
+// @Summary 鍒囨崲杞寮�鍏�
+// @Description 鍒囨崲杞寮�鍏�
+// @Produce json
+// @Tags 杞閰嶇疆
+// @Param argBody body controllers.PollEnableVo 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/pollConfig/updateEnable [post]
+func (controller PollConfigController) UpdateEnable(c *gin.Context){
+	var argBody PollEnableVo
+	if err := c.BindJSON(&argBody);err !=nil {
+		util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+		return
+	}
+	var api dbapi.SysSetApi
+	if api.UpdatePollEnable(argBody.Enable){
+		util.ResponseFormat(c,code.Success,"淇敼鎴愬姛")
+	} else {
+		util.ResponseFormat(c,code.ComError,"淇敼澶辫触")
+	}
+}
\ No newline at end of file

--
Gitblit v1.8.0