From bd8729d473966a17289a8d7c6eb9f8203154ed5a Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Fri, 24 Oct 2025 21:38:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.example.yml | 2 +- docs/docs.go | 4 +--- docs/swagger.json | 4 +--- docs/swagger.yaml | 6 +----- internal/app/dto/notification_dto.go | 1 - internal/infra/config/config.go | 2 +- internal/infra/notify/notify.go | 8 ++++---- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/config.example.yml b/config.example.yml index 7e1446e..455fd53 100644 --- a/config.example.yml +++ b/config.example.yml @@ -71,7 +71,7 @@ lora_mesh: # 通知服务配置 notify: - primary: "log" # 首选通知渠道: smtp, wechat, lark, log (如果其他渠道未启用,log 会自动成为首选) + primary: "日志" # 首选通知渠道: "邮件", "企业微信", "飞书", "日志" (如果其他渠道未启用,"日志" 会自动成为首选) failureThreshold: 2 # 连续失败多少次后触发广播模式 smtp: enabled: false # 是否启用 SMTP 邮件通知 diff --git a/docs/docs.go b/docs/docs.go index 0b8fdf8..b629949 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5656,7 +5656,7 @@ const docTemplate = `{ ], "properties": { "type": { - "description": "Type 指定要测试的通知渠道\n@enum(smtp, wechat, lark, log)", + "description": "Type 指定要测试的通知渠道", "allOf": [ { "$ref": "#/definitions/notify.NotifierType" @@ -6611,14 +6611,12 @@ const docTemplate = `{ "smtp", "wechat", "lark", - "sms", "log" ], "x-enum-varnames": [ "NotifierTypeSMTP", "NotifierTypeWeChat", "NotifierTypeLark", - "NotifierTypeSMS", "NotifierTypeLog" ] } diff --git a/docs/swagger.json b/docs/swagger.json index e0be324..b014fa8 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5648,7 +5648,7 @@ ], "properties": { "type": { - "description": "Type 指定要测试的通知渠道\n@enum(smtp, wechat, lark, log)", + "description": "Type 指定要测试的通知渠道", "allOf": [ { "$ref": "#/definitions/notify.NotifierType" @@ -6603,14 +6603,12 @@ "smtp", "wechat", "lark", - "sms", "log" ], "x-enum-varnames": [ "NotifierTypeSMTP", "NotifierTypeWeChat", "NotifierTypeLark", - "NotifierTypeSMS", "NotifierTypeLog" ] } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index e4eaa07..af35243 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1130,9 +1130,7 @@ definitions: type: allOf: - $ref: '#/definitions/notify.NotifierType' - description: |- - Type 指定要测试的通知渠道 - @enum(smtp, wechat, lark, log) + description: Type 指定要测试的通知渠道 required: - type type: object @@ -1832,14 +1830,12 @@ definitions: - smtp - wechat - lark - - sms - log type: string x-enum-varnames: - NotifierTypeSMTP - NotifierTypeWeChat - NotifierTypeLark - - NotifierTypeSMS - NotifierTypeLog info: contact: diff --git a/internal/app/dto/notification_dto.go b/internal/app/dto/notification_dto.go index bbefb8e..50e98f3 100644 --- a/internal/app/dto/notification_dto.go +++ b/internal/app/dto/notification_dto.go @@ -5,6 +5,5 @@ import "git.huangwc.com/pig/pig-farm-controller/internal/infra/notify" // SendTestNotificationRequest 定义了发送测试通知请求的 JSON 结构 type SendTestNotificationRequest struct { // Type 指定要测试的通知渠道 - // @enum(smtp, wechat, lark, log) Type notify.NotifierType `json:"type" binding:"required"` } diff --git a/internal/infra/config/config.go b/internal/infra/config/config.go index d4d583c..1a1cfb4 100644 --- a/internal/infra/config/config.go +++ b/internal/infra/config/config.go @@ -163,7 +163,7 @@ type LoraMeshConfig struct { // NotifyConfig 包含了所有与通知服务相关的配置 type NotifyConfig struct { - Primary string `yaml:"primary"` // 首选通知渠道 (e.g., "smtp", "wechat", "lark", "log") + Primary string `yaml:"primary"` // 首选通知渠道 (e.g., "邮件", "企业微信", "飞书", "日志") FailureThreshold int `yaml:"failureThreshold"` // 连续失败多少次后触发广播模式 SMTP SMTPConfig `yaml:"smtp"` WeChat WeChatConfig `yaml:"wechat"` diff --git a/internal/infra/notify/notify.go b/internal/infra/notify/notify.go index 84b9f9d..36b4a48 100644 --- a/internal/infra/notify/notify.go +++ b/internal/infra/notify/notify.go @@ -14,13 +14,13 @@ type NotifierType string const ( // NotifierTypeSMTP 表示 SMTP 邮件通知器。 - NotifierTypeSMTP NotifierType = "smtp" + NotifierTypeSMTP NotifierType = "邮件" // NotifierTypeWeChat 表示企业微信通知器。 - NotifierTypeWeChat NotifierType = "wechat" + NotifierTypeWeChat NotifierType = "企业微信" // NotifierTypeLark 表示飞书通知器。 - NotifierTypeLark NotifierType = "lark" + NotifierTypeLark NotifierType = "飞书" // NotifierTypeLog 表示日志通知器,作为最终的告警记录渠道。 - NotifierTypeLog NotifierType = "log" + NotifierTypeLog NotifierType = "日志" ) // AlarmContent 定义了通知的内容