| | |
| | | } else { |
| | | resData["server_id"] = sysconf.GetServerId() |
| | | resData["server_name"] = sysconf.GetServerName() |
| | | ipv4, mask, _ := util.GetLocalIP(config.Server.NetworkAdapter) |
| | | gateway, _ := util.GetDefaultRoute(config.Server.NetworkAdapter) |
| | | ipv4, mask, _ := sys.GetLocalIP(config.Server.NetworkAdapter) |
| | | gateway, _ := sys.GetDefaultRoute(config.Server.NetworkAdapter) |
| | | dns, _ := sys.GetDnsServer() |
| | | resData["ip"] = ipv4 |
| | | resData["subMask"] = mask |
| | | resData["gateway"] = gateway |
| | | resData["dns"] = dns |
| | | |
| | | resData["deviceNum"] = config.Server.DeviceNum |
| | | resData["deviceType"] = config.Server.DeviceType |
| | |
| | | var api dbapi.SysSetApi |
| | | paramBody := make(map[string]interface{}, 0) |
| | | paramBody["serverName"] = dev_name |
| | | |
| | | // 设置ip |
| | | isOk, msg := sys.SetNetworkConfig(c.PostForm("ip"), c.PostForm("subMask"), c.PostForm("gateway"), c.PostForm("dns")) |
| | | if !isOk { |
| | | util.ResponseFormat(c, code.ComError, msg) |
| | | return |
| | | } |
| | | |
| | | b, data := api.SaveServerInfo(paramBody) |
| | | if b { // 查询是否存在 |
| | | util.ResponseFormat(c, code.Success, data) |
| | |
| | | return |
| | | } |
| | | |
| | | if root := sys.CheckRootPermissions(); !root { |
| | | util.ResponseFormat(c, code.ServiceInsideError, "服务器没有修改时间的权限") |
| | | return |
| | | } |
| | | |
| | | if args.TimeZone != "CST" && args.TimeZone != "UTC" { |
| | | if r := sys.SetTimeZone(args.TimeZone); !r { |
| | | util.ResponseFormat(c, code.RequestParamError, "时区参数错误") |
| | |
| | | info := sys.GetSysInfo() |
| | | util.ResponseFormat(c, code.UpdateSuccess, info) |
| | | } |
| | | |
| | | // @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) |
| | | } |
| | | |
| | | // @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, "正在重启") |
| | | } |