From 10c65da3d2af7056f48d9301e83f53f102f76e18 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 30 十月 2023 14:52:11 +0800 Subject: [PATCH] fix --- service/device_plc.go | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/service/device_plc.go b/service/device_plc.go index fc5fadc..d98d689 100644 --- a/service/device_plc.go +++ b/service/device_plc.go @@ -22,14 +22,17 @@ DevicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.System.DeviceId).First() if err == gorm.ErrRecordNotFound { return &model.DevicePlc{ + DeviceID: "", Brand: "", Method: "", Address: "", Port: 0, BaudRate: 0, SerialName: "", + DataBit: 0, + StopBit: 0, + Parity: 0, IsOpen: false, - Detail: "", Details: make([]*model.DevicePlcAddress, 0), }, ecode.OK } @@ -64,11 +67,10 @@ return ecode.ParamsErr } record.Detail = string(detail) - - if plc.Id == 0 { + if record.ID == 0 { err = model.NewDevicePlcSearch().Create(&record) } else { - err = model.NewDevicePlcSearch().SetId(plc.Id).Save(&record) + err = model.NewDevicePlcSearch().Save(&record) } if err != nil { -- Gitblit v1.8.0