From 0d72a0b3bbc9ab5884a0680b71f6d96d48c2173e Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期四, 31 十月 2019 13:47:48 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/webserver --- controllers/syssetcont.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 47 insertions(+), 9 deletions(-) diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go index 4045ebf..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" @@ -196,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) @@ -298,17 +298,14 @@ 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 @@ -392,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