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

Feat i18n dev3 ce #2618

Merged
merged 11 commits into from
Sep 20, 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
9 changes: 0 additions & 9 deletions sqle/api/controller/v1/audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ type AuditPlanParamResV1 struct {
EnumsValues []EnumsValueResV1 `json:"enums_value"`
}

type HighPriorityCondition struct {
Key string `json:"key"`
Desc string `json:"desc"`
Value string `json:"value"`
Type string `json:"type" enums:"string,int,bool,password"`
EnumsValues []params.EnumsValue `json:"enums_value"`
Operator Operator `json:"operator"`
}

type Operator struct {
Value string `json:"operator_value"`
EnumsValue []params.EnumsValue `json:"operator_enums_value"`
Expand Down
27 changes: 18 additions & 9 deletions sqle/api/controller/v1/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,20 @@ type InstanceAuditPlanDetailResV1 struct {
}

type AuditPlanRes struct {
RuleTemplateName string `json:"rule_template_name" from:"rule_template_name" example:"default_MySQL"`
Type AuditPlanTypeResBase `json:"audit_plan_type" form:"audit_plan_type"`
Params []AuditPlanParamResV1 `json:"audit_plan_params" valid:"dive,required"`
NeedMarkHighPrioritySQL bool `json:"need_mark_high_priority_sql"`
HighPriorityConditions []HighPriorityCondition `json:"high_priority_conditions"`
RuleTemplateName string `json:"rule_template_name" from:"rule_template_name" example:"default_MySQL"`
Type AuditPlanTypeResBase `json:"audit_plan_type" form:"audit_plan_type"`
Params []AuditPlanParamResV1 `json:"audit_plan_params" valid:"dive,required"`
NeedMarkHighPrioritySQL bool `json:"need_mark_high_priority_sql"`
HighPriorityConditions []HighPriorityConditionResV1 `json:"high_priority_conditions"`
}

type HighPriorityCondition struct {
Key string `json:"key"`
Desc string `json:"desc"`
Value string `json:"value"`
Type string `json:"type" enums:"string,int,bool,password"`
EnumsValues []params.EnumsValue `json:"enums_value"`
Operator Operator `json:"operator"`
}

// @Summary 获取实例扫描任务详情
Expand Down Expand Up @@ -680,20 +689,20 @@ func ConvertAuditPlansToRes(ctx context.Context, auditPlans []*model.AuditPlanV2
}

if v.HighPriorityParams != nil && len(v.HighPriorityParams) > 0 {
hppParamsRes := make([]HighPriorityCondition, len(v.HighPriorityParams))
hppParamsRes := make([]HighPriorityConditionResV1, len(v.HighPriorityParams))
for i, hpp := range v.HighPriorityParams {
for _, metaHpp := range meta.HighPriorityParams {
if metaHpp.Key != hpp.Key {
continue
}
highParamRes := HighPriorityCondition{
highParamRes := HighPriorityConditionResV1{
Key: metaHpp.Key,
Desc: metaHpp.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Value: hpp.Value,
Type: string(metaHpp.Type),
Operator: Operator{
Operator: OperatorResV1{
Value: string(hpp.Operator.Value),
EnumsValue: metaHpp.Operator.EnumsValue,
EnumsValue: ConvertEnumsValuesToRes(ctx, metaHpp.Operator.EnumsValue),
},
}
hppParamsRes[i] = highParamRes
Expand Down
64 changes: 1 addition & 63 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10476,21 +10476,6 @@ var doc = `{
"$ref": "#/definitions/model.AuditResultInfo"
}
},
"params.EnumsValue": {
"type": "object",
"properties": {
"desc": {
"description": "Deprecated: use I18nDesc instead",
"type": "string"
},
"i18n_desc": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"v1.AffectRows": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -10694,7 +10679,7 @@ var doc = `{
"high_priority_conditions": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.HighPriorityCondition"
"$ref": "#/definitions/v1.HighPriorityConditionResV1"
}
},
"need_mark_high_priority_sql": {
Expand Down Expand Up @@ -14072,39 +14057,6 @@ var doc = `{
}
}
},
"v1.HighPriorityCondition": {
"type": "object",
"properties": {
"desc": {
"type": "string"
},
"enums_value": {
"type": "array",
"items": {
"$ref": "#/definitions/params.EnumsValue"
}
},
"key": {
"type": "string"
},
"operator": {
"type": "object",
"$ref": "#/definitions/v1.Operator"
},
"type": {
"type": "string",
"enum": [
"string",
"int",
"bool",
"password"
]
},
"value": {
"type": "string"
}
}
},
"v1.HighPriorityConditionReq": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -14597,20 +14549,6 @@ var doc = `{
}
}
},
"v1.Operator": {
"type": "object",
"properties": {
"operator_enums_value": {
"type": "array",
"items": {
"$ref": "#/definitions/params.EnumsValue"
}
},
"operator_value": {
"type": "string"
}
}
},
"v1.OperatorResV1": {
"type": "object",
"properties": {
Expand Down
64 changes: 1 addition & 63 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -10460,21 +10460,6 @@
"$ref": "#/definitions/model.AuditResultInfo"
}
},
"params.EnumsValue": {
"type": "object",
"properties": {
"desc": {
"description": "Deprecated: use I18nDesc instead",
"type": "string"
},
"i18n_desc": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"v1.AffectRows": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -10678,7 +10663,7 @@
"high_priority_conditions": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.HighPriorityCondition"
"$ref": "#/definitions/v1.HighPriorityConditionResV1"
}
},
"need_mark_high_priority_sql": {
Expand Down Expand Up @@ -14056,39 +14041,6 @@
}
}
},
"v1.HighPriorityCondition": {
"type": "object",
"properties": {
"desc": {
"type": "string"
},
"enums_value": {
"type": "array",
"items": {
"$ref": "#/definitions/params.EnumsValue"
}
},
"key": {
"type": "string"
},
"operator": {
"type": "object",
"$ref": "#/definitions/v1.Operator"
},
"type": {
"type": "string",
"enum": [
"string",
"int",
"bool",
"password"
]
},
"value": {
"type": "string"
}
}
},
"v1.HighPriorityConditionReq": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -14581,20 +14533,6 @@
}
}
},
"v1.Operator": {
"type": "object",
"properties": {
"operator_enums_value": {
"type": "array",
"items": {
"$ref": "#/definitions/params.EnumsValue"
}
},
"operator_value": {
"type": "string"
}
}
},
"v1.OperatorResV1": {
"type": "object",
"properties": {
Expand Down
44 changes: 1 addition & 43 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ definitions:
additionalProperties:
$ref: '#/definitions/model.AuditResultInfo'
type: object
params.EnumsValue:
properties:
desc:
description: 'Deprecated: use I18nDesc instead'
type: string
i18n_desc:
type: string
value:
type: string
type: object
v1.AffectRows:
properties:
count:
Expand Down Expand Up @@ -165,7 +155,7 @@ definitions:
type: object
high_priority_conditions:
items:
$ref: '#/definitions/v1.HighPriorityCondition'
$ref: '#/definitions/v1.HighPriorityConditionResV1'
type: array
need_mark_high_priority_sql:
type: boolean
Expand Down Expand Up @@ -2491,29 +2481,6 @@ definitions:
example: ok
type: string
type: object
v1.HighPriorityCondition:
properties:
desc:
type: string
enums_value:
items:
$ref: '#/definitions/params.EnumsValue'
type: array
key:
type: string
operator:
$ref: '#/definitions/v1.Operator'
type: object
type:
enum:
- string
- int
- bool
- password
type: string
value:
type: string
type: object
v1.HighPriorityConditionReq:
properties:
key:
Expand Down Expand Up @@ -2844,15 +2811,6 @@ definitions:
user_name:
type: string
type: object
v1.Operator:
properties:
operator_enums_value:
items:
$ref: '#/definitions/params.EnumsValue'
type: array
operator_value:
type: string
type: object
v1.OperatorResV1:
properties:
operator_enums_value:
Expand Down
1 change: 1 addition & 0 deletions sqle/driver/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ func (p *PluginProcessor) GetDriverMetas() (*driverV2.DriverMetas, error) {
driverV2.OptionalModuleEstimateSQLAffectRows,
driverV2.OptionalModuleKillProcess,
driverV2.OptionalExecBatch,
driverV2.OptionalModuleI18n,
},
}, nil
}
Expand Down
Loading
Loading