From 250e1e78af11922990923d8895abcbef53c1e20f Mon Sep 17 00:00:00 2001 From: iwanghc Date: Mon, 20 Jan 2025 17:24:27 +0800 Subject: [PATCH 1/3] add: db compare add rule execution error result --- sqle/api/controller/v1/database_compare.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sqle/api/controller/v1/database_compare.go b/sqle/api/controller/v1/database_compare.go index 4b8bd7999..1f9a41ccc 100644 --- a/sqle/api/controller/v1/database_compare.go +++ b/sqle/api/controller/v1/database_compare.go @@ -89,6 +89,8 @@ type SQLAuditResult struct { Message string `json:"message" example:"避免使用不必要的内置函数md5()"` RuleName string `json:"rule_name"` DbType string `json:"db_type"` + ExecutionFailed bool `json:"execution_failed" example:"false"` + ErrorInfo string `json:"error_info"` I18nAuditResultInfo model.I18nAuditResultInfo `json:"i18n_audit_result_info"` } From ccb97923158d096ecf416a3f793a19941f38bd7f Mon Sep 17 00:00:00 2001 From: iwanghc Date: Mon, 20 Jan 2025 17:44:26 +0800 Subject: [PATCH 2/3] add: direct audit add rule execution error result --- sqle/api/controller/v2/sql_audit.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sqle/api/controller/v2/sql_audit.go b/sqle/api/controller/v2/sql_audit.go index 93501d0ff..3e92421d6 100644 --- a/sqle/api/controller/v2/sql_audit.go +++ b/sqle/api/controller/v2/sql_audit.go @@ -84,21 +84,8 @@ func DirectAudit(c echo.Context) error { } func convertTaskResultToAuditResV2(ctx context.Context, task *model.Task) *AuditResDataV2 { - lang := locale.Bundle.GetLangTagFromCtx(ctx) results := make([]AuditSQLResV2, len(task.ExecuteSQLs)) for i, sql := range task.ExecuteSQLs { - - ar := make([]*AuditResult, len(sql.AuditResults)) - for j := range sql.AuditResults { - ar[j] = &AuditResult{ - Level: sql.AuditResults[j].Level, - Message: sql.AuditResults[j].GetAuditMsgByLangTag(lang), - RuleName: sql.AuditResults[j].RuleName, - DbType: task.DBType, - I18nAuditResultInfo: sql.AuditResults[j].I18nAuditResultInfo, - } - } - results[i] = AuditSQLResV2{ Number: sql.Number, ExecSQL: sql.Content, @@ -243,6 +230,8 @@ func convertAuditResultToAuditResV2(ctx context.Context, auditResults model.Audi ar[i] = AuditResult{ Level: auditResults[i].Level, Message: auditResults[i].GetAuditMsgByLangTag(lang), + ErrorInfo: auditResults[i].GetAuditErrorMsgByLangTag(lang), + ExecutionFailed: auditResults[i].ExecutionFailed, RuleName: auditResults[i].RuleName, I18nAuditResultInfo: auditResults[i].I18nAuditResultInfo, } From 3845e7533062dd5f54399b62ca58b487d4da2371 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Mon, 20 Jan 2025 18:01:58 +0800 Subject: [PATCH 3/3] gen swagger: add rule execution error result --- sqle/docs/docs.go | 7 +++++++ sqle/docs/swagger.json | 7 +++++++ sqle/docs/swagger.yaml | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index a53fb2595..a90cbcaed 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -17287,6 +17287,13 @@ var doc = `{ "db_type": { "type": "string" }, + "error_info": { + "type": "string" + }, + "execution_failed": { + "type": "boolean", + "example": false + }, "i18n_audit_result_info": { "type": "object", "$ref": "#/definitions/model.I18nAuditResultInfo" diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 4ae16cc6b..df1466cbb 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -17271,6 +17271,13 @@ "db_type": { "type": "string" }, + "error_info": { + "type": "string" + }, + "execution_failed": { + "type": "boolean", + "example": false + }, "i18n_audit_result_info": { "type": "object", "$ref": "#/definitions/model.I18nAuditResultInfo" diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index b64f701d6..b27167489 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -3993,6 +3993,11 @@ definitions: properties: db_type: type: string + error_info: + type: string + execution_failed: + example: false + type: boolean i18n_audit_result_info: $ref: '#/definitions/model.I18nAuditResultInfo' type: object