Skip to content

Conversation

@BugsGuru
Copy link
Collaborator

@BugsGuru BugsGuru commented Dec 25, 2025

User description

关联的 issue

fix: #3190

描述你的变更

支持对工单“工单关闭”、“标记为人工上线”操作进行通知

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 增加工单取消通知调用

  • 增加人工上线通知调用

  • 更新中英文通知本地化

  • 扩展通知逻辑处理流程


Diagram Walkthrough

flowchart LR
  A["更新 workflow.go (v2)"] --> B["新增取消通知"]
  C["更新 workflow.go (v3)"] --> D["新增上线通知"]
  E["更新 locale 与 notification 模块"] --> F["扩展通知逻辑"]
Loading

File Walkthrough

Relevant files
Enhancement
workflow.go
添加工单取消通知调用                                                                                             

sqle/api/controller/v2/workflow.go

  • 添加取消工单通知调用
  • 采用异步方式执行通知逻辑
+2/-0     
workflow.go
添加工单人工上线通知调用                                                                                         

sqle/api/controller/v3/workflow.go

  • 添加人工上线通知调用
  • 确保批处理工单时通知用户
+3/-0     
notification.go
扩展通知逻辑处理                                                                                                 

sqle/notification/notification.go

  • 新增取消与人工上线通知逻辑处理
  • 扩展通知主题及用户通知分支
+28/-0   
Documentation
message_zh.go
更新中文通知文本                                                                                                 

sqle/locale/message_zh.go

  • 增加取消与人工上线中文消息
  • 更新本地化通知文本配置
+4/-0     
active.en.toml
更新英文通知文本                                                                                                 

sqle/locale/active.en.toml

  • 添加英文取消与人工上线通知文本
+4/-0     
active.zh.toml
更新中文通知文本                                                                                                 

sqle/locale/active.zh.toml

  • 添加中文取消与人工上线通知文本
+4/-0     

…tions

- Implemented notification for workflow cancellation and completion in the workflow controller.
- Updated localization files to include messages for canceled and completed workflows in both English and Chinese.
- Enhanced notification logic to ensure users are notified appropriately based on workflow status changes.
@github-actions
Copy link

PR Reviewer Guide 🔍

🎫 Ticket compliance analysis ✅

3190 - Fully compliant

Compliant requirements:

已添加取消和人工上线通知的调用逻辑,并同步更新了中英文本地化内容

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

异步通知调用

检查异步调用通知函数时的错误处理逻辑,确认是否需要捕获和记录潜在的异常情况,以确保调用流程的稳定性。

go im.BatchCancelApprove([]string{workflow.WorkflowId}, user)

go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeCancel)

return controller.JSONBaseErrorReq(c, nil)
通知类型映射

验证新增的取消和人工上线通知类型在通知处理函数中是否与现有流程保持一致,并确认通知内容的描述与业务逻辑相符。

case WorkflowNotifyTypeCancel:
	return "cancel"
case WorkflowNotifyTypeComplete:
	return "complete"
}

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
添加异步错误处理


建议在异步通知调用时增加错误处理或异常捕获措施,防止因通知过程中出现问题而导致隐藏的panic或错误。可以使用defer和recover捕获异常并记录错误日志,以便后续排查问题。

sqle/api/controller/v2/workflow.go [243]

-go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeCancel)
+go func() {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Error("notification.NotifyWorkflow panic:", r)
+		}
+	}()
+	notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeCancel)
+}()
Suggestion importance[1-10]: 7

__

Why: The suggestion enhances error handling in the asynchronous notification call on notification.NotifyWorkflow, which improves robustness without being critical. The proposed change directly wraps the call at line 243 with defer and recover, which is appropriate.

Medium
增加错误捕获机制

建议在该异步调用中增加异常捕获与日志记录机制,防止因通知失败而触发panic或引起问题。通过defer和recover可以确保通知过程中的异常被妥善处理。

sqle/api/controller/v3/workflow.go [113]

-go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeComplete)
+go func() {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Error("notification.NotifyWorkflow panic:", r)
+		}
+	}()
+	notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeComplete)
+}()
Suggestion importance[1-10]: 7

__

Why: This suggestion provides a similar error-handling improvement for the asynchronous call at line 113 in the V3 file, adding robustness with minimal intrusion. The change is relevant and directly derived from the diff.

Medium

@littleniannian littleniannian merged commit 4714f83 into main Dec 25, 2025
4 checks passed
@littleniannian littleniannian deleted the feat-add-workflow-notification branch December 25, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

工单通知没有支持“工单关闭”和“标记为人工上线”操作

3 participants