Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#2497 #2498

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 27 additions & 6 deletions sqle/api/controller/v1/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
76 changes: 74 additions & 2 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
76 changes: 74 additions & 2 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
51 changes: 49 additions & 2 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading