zhangqian
2023-08-24 e6c81b3916494ef51edc21774a27402d0f16c49c
api/v1/config.go
@@ -2,6 +2,7 @@
import (
   "apsClient/conf"
   "apsClient/constvar"
   "apsClient/model"
   "apsClient/model/request"
   _ "apsClient/model/response"
@@ -119,6 +120,20 @@
      return
   }
   if !params.Method.Valid() {
      ctx.FailWithMsg(ecode.ParamsErr, "接口方式不正确")
      return
   }
   if params.Method == constvar.PlcMethodModbusTCP && (params.Address == "" || params.Port == 0) {
      ctx.FailWithMsg(ecode.ParamsErr, "当接口方式为modbusTCP时,address和port不能为空")
      return
   }
   if params.Method == constvar.PlcMethodSerial && (params.BaudRate == 0 || params.SerialName == "") {
      ctx.FailWithMsg(ecode.ParamsErr, "当接口方式为serial时,baudRate和serialName不能为空")
      return
   }
   errCode := service.NewDevicePlcService().UpdateDevicePlc(&params)
   if errCode != ecode.OK {
      ctx.Fail(errCode)