Skip to content

feat: add rule template name to audit task request and processing - #3090

Merged
Seechi-Yolo merged 2 commits into
mainfrom
add_rule_template_for_create_task
Jul 18, 2025
Merged

Seechi-Yolo merged 2 commits into
mainfrom
add_rule_template_for_create_task

Conversation

@iwanghc

@iwanghc iwanghc commented Jul 18, 2025 •

Copy link
Copy Markdown
Collaborator

User description

关联的 issue

issue: actiontech/dms#489

描述你的变更

可以指定审核规则模板创建审核任务

  • 创建审核任务接口 新增审核规则模板参数,

确认项(pr提交后操作)

Tip

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


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

link actiontech/dms#494


Description

  • 新增审核任务接口参数:rule_template_name

  • 查询并绑定规则模板至任务

  • 更新 swagger 接口文档及参数定义

  • 增强审核任务接口扩展性


Changes diagram

flowchart LR
  A["新增 rule_template_name 参数"]
  B["请求解析"]
  C["查询规则模板"]
  D["更新任务信息"]
  A -- "解析参数" --> B
  B -- "调用查询" --> C
  C -- "返回规则模板" --> D
Loading

Changes walkthrough 📝

Relevant files
Enhancement
task.go
支持基于规则模板创建审核任务                                                                                     

sqle/api/controller/v1/task.go

  • 添加 RuleTemplateName 字段到请求结构体
  • 根据模板名查询并绑定规则模板
+20/-7   
Documentation
docs.go
更新 API 文档中规则模板参数                                                                                 

sqle/docs/docs.go

  • 添加 rule_template_name 参数描述至接口文档
+9/-0     
swagger.json
swagger 中添加规则模板参数定义                                                                           

sqle/docs/swagger.json

  • 在 swagger.json 中增加 rule_template_name 定义
+9/-0     
swagger.yaml
swagger.yaml 中增加规则模板参数                                                                     

sqle/docs/swagger.yaml

  • 在 swagger.yaml 中增加 rule_template_name 参数定义
+6/-0     

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @actiontech-bot
    actiontech-bot requested review from Seechi-Yolo and removed request for Seechi-Yolo July 18, 2025 05:58
    @github-actions

    github-actions Bot commented Jul 18, 2025 •

    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Trim input spaces

    建议对输入的 rule_template_name 使用 TrimSpace 去除两端空格,以避免因用户输入额外空格导致匹配失败。这样可以提高后端规则模板匹配的鲁棒性。

    sqle/api/controller/v1/task.go [350-360]

    -if req.RuleTemplateName != nil && *req.RuleTemplateName != "" {
    -		ruleTemplate, exist, err := s.GetGlobalAndProjectRuleTemplateByNameAndProjectId(*req.RuleTemplateName, projectUid)
    +if req.RuleTemplateName != nil && strings.TrimSpace(*req.RuleTemplateName) != "" {
    +		trimmedName := strings.TrimSpace(*req.RuleTemplateName)
    +		ruleTemplate, exist, err := s.GetGlobalAndProjectRuleTemplateByNameAndProjectId(trimmedName, projectUid)
     		if err != nil {
     			return controller.JSONBaseErrorReq(c, err)
     		}
     		if !exist {
    -			return controller.JSONBaseErrorReq(c, errors.New(errors.DataNotExist, fmt.Errorf("rule template %v not exist", *req.RuleTemplateName)))
    +			return controller.JSONBaseErrorReq(c, errors.New(errors.DataNotExist, fmt.Errorf("rule template '%v' does not exist", trimmedName)))
     		}
     		task.RuleTemplate = ruleTemplate
     		task.RuleTemplateID = ruleTemplate.ID
     	}
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly improves robustness by trimming spaces from req.RuleTemplateName, which minimizes input errors. It has moderate impact and accurately targets the relevant new hunk lines.

    Medium

    @actiontech-bot
    actiontech-bot requested review from Seechi-Yolo and removed request for Seechi-Yolo July 18, 2025 06:02
    @github-actions

    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Trim input spaces

    建议对输入的 rule_template_name 使用 TrimSpace 去除两端空格,以避免因用户输入额外空格导致匹配失败。这样可以提高后端规则模板匹配的鲁棒性。

    sqle/api/controller/v1/task.go [350-360]

    -if req.RuleTemplateName != nil && *req.RuleTemplateName != "" {
    -		ruleTemplate, exist, err := s.GetGlobalAndProjectRuleTemplateByNameAndProjectId(*req.RuleTemplateName, projectUid)
    +if req.RuleTemplateName != nil && strings.TrimSpace(*req.RuleTemplateName) != "" {
    +		trimmedName := strings.TrimSpace(*req.RuleTemplateName)
    +		ruleTemplate, exist, err := s.GetGlobalAndProjectRuleTemplateByNameAndProjectId(trimmedName, projectUid)
     		if err != nil {
     			return controller.JSONBaseErrorReq(c, err)
     		}
     		if !exist {
    -			return controller.JSONBaseErrorReq(c, errors.New(errors.DataNotExist, fmt.Errorf("rule template %v not exist", *req.RuleTemplateName)))
    +			return controller.JSONBaseErrorReq(c, errors.New(errors.DataNotExist, fmt.Errorf("rule template '%v' does not exist", trimmedName)))
     		}
     		task.RuleTemplate = ruleTemplate
     		task.RuleTemplateID = ruleTemplate.ID
     	}
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly improves robustness by trimming spaces from req.RuleTemplateName, which minimizes input errors. It has moderate impact and accurately targets the relevant new hunk lines.

    Medium

    @Seechi-Yolo
    Seechi-Yolo merged commit 456ea43 into main Jul 18, 2025
    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.

    2 participants