From f26a0cab5bca17b7eab57f6330e576271e17a17f Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 13 十一月 2019 19:12:08 +0800
Subject: [PATCH] update ynSwagger,sync to master

---
 controllers/syssetcont.go |  194 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 193 insertions(+), 1 deletions(-)

diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go
index fe25b70..0ebeb4e 100644
--- a/controllers/syssetcont.go
+++ b/controllers/syssetcont.go
@@ -3,6 +3,7 @@
 import (
 	"basic.com/dbapi.git"
 	"github.com/gin-gonic/gin"
+	"regexp"
 	"webserver/extend/code"
 	"webserver/extend/config"
 	"webserver/extend/util"
@@ -42,6 +43,7 @@
 	UpdateTime string `json:"UpdateTime"`
 }
 
+// @Security ApiKeyAuth
 // @Summary 鍩虹璁剧疆鏌ヨ
 // @Description 鍩虹璁剧疆鏌ヨ
 // @Accept  json
@@ -60,6 +62,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鎶ヨ璁剧疆淇敼
 // @Description 鎶ヨ璁剧疆淇敼
 // @Accept  json
@@ -86,6 +89,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鎶ヨ鏃堕暱淇敼
 // @Description 鎶ヨ鏃堕暱淇敼
 // @Accept  json
@@ -108,6 +112,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 瑙嗛鎴彇鏃堕暱淇敼
 // @Description 瑙嗛鎴彇鏃堕暱淇℃伅
 // @Accept  x-www-form-urlencoded
@@ -133,6 +138,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鑾峰彇鍒嗘瀽璁惧淇℃伅
 // @Description  鍒嗘瀽璁惧淇℃伅
 // @Accept  json
@@ -160,6 +166,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // saveDevInfo  dev_id dev_name
 // @Summary 淇濆瓨瑙嗛鍒嗘瀽璁惧淇℃伅
 // @Description 鍒嗘瀽璁惧淇℃伅
@@ -184,7 +191,7 @@
 	}
 }
 
-
+// @Security ApiKeyAuth
 // @Summary GB28181璁剧疆鏌ヨ
 // @Description GB28181璁剧疆淇℃伅鏌ヨ
 // @Accept  json
@@ -203,6 +210,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary GB28181璁剧疆淇℃伅淇敼
 // @Description GB28181璁剧疆淇敼
 // @Accept  json
@@ -228,3 +236,187 @@
 		util.ResponseFormat(c,code.ComError,"鏇存柊澶辫触")
 	}
 }
+
+/*
+// @Security ApiKeyAuth
+// @Summary 鑾峰彇鏃堕棿閰嶇疆
+// @Description  绯荤粺鏃堕棿閰嶇疆淇℃伅
+// @Accept  json
+// @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/clockInfo [GET]
+*/
+func (sset SysSetController) GetClockinfo(c *gin.Context) {
+	resData := make(map[string]interface{}, 0)
+	resData["time_zone"], resData["local_time"] = sys.TimeZone()
+	resData["ntp"], resData["ntp_server"], resData["interval"] = sys.NTPConfig()
+
+	util.ResponseFormat(c, code.Success, resData)
+}
+
+/*
+// @Security ApiKeyAuth
+// @Summary 娴嬭瘯鍚屾鏃堕棿
+// @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢�
+// @Produce json
+// @Tags sysset
+// @Param server query string true "鏃堕棿鏈嶅姟鍣╥p"
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/sysset/ntpTest [GET]
+*/
+func (sset SysSetController) TestNTPServer(c *gin.Context) {
+	ntpServer := c.Query("server")
+
+	if root := sys.CheckRootPermissions(); !root {
+		util.ResponseFormat(c, code.ServiceInsideError, "鏈嶅姟鍣ㄦ病鏈変慨鏀规椂闂寸殑鏉冮檺")
+		return
+	}
+
+	isConn := sys.RunNTPDate(ntpServer)
+	if !isConn {
+		util.ResponseFormat(c, code.RequestParamError, "NTP鏈嶅姟鍣ㄤ笉鍙敤")
+		return
+	}
+
+	util.ResponseFormat(c, code.Success, "")
+
+}
+
+/*
+// @Security ApiKeyAuth
+// @Summary 璁剧疆绯荤粺鏃堕棿
+// @Description 鏍℃绯荤粺鏃堕棿
+// @Accept  json
+// @Produce json
+// @Tags sysset
+// @Param config body controllers.SysClockConfigVo true "鏍℃椂淇℃伅"
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/sysset/updateClock [POST]
+*/
+func (sset SysSetController) SetSysClock(c *gin.Context) {
+	var args SysClockConfigVo
+	err := c.BindJSON(&args)
+	if err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+		return
+	}
+
+	if args.TimeZone != "CST" && args.TimeZone != "UTC" {
+		if r := sys.SetTimeZone(args.TimeZone); !r {
+			util.ResponseFormat(c, code.RequestParamError, "鏃跺尯鍙傛暟閿欒")
+			return
+		}
+	}
+
+	if !args.NTP {
+		if r := sys.SetLocalTime(args.NewTime); !r {
+			util.ResponseFormat(c, code.RequestParamError, "鎸囧畾鐨勬椂闂村弬鏁伴敊璇�")
+			return
+		}
+	} else {
+		if r := sys.EnableNTPCron(args.NTPServer, args.Interval); !r {
+			util.ResponseFormat(c, code.RequestParamError, "鎸囧畾鐨勬湇鍔″櫒鍦板潃閿欒")
+			return
+		}
+	}
+
+	util.ResponseFormat(c, code.UpdateSuccess, "閰嶇疆鎴愬姛")
+}
+
+/*
+// @Security ApiKeyAuth
+// @Summary 鏌ヨ绯荤粺杩愯淇℃伅
+// @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨绛�
+// @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/sysinfo [GET]
+*/
+func (sset SysSetController) GetSysInfo(c *gin.Context) {
+	info := sys.GetSysInfo()
+	util.ResponseFormat(c, code.UpdateSuccess, info)
+}
+
+/*
+// @Security ApiKeyAuth
+// @Summary 鏌ヨ绯荤粺鐘舵�侀槇鍊艰缃�
+// @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨鐨勯槇鍊奸厤缃�
+// @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/sysThresholds [GET]
+*/
+func (sset SysSetController) GetSysThresholds(c *gin.Context) {
+	util.ResponseFormat(c, code.UpdateSuccess, config.Server.SysThresholds)
+}
+
+/*
+// @Security ApiKeyAuth
+// @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/reboot [GET]
+*/
+func (sset SysSetController) RebootOS(c *gin.Context) {
+	if isOk, msg := sys.Reboot(); !isOk {
+		util.ResponseFormat(c, code.UpdateFail, msg)
+		return
+	}
+
+	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 璁剧疆瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒�
+// @Accept x-www-form-urlencoded
+// @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