From 0ddab40835d44820bd17945ce3e3596329d09afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E6=BB=A1?= Date: Sun, 18 Apr 2021 19:50:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7command=E9=85=8D=E7=BD=AE,?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE=E8=AE=B0=E5=BD=95=E4=B8=8A?= =?UTF-8?q?=E8=A1=8C=E3=80=81=E4=B8=8B=E8=A1=8C=E6=95=B0=E6=8D=AE,?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E8=87=AA=E5=8A=A8=E5=93=8D=E5=BA=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/command.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/config/command.go b/config/command.go index 992b4f2..bcdb3c7 100644 --- a/config/command.go +++ b/config/command.go @@ -7,6 +7,17 @@ // Date : 2021-04-17 2:34 下午 package config +const ( + // DefaultPushMessageWithError 默认开启异常消息推送 + DefaultPushMessageWithError = true + // DefaultLogUpData 默认开记录上行数据 + DefaultLogUpData = true + // DefaultLogDownData 默认开启记录下行数据 + DefaultLogDownData = true + // DefaultResponseData 默认开启向客户端响应数据 + DefaultResponseData = true +) + // commandConfig 指令相关配置 // // Author : go_developer@163.com<张德满> @@ -14,6 +25,9 @@ package config // Date : 2:36 下午 2021/4/17 type CommandConfig struct { PushMessageWithError bool // 当调度指令时,指令执行错误,是否想客户端推送错误消息 + LogUpData bool // 记录上行数据(客户端发送上来的数据) + LogDownData bool // 记录响应数据(服务端向客户端响应的数据) + ResponseData bool // 是否需要向客户端响应数据 } // SetCommandConfig 设置command配置 @@ -30,6 +44,39 @@ func ClosePushCommandErrorMessage() SetCommandConfig { } } +// CloseLogUpData 关闭记录上行数据 +// +// Author : go_developer@163.com<张德满> +// +// Date : 7:44 下午 2021/4/18 +func CloseLogUpData() SetCommandConfig { + return func(cc *CommandConfig) { + cc.LogUpData = false + } +} + +// CloseLogDownData 关闭记录下行数据 +// +// Author : go_developer@163.com<张德满> +// +// Date : 7:45 下午 2021/4/18 +func CloseLogDownData() SetCommandConfig { + return func(cc *CommandConfig) { + cc.LogDownData = false + } +} + +// CloseResponseData 关闭向客户端发送响应结果 +// +// Author : go_developer@163.com<张德满> +// +// Date : 7:47 下午 2021/4/18 +func CloseResponseData() SetCommandConfig { + return func(cc *CommandConfig) { + cc.ResponseData = false + } +} + // NewCommandConfig 指令的配置 // // Author : go_developer@163.com<张德满> @@ -37,7 +84,10 @@ func ClosePushCommandErrorMessage() SetCommandConfig { // Date : 2:39 下午 2021/4/17 func NewCommandConfig(optionFunc ...SetCommandConfig) *CommandConfig { cc := &CommandConfig{ - PushMessageWithError: true, // 默认推送异常消息 + PushMessageWithError: DefaultPushMessageWithError, // 默认推送异常消息 + LogUpData: DefaultLogUpData, // 记录上行数据日志 + LogDownData: DefaultLogDownData, // 记录下行日志数据 + ResponseData: DefaultResponseData, // 默认自动响应数据 } for _, o := range optionFunc { o(cc)