From a1bb1fb1e5ff5cf18a6d287dfa02978ec7ca8fa1 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期三, 20 十一月 2019 20:32:07 +0800 Subject: [PATCH] update esutil --- controllers/syssetcont.go | 59 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 48 insertions(+), 11 deletions(-) diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go index 4045ebf..9275310 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" @@ -100,7 +101,6 @@ // @Security ApiKeyAuth // @Summary 瀛樺偍淇℃伅淇敼 // @Description 瀛樺偍淇℃伅淇敼 -// @Accept json // @Produce json // @Tags sysset // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" @@ -196,7 +196,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) @@ -283,7 +282,6 @@ // @Security ApiKeyAuth // @Summary 娴嬭瘯鍚屾鏃堕棿 // @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢� -// @Accept json // @Produce json // @Tags sysset // @Param server query string true "鏃堕棿鏈嶅姟鍣╥p" @@ -298,17 +296,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 +387,45 @@ 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