From c84a97df024e2a1fbbb6d50a7bcb4b2e2a0838b8 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 07 十一月 2023 17:07:36 +0800 Subject: [PATCH] plc结果支持int32解析 --- api/v1/device.go | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/v1/device.go b/api/v1/device.go index 02cf81b..6f16b3a 100644 --- a/api/v1/device.go +++ b/api/v1/device.go @@ -29,7 +29,7 @@ if !ok { return } - if params.CurrentDeviceID != "" { + if params.CurrentDeviceID == "" { ctx.Fail(ecode.ParamsErr) return } @@ -45,7 +45,7 @@ return } service.SetDeviceIDToFile(params.CurrentDeviceID) - conf.Conf.SerfClusterStatus = params.CurrentDeviceID + conf.Conf.CurrentDeviceID = params.CurrentDeviceID err = crontask.RestartTask(conf.Conf.SerfClusterStatus != constvar.SerfClusterStatusSlave) if err != nil { logx.Errorf("restart task failed:%v", err) @@ -57,25 +57,29 @@ } // DeviceList -// @Tags Device +// @Tags 璁惧 // @Summary 鑾峰彇褰撳墠闈㈡澘缁戝畾鐨勮澶囧垪琛� // @Produce application/json // @Success 200 {object} contextx.Response{data=response.DeviceListResponse} "鎴愬姛" -// @Router /v1/device/list [post] +// @Router /v1/device/list [get] func (slf *DeviceApi) DeviceList(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } - list, err := service.GetDeviceIDList() + list, err := service.GetDeviceList() if err != nil { ctx.Fail(ecode.DBErr) return } resp := response.DeviceListResponse{ - SystemDeviceID: conf.Conf.System.DeviceId, - CurrentDeviceID: conf.Conf.CurrentDeviceID, - DeviceIDList: list, + SystemDeviceID: conf.Conf.System.DeviceId, + CurrentDeviceID: conf.Conf.CurrentDeviceID, + DeviceList: list, + SystemDeviceStatus: response.SystemDeviceStatusNormal, + ClusterStatus: conf.Conf.SerfClusterStatus, + ClusterNodeQuantity: conf.Conf.ClusterNodeQuantity, + SystemDeviceRunSince: conf.Conf.SystemDeviceRunSince, } ctx.OkWithDetailed(resp) } -- Gitblit v1.8.0