From 712ef81c6b8813a498a66cf61ffcd37e5c502c8c Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期五, 01 十一月 2019 13:45:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 controllers/syssetcont.go |   70 ++++++++++++++++++++++++++++++----
 1 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go
index 8034844..96705e3 100644
--- a/controllers/syssetcont.go
+++ b/controllers/syssetcont.go
@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"regexp"
 	"webserver/extend/code"
 	"webserver/extend/config"
 	"webserver/extend/sys"
@@ -51,6 +52,7 @@
 	NewTime   string `json:"newTime" example:"鎵嬪姩鎸囧畾鏃堕棿"`
 }
 
+// @Security ApiKeyAuth
 // @Summary 瀛樺偍淇℃伅鏌ヨ
 // @Description 瀛樺偍淇℃伅鏌ヨ
 // @Accept  json
@@ -69,6 +71,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 瀛樺偍淇℃伅淇敼
 // @Description 瀛樺偍淇℃伅淇敼
 // @Accept  json
@@ -95,6 +98,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 瀛樺偍淇℃伅淇敼
 // @Description 瀛樺偍淇℃伅淇敼
 // @Accept  json
@@ -117,6 +121,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 瑙嗛鎴彇鏃堕暱淇敼
 // @Description 瑙嗛鎴彇鏃堕暱淇℃伅
 // @Accept  x-www-form-urlencoded
@@ -142,6 +147,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鑾峰彇鍒嗘瀽璁惧淇℃伅
 // @Description  鍒嗘瀽璁惧淇℃伅
 // @Accept  json
@@ -179,6 +185,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // saveDevInfo  dev_id dev_name
 // @Summary 淇濆瓨瑙嗛鍒嗘瀽璁惧淇℃伅
 // @Description 鍒嗘瀽璁惧淇℃伅
@@ -190,7 +197,6 @@
 // @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
 // @Router /data/api-v/sysset/saveDevInfo [POST]
 func (sset SysSetController) SaveDevInfo(c *gin.Context) {
-
 	dev_name := c.PostForm("server_name")
 	var api dbapi.SysSetApi
 	paramBody := make(map[string]interface{}, 0)
@@ -211,6 +217,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary GB28181璁剧疆鏌ヨ
 // @Description GB28181璁剧疆淇℃伅鏌ヨ
 // @Accept  json
@@ -229,6 +236,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary GB28181璁剧疆淇℃伅淇敼
 // @Description GB28181璁剧疆淇敼
 // @Accept  json
@@ -255,6 +263,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鑾峰彇鏃堕棿閰嶇疆
 // @Description  绯荤粺鏃堕棿閰嶇疆淇℃伅
 // @Accept  json
@@ -271,6 +280,7 @@
 	util.ResponseFormat(c, code.Success, resData)
 }
 
+// @Security ApiKeyAuth
 // @Summary 娴嬭瘯鍚屾鏃堕棿
 // @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢�
 // @Accept  json
@@ -288,19 +298,17 @@
 		return
 	}
 
-	isIP, err := sys.RunNTPDate(ntpServer)
-	if !isIP {
-		util.ResponseFormat(c, code.RequestParamError, "鎸囧畾鐨勬湇鍔″櫒鍦板潃閿欒")
+	isConn := sys.RunNTPDate(ntpServer)
+	if !isConn {
+		util.ResponseFormat(c, code.RequestParamError, "NTP鏈嶅姟鍣ㄤ笉鍙敤")
 		return
 	}
 
-	if err == nil {
-		util.ResponseFormat(c, code.Success, "")
-	} else {
-		util.ResponseFormat(c, code.TaskStoped, "")
-	}
+	util.ResponseFormat(c, code.Success, "")
+
 }
 
+// @Security ApiKeyAuth
 // @Summary 璁剧疆绯荤粺鏃堕棿
 // @Description 鏍℃绯荤粺鏃堕棿
 // @Accept  json
@@ -340,6 +348,7 @@
 	util.ResponseFormat(c, code.UpdateSuccess, "閰嶇疆鎴愬姛")
 }
 
+// @Security ApiKeyAuth
 // @Summary 鏌ヨ绯荤粺杩愯淇℃伅
 // @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨绛�
 // @Produce json
@@ -352,6 +361,7 @@
 	util.ResponseFormat(c, code.UpdateSuccess, info)
 }
 
+// @Security ApiKeyAuth
 // @Summary 鏌ヨ绯荤粺鐘舵�侀槇鍊艰缃�
 // @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨鐨勯槇鍊奸厤缃�
 // @Produce json
@@ -363,6 +373,7 @@
 	util.ResponseFormat(c, code.UpdateSuccess, config.Server.SysThresholds)
 }
 
+// @Security ApiKeyAuth
 // @Summary 閲嶅惎绯荤粺
 // @Description 閲嶅惎鎿嶄綔绯荤粺
 // @Produce json
@@ -378,3 +389,44 @@
 
 	util.ResponseFormat(c, code.Success, "姝e湪閲嶅惎")
 }
+
+// @Summary 鑾峰彇瀹氭椂閲嶅惎
+// @Description 鑾峰彇瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒�
+// @Produce json
+// @Tags sysset
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/sysset/rebootTask [GET]
+func (sset SysSetController) GetRebootTask(c *gin.Context) {
+	_, msg := sys.ReadRebootTaskInCrontab()
+	util.ResponseFormat(c, code.Success, msg)
+}
+
+// @Summary 璁剧疆瀹氭椂閲嶅惎
+// @Description 璁剧疆瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒�
+// @Produce json
+// @Tags sysset
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/sysset/rebootTask [POST]
+func (sset SysSetController) SetRebootTask(c *gin.Context) {
+	task := c.PostForm("task")
+	if len(task) < 1 {
+		sys.CleanRebootTask()
+		util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛")
+		return
+	}
+
+	regEx := `^([0-9*]+\s){4}[0-9*]+$`
+	if r, _ := regexp.MatchString(regEx, task); !r {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟閿欒")
+		return
+	}
+
+	if r := sys.UpdateRebootTask(task); !r {
+		util.ResponseFormat(c, code.UpdateFail, "閰嶇疆澶辫触")
+		return
+	}
+
+	util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛")
+}

--
Gitblit v1.8.0