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

fix(rule): api 新增query参数支持通过 rule_name 列表获取 rule #1419

Merged
merged 2 commits into from
Apr 4, 2023
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
6 changes: 4 additions & 2 deletions sqle/api/controller/v1/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ func convertRuleTemplatesToRes(templateNameToInstanceIds map[string][]uint,
}

type GetRulesReqV1 struct {
FilterDBType string `json:"filter_db_type" query:"filter_db_type"`
FilterGlobalRuleTemplateName string `json:"filter_global_rule_template_name" query:"filter_global_rule_template_name"`
FilterDBType string `json:"filter_db_type" query:"filter_db_type"`
FilterGlobalRuleTemplateName string `json:"filter_global_rule_template_name" query:"filter_global_rule_template_name"`
FilterRuleNames []string `json:"filter_rule_names" query:"filter_rule_names"`
}

type GetRulesResV1 struct {
Expand Down Expand Up @@ -469,6 +470,7 @@ func convertRulesToRes(rules []*model.Rule) []RuleResV1 {
// @Security ApiKeyAuth
// @Param filter_db_type query string false "filter db type"
// @Param filter_global_rule_template_name query string false "filter global rule template name"
// @Param filter_rule_names query array false "filter rule name list"
// @Success 200 {object} v1.GetRulesResV1
// @router /v1/rules [get]
func GetRules(c echo.Context) error {
Expand Down
16 changes: 11 additions & 5 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5461,6 +5461,12 @@ var doc = `{
"description": "filter global rule template name",
"name": "filter_global_rule_template_name",
"in": "query"
},
{
"type": "array",
"description": "filter global rule template name",
"name": "filter_rule_names",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -13636,7 +13642,10 @@ var doc = `{
"type": "string"
},
"audit_result": {
"type": "string"
"type": "array",
"items": {
"$ref": "#/definitions/v2.AuditResult"
}
},
"audit_status": {
"type": "string"
Expand All @@ -13645,10 +13654,7 @@ var doc = `{
"type": "string"
},
"exec_result": {
"type": "array",
"items": {
"$ref": "#/definitions/v2.AuditResult"
}
"type": "string"
},
"exec_sql": {
"type": "string"
Expand Down
16 changes: 11 additions & 5 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5445,6 +5445,12 @@
"description": "filter global rule template name",
"name": "filter_global_rule_template_name",
"in": "query"
},
{
"type": "array",
"description": "filter global rule template name",
"name": "filter_rule_names",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -13620,7 +13626,10 @@
"type": "string"
},
"audit_result": {
"type": "string"
"type": "array",
"items": {
"$ref": "#/definitions/v2.AuditResult"
}
},
"audit_status": {
"type": "string"
Expand All @@ -13629,10 +13638,7 @@
"type": "string"
},
"exec_result": {
"type": "array",
"items": {
"$ref": "#/definitions/v2.AuditResult"
}
"type": "string"
},
"exec_sql": {
"type": "string"
Expand Down
12 changes: 8 additions & 4 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3759,15 +3759,15 @@ definitions:
audit_level:
type: string
audit_result:
type: string
items:
$ref: '#/definitions/v2.AuditResult'
type: array
audit_status:
type: string
description:
type: string
exec_result:
items:
$ref: '#/definitions/v2.AuditResult'
type: array
type: string
exec_sql:
type: string
exec_status:
Expand Down Expand Up @@ -7637,6 +7637,10 @@ paths:
in: query
name: filter_global_rule_template_name
type: string
- description: filter global rule template name
in: query
name: filter_rule_names
type: array
responses:
"200":
description: OK
Expand Down