From 8324f872ef3a4d0c978a9b1d062800c6a1701c12 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 01 十二月 2023 09:58:17 +0800 Subject: [PATCH] fix --- service/device_plc.go | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/service/device_plc.go b/service/device_plc.go index c8124a4..a643653 100644 --- a/service/device_plc.go +++ b/service/device_plc.go @@ -19,7 +19,7 @@ } func (slf DevicePlcService) GetDevicePlc() (*model.DevicePlc, int) { - DevicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First() + devicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First() if err == gorm.ErrRecordNotFound { logx.Errorf("GetDevicePlc failed:%v", err) return &model.DevicePlc{ @@ -41,8 +41,11 @@ logx.Errorf("GetDevicePlc failed:%v", err) return nil, ecode.DBErr } + if len(devicePlc.Details) == 0 { + return nil, ecode.PlcAddressError + } - return DevicePlc, ecode.OK + return devicePlc, ecode.OK } func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) { -- Gitblit v1.8.0