diff --git a/sqle/api/app.go b/sqle/api/app.go index 687c29124..cacb0e0a4 100644 --- a/sqle/api/app.go +++ b/sqle/api/app.go @@ -279,6 +279,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti 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) // 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 0996caff1..44361b965 100644 --- a/sqle/api/controller/v1/instance_audit_plan.go +++ b/sqle/api/controller/v1/instance_audit_plan.go @@ -905,14 +905,14 @@ type AuditPlanSQLMetaResV1 struct { } type FilterMeta struct { - Name string `json:"filter_name"` - Desc string `json:"desc"` - FilterInputType string `json:"filter_input_type" enums:"int,string,date_time"` - FilterOperation string `json:"filter_op_type" enums:"equal,between"` - FilterTips []FilterTips `json:"filter_tip_list"` + Name string `json:"filter_name"` + Desc string `json:"desc"` + FilterInputType string `json:"filter_input_type" enums:"int,string,date_time"` + FilterOpType string `json:"filter_op_type" enums:"equal,between"` + FilterTips []FilterTip `json:"filter_tip_list"` } -type FilterTips struct { +type FilterTip struct { Value string `json:"value"` Desc string `json:"desc"` Group string `json:"group"` @@ -975,3 +975,24 @@ type AuditPlanSQLDataResV1 struct { func GetInstanceAuditPlanSQLData(c echo.Context) error { return nil } + +type GetAuditPlanSQLExportReqV1 struct { + OrderBy string `json:"order_by"` + IsAsc bool `json:"is_asc"` + Filters []Filter `json:"filter_list"` +} + +// @Summary 导出指定扫描任务的 SQL CSV 列表 +// @Description export audit plan SQL report as CSV +// @Id getInstanceAuditPlanSQLExportV1 +// @Tags instance_audit_plan +// @Security ApiKeyAuth +// @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" +// @param audit_plan_sql_request body v1.GetAuditPlanSQLExportReqV1 true "audit plan sql export request" +// @Success 200 {file} file "export audit plan sql report" +// @router /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_export [post] +func GetInstanceAuditPlanSQLExport(c echo.Context) error { + return nil +} diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 637734d69..7fecad748 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -2577,6 +2577,61 @@ var doc = `{ } } }, + "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_export": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "export audit plan SQL report as CSV", + "tags": [ + "instance_audit_plan" + ], + "summary": "导出指定扫描任务的 SQL CSV 列表", + "operationId": "getInstanceAuditPlanSQLExportV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance audit plan id", + "name": "instance_audit_plan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "audit plan type", + "name": "audit_plan_type", + "in": "path", + "required": true + }, + { + "description": "audit plan sql export request", + "name": "audit_plan_sql_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.GetAuditPlanSQLExportReqV1" + } + } + ], + "responses": { + "200": { + "description": "export audit plan sql report", + "schema": { + "type": "file" + } + } + } + } + }, "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_meta": { "get": { "security": [ @@ -10497,12 +10552,12 @@ var doc = `{ "filter_tip_list": { "type": "array", "items": { - "$ref": "#/definitions/v1.FilterTips" + "$ref": "#/definitions/v1.FilterTip" } } } }, - "v1.FilterTips": { + "v1.FilterTip": { "type": "object", "properties": { "desc": { @@ -10724,6 +10779,23 @@ var doc = `{ } } }, + "v1.GetAuditPlanSQLExportReqV1": { + "type": "object", + "properties": { + "filter_list": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.Filter" + } + }, + "is_asc": { + "type": "boolean" + }, + "order_by": { + "type": "string" + } + } + }, "v1.GetAuditPlanSQLsResV1": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 768cc6fe6..72d77bff9 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -2561,6 +2561,61 @@ } } }, + "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_export": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "export audit plan SQL report as CSV", + "tags": [ + "instance_audit_plan" + ], + "summary": "导出指定扫描任务的 SQL CSV 列表", + "operationId": "getInstanceAuditPlanSQLExportV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance audit plan id", + "name": "instance_audit_plan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "audit plan type", + "name": "audit_plan_type", + "in": "path", + "required": true + }, + { + "description": "audit plan sql export request", + "name": "audit_plan_sql_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.GetAuditPlanSQLExportReqV1" + } + } + ], + "responses": { + "200": { + "description": "export audit plan sql report", + "schema": { + "type": "file" + } + } + } + } + }, "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_meta": { "get": { "security": [ @@ -10481,12 +10536,12 @@ "filter_tip_list": { "type": "array", "items": { - "$ref": "#/definitions/v1.FilterTips" + "$ref": "#/definitions/v1.FilterTip" } } } }, - "v1.FilterTips": { + "v1.FilterTip": { "type": "object", "properties": { "desc": { @@ -10708,6 +10763,23 @@ } } }, + "v1.GetAuditPlanSQLExportReqV1": { + "type": "object", + "properties": { + "filter_list": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.Filter" + } + }, + "is_asc": { + "type": "boolean" + }, + "order_by": { + "type": "string" + } + } + }, "v1.GetAuditPlanSQLsResV1": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index a96f49c31..1d5a3958c 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -960,10 +960,10 @@ definitions: type: string filter_tip_list: items: - $ref: '#/definitions/v1.FilterTips' + $ref: '#/definitions/v1.FilterTip' type: array type: object - v1.FilterTips: + v1.FilterTip: properties: desc: type: string @@ -1114,6 +1114,17 @@ definitions: total_nums: type: integer type: object + v1.GetAuditPlanSQLExportReqV1: + properties: + filter_list: + items: + $ref: '#/definitions/v1.Filter' + type: array + is_asc: + type: boolean + order_by: + type: string + type: object v1.GetAuditPlanSQLsResV1: properties: code: @@ -6299,6 +6310,42 @@ paths: summary: 获取指定扫描任务的SQL列表 tags: - instance_audit_plan + /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_export: + post: + description: export audit plan SQL report as CSV + operationId: getInstanceAuditPlanSQLExportV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: instance audit plan id + in: path + name: instance_audit_plan_id + required: true + type: string + - description: audit plan type + in: path + name: audit_plan_type + required: true + type: string + - description: audit plan sql export request + in: body + name: audit_plan_sql_request + required: true + schema: + $ref: '#/definitions/v1.GetAuditPlanSQLExportReqV1' + responses: + "200": + description: export audit plan sql report + schema: + type: file + security: + - ApiKeyAuth: [] + summary: 导出指定扫描任务的 SQL CSV 列表 + tags: + - instance_audit_plan /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_type}/sql_meta: get: description: get audit plan SQL meta