From 94a8c84e8d29300644a689ce2cd6f537f1993224 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 19 八月 2023 17:41:30 +0800
Subject: [PATCH] plc查询和修改接口

---
 api/v1/config.go |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/api/v1/config.go b/api/v1/config.go
index d14c0a6..43065ad 100644
--- a/api/v1/config.go
+++ b/api/v1/config.go
@@ -2,6 +2,7 @@
 
 import (
 	"apsClient/model"
+	"apsClient/model/request"
 	_ "apsClient/model/response"
 	"apsClient/pkg/contextx"
 	"apsClient/pkg/ecode"
@@ -40,7 +41,7 @@
 // @Produce   application/json
 // @Param	  object	body  model.NetConfig	true	"鍙傛暟"
 // @Success   200   {object}  contextx.Response{data=[]response.ProcessParams}  "鎴愬姛"
-// @Router    /v1/config/net [put]
+// @Router    /v1/config/net [post]
 func (slf *ConfigApi) SetNetConfig(c *gin.Context) {
 	var params model.NetConfig
 	ctx, ok := contextx.NewContext(c, &params)
@@ -64,3 +65,46 @@
 	}
 	ctx.Ok()
 }
+
+// PlcGet
+// @Tags      Config
+// @Summary   鑾峰彇plc閰嶇疆
+// @Produce   application/json
+// @Success   200   {object}  contextx.Response{data=model.DevicePlc}  "鎴愬姛"
+// @Router    /v1/config/plc [get]
+func (slf *ConfigApi) PlcGet(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	plcData, code := service.NewDevicePlcService().GetDevicePlc()
+	if code != ecode.OK {
+		ctx.Fail(code)
+		return
+	}
+	ctx.OkWithDetailed(plcData)
+}
+
+// PlcUpdate
+// @Tags	Config
+// @Summary	 鏇存柊plc閰嶇疆
+// @Produce	application/json
+// @Param		object	body	request.UpdatePlc	true	"鏌ヨ鍙傛暟"
+// @Success	200		{object}	contextx.Response{}
+// @Router		/v1/config/plc [post]
+func (slf *ConfigApi) PlcUpdate(c *gin.Context) {
+	var params request.UpdatePlc
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode := service.NewDevicePlcService().UpdateDevicePlc(&params)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}

--
Gitblit v1.8.0