From 0fce2811421fa4b9e3f406371b45c831c88f1c7c Mon Sep 17 00:00:00 2001 From: BugsGuru Date: Wed, 31 Jul 2024 16:57:28 +0800 Subject: [PATCH 1/2] update AuditPlanSQLMeta api --- sqle/api/app.go | 4 ++-- sqle/api/controller/v1/instance_audit_plan.go | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sqle/api/app.go b/sqle/api/app.go index cacb0e0a4..276577b73 100644 --- a/sqle/api/app.go +++ b/sqle/api/app.go @@ -278,8 +278,8 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti v1ProjectRouter.PATCH("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/", v1.UpdateAuditPlanStatus) v1ProjectRouter.GET("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/sqls", v1.GetInstanceAuditPlanSQLs) // 弃用 v1ProjectRouter.GET("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/sql_meta", v1.GetInstanceAuditPlanSQLMeta) - v1ProjectRouter.GET("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/sql_data", v1.GetInstanceAuditPlanSQLData) - v1ProjectRouter.GET("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/sql_export", v1.GetInstanceAuditPlanSQLData) + v1ProjectRouter.POST("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/sql_data", v1.GetInstanceAuditPlanSQLData) + v1ProjectRouter.POST("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_type/sql_export", v1.GetInstanceAuditPlanSQLExport) // sql manager v1ProjectRouter.GET("/:project_name/sql_manages", v1.GetSqlManageList) diff --git a/sqle/api/controller/v1/instance_audit_plan.go b/sqle/api/controller/v1/instance_audit_plan.go index d1806b832..4e40e344d 100644 --- a/sqle/api/controller/v1/instance_audit_plan.go +++ b/sqle/api/controller/v1/instance_audit_plan.go @@ -891,6 +891,11 @@ func GetInstanceAuditPlanSQLs(c echo.Context) error { }) } +type GetAuditPlanSQLMetaResV1 struct { + controller.BaseRes + Data AuditPlanSQLMetaResV1 `json:"data"` +} + type AuditPlanSQLMetaResV1 struct { Head []AuditPlanSQLHeadV1 `json:"head"` FilterMetaList []FilterMeta `json:"filter_meta_list"` @@ -929,7 +934,7 @@ type FilterBetweenValue struct { // @Param project_name path string true "project name" // @Param instance_audit_plan_id path string true "instance audit plan id" // @Param audit_plan_type path string true "audit plan type" -// @Success 200 {object} v1.AuditPlanSQLMetaResV1 +// @Success 200 {object} v1.GetAuditPlanSQLMetaResV1 // @router /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_meta [get] func GetInstanceAuditPlanSQLMeta(c echo.Context) error { return nil From e93e8a80ef9bbe116ccfd916da71df2f8a947e45 Mon Sep 17 00:00:00 2001 From: BugsGuru Date: Wed, 31 Jul 2024 17:14:09 +0800 Subject: [PATCH 2/2] gen swag docs --- sqle/docs/docs.go | 23 ++++++++++++++++++++++- sqle/docs/swagger.json | 23 ++++++++++++++++++++++- sqle/docs/swagger.yaml | 17 ++++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 82e6c6157..d447036d7 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -2678,7 +2678,7 @@ var doc = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/v1.AuditPlanSQLMetaResV1" + "$ref": "#/definitions/v1.GetAuditPlanSQLMetaResV1" } } } @@ -10794,6 +10794,23 @@ var doc = `{ } } }, + "v1.GetAuditPlanSQLMetaResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "object", + "$ref": "#/definitions/v1.AuditPlanSQLMetaResV1" + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetAuditPlanSQLsResV1": { "type": "object", "properties": { @@ -12372,6 +12389,10 @@ var doc = `{ "type": "string", "example": "test" }, + "instance_id": { + "type": "string", + "example": "instance_id" + }, "instance_name": { "type": "string", "example": "test_mysql" diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 9020c573e..6a080a869 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -2662,7 +2662,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/v1.AuditPlanSQLMetaResV1" + "$ref": "#/definitions/v1.GetAuditPlanSQLMetaResV1" } } } @@ -10778,6 +10778,23 @@ } } }, + "v1.GetAuditPlanSQLMetaResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "object", + "$ref": "#/definitions/v1.AuditPlanSQLMetaResV1" + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetAuditPlanSQLsResV1": { "type": "object", "properties": { @@ -12356,6 +12373,10 @@ "type": "string", "example": "test" }, + "instance_id": { + "type": "string", + "example": "instance_id" + }, "instance_name": { "type": "string", "example": "test_mysql" diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 66ab2ff0c..92cb9e441 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -1119,6 +1119,18 @@ definitions: order_by: type: string type: object + v1.GetAuditPlanSQLMetaResV1: + properties: + code: + example: 0 + type: integer + data: + $ref: '#/definitions/v1.AuditPlanSQLMetaResV1' + type: object + message: + example: ok + type: string + type: object v1.GetAuditPlanSQLsResV1: properties: code: @@ -2213,6 +2225,9 @@ definitions: business: example: test type: string + instance_id: + example: instance_id + type: string instance_name: example: test_mysql type: string @@ -6364,7 +6379,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/v1.AuditPlanSQLMetaResV1' + $ref: '#/definitions/v1.GetAuditPlanSQLMetaResV1' security: - ApiKeyAuth: [] summary: 获取指定扫描任务的SQL列表元信息