Skip to content

update api from v1 to v2#3015

Merged
iwanghc merged 5 commits into3008-commitsfrom
3008-commits-lxt
Apr 10, 2025
Merged

update api from v1 to v2#3015
iwanghc merged 5 commits into3008-commitsfrom
3008-commits-lxt

Conversation

@Seechi-Yolo
Copy link
Copy Markdown
Collaborator

@Seechi-Yolo Seechi-Yolo commented Apr 10, 2025

User description

assign in @iwanghc

关联的 issue

#3008

描述你的变更

升级以下2个接口 from v1 to v2

  1. GetInstanceAuditPlans
  2. GetInstanceAuditPlanDetail
    删除已废弃接口的业务逻辑

确认项(pr提交后操作)

Tip

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


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


Description

  • 添加环境属性管理功能

  • 迁移实例审核计划API到v2

  • 更新API文档和Swagger

  • 修改本地化消息内容


Changes walkthrough 📝

Relevant files
Enhancement
10 files
app.go
迁移实例审核计划API到v2                                                                                     
+4/-2     
instance.go
标记过时的业务参数                                                                                               
+2/-2     
instance_audit_plan.go
移除过时的实例审核计划逻辑                                                                                       
+7/-199 
project_permission.go
更新项目权限中的环境标签过滤                                                                                     
+1/-1     
sql_manage.go
标记过时的业务过滤参数                                                                                           
+5/-5     
workflow.go
更新工作流中的实例服务类型引用                                                                                   
+1/-1     
instance_audit_plan.go
新增v2实例审核计划API实现                                                                                   
+320/-5 
sql_manage.go
标记导出SQL管理功能为无效                                                                                     
+2/-2     
instance.go
更新实例模型以使用环境属性                                                                                       
+10/-8   
instance.go
移除实例模型中的业务字段                                                                                         
+0/-2     
Documentation
6 files
docs.go
更新API文档添加v2实例审核计划                                                                               
+294/-6 
message_zh.go
更新本地化消息替换业务为环境                                                                                     
+3/-3     
swagger.json
更新Swagger文档添加v2实例审核计划                                                                       
+294/-6 
swagger.yaml
更新Swagger YAML添加v2实例审核计划                                                                 
+200/-10
active.en.toml
更新英文本地化消息                                                                                               
+1/-1     
active.zh.toml
更新中文本地化消息                                                                                               
+1/-1     

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • - Move instance audit plan related endpoints from v1 to v2
    - Update data structures and API responses for v2
    - Deprecate v1 endpoints for instance audit plans
    - Improve error handling and data validation in v2 endpoints
    …anagement features
    
    - Remove deprecated business parameter from SQL management related APIs
    - Update SQL management features to use environment tag instead of business
    - Refactor instance retrieval methods to use new API structures
    - Update notification body to use environment instead of business
    - Remove deprecated flag from getInstanceAuditPlansV1 endpoint
    - Add new endpoint for getting instance audit plan details in v2
    - Update parameter descriptions across multiple endpoints
    - Add new response models for v2 API
    - Remove 'Business' field from the notification content
    - Rename 'Environment' to '环境属性' in Chinese locale
    - Update corresponding English and Chinese locale files
    - Add new API endpoint for v2 instance audit plans
    - Update existing API to use deprecated flag
    - Add new response models for v2 instance audit plans
    - Update API documentation in Swagger JSON and YAML formats
    @actiontech-bot actiontech-bot requested a review from iwanghc April 10, 2025 10:25
    @github-actions
    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    @github-actions
    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    修正 HTTP 响应

    在 HTTP 处理函数中返回 nil 可能导致请求挂起或服务器崩溃。请确保返回适当的 HTTP 响应,例如使用 c.JSON 返回具体的状态码和消息。

    sqle/api/controller/v1/instance_audit_plan.go [494]

    -+	return nil
    +return c.JSON(http.StatusOK, controller.NewBaseReq(nil))
    Suggestion importance[1-10]: 8

    __

    Why: Returning 'nil' in an HTTP handler can cause requests to hang or lead to server errors. Replacing it with a proper HTTP response like 'c.JSON' ensures correct client communication.

    Medium
    修复空响应问题

    在 SQL 管理的 HTTP 处理函数中返回 nil 会导致客户端接收到空响应,影响用户体验。建议返回具体的 HTTP 状态码和响应内容,如 c.JSON

    sqle/api/controller/v1/sql_manage.go [103]

    -+	return nil
    +return c.JSON(http.StatusOK, controller.NewBaseReq(nil))
    Suggestion importance[1-10]: 8

    __

    Why: Returning 'nil' in an HTTP handler leads to empty responses, affecting the client. Replacing it with a proper HTTP response like 'c.JSON' improves user experience.

    Medium
    确保正确响应

    在版本 2 的 SQL 管理处理函数中返回 nil 会使 API 无法正确响应客户端请求,可能引发服务器错误。请替换为适当的响应方法,如
    c.JSON,并提供必要的数据。

    sqle/api/controller/v2/sql_manage.go [66]

    -+	return nil
    +return c.JSON(http.StatusOK, controller.NewBaseReq(nil))
    Suggestion importance[1-10]: 8

    __

    Why: Returning 'nil' in an HTTP handler results in improper API responses, potentially causing server errors. Using 'c.JSON' with relevant data ensures correct client responses.

    Medium

    @iwanghc iwanghc merged commit 66a3d5f into 3008-commits Apr 10, 2025
    2 checks passed
    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