From aa738b63580be3869ebcd9680b147af9c7a35637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=A4=A7=E5=A4=A7?= <397447182@qq.com> Date: Tue, 30 May 2023 07:00:40 +0000 Subject: [PATCH] =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E6=8F=92=E4=BB=B6--=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨大大 <397447182@qq.com> --- services/tp_protocol_plugin_service.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/services/tp_protocol_plugin_service.go b/services/tp_protocol_plugin_service.go index 2818918..a9f561f 100644 --- a/services/tp_protocol_plugin_service.go +++ b/services/tp_protocol_plugin_service.go @@ -84,11 +84,35 @@ func (*TpProtocolPluginService) AddTpProtocolPlugin(tp_protocol_plugin models.Tp // 修改数据 func (*TpProtocolPluginService) EditTpProtocolPlugin(tp_protocol_plugin valid.TpProtocolPluginValidate) error { - result := psql.Mydb.Model(&models.TpProtocolPlugin{}).Where("id = ?", tp_protocol_plugin.Id).Updates(&tp_protocol_plugin) + + tpProtocolPlugin := models.TpProtocolPlugin{} + query := psql.Mydb.Model(tpProtocolPlugin) + query.Where("id = ?", tp_protocol_plugin.Id).First(&tpProtocolPlugin) + result := query.Updates(&tp_protocol_plugin) if result.Error != nil { logs.Error(result.Error.Error(), gorm.ErrRecordNotFound) return result.Error } + var TpDictService TpDictService + tpDict := models.TpDict{} + var old_dict_code string + if tpProtocolPlugin.DeviceType == "1" { //直连设备 + old_dict_code = "DRIECT_ATTACHED_PROTOCOL" + } else { + old_dict_code = "GATEWAY_PROTOCOL" + } + psql.Mydb.Model(tpDict).Where("dict_value = ? and dict_code = ?", tpProtocolPlugin.ProtocolType, old_dict_code).First(&tpDict) + + var dict_code string + if tp_protocol_plugin.DeviceType == "1" { //直连设备 + dict_code = "DRIECT_ATTACHED_PROTOCOL" + } else { + dict_code = "GATEWAY_PROTOCOL" + } + tpDict.DictCode = dict_code + tpDict.DictValue = tp_protocol_plugin.ProtocolType + tpDict.Describe = tp_protocol_plugin.Name + TpDictService.EditTpDict(tpDict) return nil } -- Gitee