From 0ac1167a7d7b1feaac55e9ded6d159dee4280aa1 Mon Sep 17 00:00:00 2001 From: lizhensheng Date: Wed, 13 Dec 2023 14:29:09 +0800 Subject: [PATCH] [feature]:(SQLManagement) build api and add schema column for list --- src/api/SqlManage/index.d.ts | 6 +++ src/api/SqlManage/index.ts | 2 +- src/api/audit_plan/index.d.ts | 22 +++++++++- src/api/audit_plan/index.ts | 42 ++++++++++++++++++- src/api/common.d.ts | 30 ++++++++++++++ src/page/SQLManagement/SQLPanel/column.tsx | 48 +++++++++++++++------- 6 files changed, 133 insertions(+), 17 deletions(-) diff --git a/src/api/SqlManage/index.d.ts b/src/api/SqlManage/index.d.ts index 7afecece..ab6606d5 100644 --- a/src/api/SqlManage/index.d.ts +++ b/src/api/SqlManage/index.d.ts @@ -48,6 +48,8 @@ export interface IGetSqlManageListParams { fuzzy_search_endpoint?: string; + fuzzy_search_schema_name?: string; + sort_field?: GetSqlManageListSortFieldEnum; sort_order?: GetSqlManageListSortOrderEnum; @@ -90,6 +92,8 @@ export interface IExportSqlManageV1Params { fuzzy_search_endpoint?: string; + fuzzy_search_schema_name?: string; + sort_field?: exportSqlManageV1SortFieldEnum; sort_order?: exportSqlManageV1SortOrderEnum; @@ -127,6 +131,8 @@ export interface IGetSqlManageListV2Params { fuzzy_search_endpoint?: string; + fuzzy_search_schema_name?: string; + sort_field?: GetSqlManageListV2SortFieldEnum; sort_order?: GetSqlManageListV2SortOrderEnum; diff --git a/src/api/SqlManage/index.ts b/src/api/SqlManage/index.ts index dde1db11..5ea417b2 100644 --- a/src/api/SqlManage/index.ts +++ b/src/api/SqlManage/index.ts @@ -15,7 +15,7 @@ import { IGetSqlManageRuleTipsParams, IGetSqlManageRuleTipsReturn, IGetSqlManageListV2Params, - IGetSqlManageListV2Return, + IGetSqlManageListV2Return } from './index.d'; class SqlManageService extends ServiceBase { diff --git a/src/api/audit_plan/index.d.ts b/src/api/audit_plan/index.d.ts index 27ddd430..20b2e627 100644 --- a/src/api/audit_plan/index.d.ts +++ b/src/api/audit_plan/index.d.ts @@ -19,7 +19,9 @@ import { ITriggerAuditPlanResV1, IGetAuditPlansResV2, IGetAuditPlanReportSQLsResV2, - IGetAuditPlanAnalysisDataResV2 + IGetAuditPlanAnalysisDataResV2, + IFullSyncAuditPlanSQLsReqV2, + IPartialSyncAuditPlanSQLsReqV2 } from '../common.d'; export interface IGetAuditPlanMetasV1Params { @@ -247,3 +249,21 @@ export interface IGetAuditPlantAnalysisDataV2Params { export interface IGetAuditPlantAnalysisDataV2Return extends IGetAuditPlanAnalysisDataResV2 {} + +export interface IFullSyncAuditPlanSQLsV2Params + extends IFullSyncAuditPlanSQLsReqV2 { + project_name: string; + + audit_plan_name: string; +} + +export interface IFullSyncAuditPlanSQLsV2Return extends IBaseRes {} + +export interface IPartialSyncAuditPlanSQLsV2Params + extends IPartialSyncAuditPlanSQLsReqV2 { + project_name: string; + + audit_plan_name: string; +} + +export interface IPartialSyncAuditPlanSQLsV2Return extends IBaseRes {} diff --git a/src/api/audit_plan/index.ts b/src/api/audit_plan/index.ts index 82d0d446..67d938ee 100644 --- a/src/api/audit_plan/index.ts +++ b/src/api/audit_plan/index.ts @@ -48,7 +48,11 @@ import { IGetAuditPlanReportsSQLsParams, IGetAuditPlanReportsSQLsReturn, IGetAuditPlantAnalysisDataV2Params, - IGetAuditPlantAnalysisDataV2Return + IGetAuditPlantAnalysisDataV2Return, + IFullSyncAuditPlanSQLsV2Params, + IFullSyncAuditPlanSQLsV2Return, + IPartialSyncAuditPlanSQLsV2Params, + IPartialSyncAuditPlanSQLsV2Return } from './index.d'; class AuditPlanService extends ServiceBase { @@ -446,6 +450,42 @@ class AuditPlanService extends ServiceBase { options ); } + + public fullSyncAuditPlanSQLsV2( + params: IFullSyncAuditPlanSQLsV2Params, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const project_name = paramsData.project_name; + delete paramsData.project_name; + + const audit_plan_name = paramsData.audit_plan_name; + delete paramsData.audit_plan_name; + + return this.post( + `/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/full`, + paramsData, + options + ); + } + + public partialSyncAuditPlanSQLsV2( + params: IPartialSyncAuditPlanSQLsV2Params, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const project_name = paramsData.project_name; + delete paramsData.project_name; + + const audit_plan_name = paramsData.audit_plan_name; + delete paramsData.audit_plan_name; + + return this.post( + `/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/partial`, + paramsData, + options + ); + } } export default new AuditPlanService(); diff --git a/src/api/common.d.ts b/src/api/common.d.ts index 8bca9027..fa7bb04c 100644 --- a/src/api/common.d.ts +++ b/src/api/common.d.ts @@ -3125,6 +3125,28 @@ export interface IAuditPlanResV2 { rule_template?: IRuleTemplateV2; } +export interface IAuditPlanSQLReqV2 { + audit_plan_sql_counter?: string; + + audit_plan_sql_fingerprint?: string; + + audit_plan_sql_last_receive_text?: string; + + audit_plan_sql_last_receive_timestamp?: string; + + audit_plan_sql_schema?: string; + + db_user?: string; + + endpoints?: string[]; + + first_query_at?: string; + + query_time_avg?: number; + + query_time_max?: number; +} + export interface IAuditResDataV2 { audit_level?: AuditResDataV2AuditLevelEnum; @@ -3255,6 +3277,10 @@ export interface IDriverMeta { logo_url?: string; } +export interface IFullSyncAuditPlanSQLsReqV2 { + audit_plan_sql_list?: IAuditPlanSQLReqV2[]; +} + export interface IGetAuditPlanAnalysisDataResV2 { code?: number; @@ -3391,6 +3417,10 @@ export interface IInstanceResV2 { sql_query_config?: ISQLQueryConfigResV1; } +export interface IPartialSyncAuditPlanSQLsReqV2 { + audit_plan_sql_list?: IAuditPlanSQLReqV2[]; +} + export interface IPerformanceStatistics { affect_rows?: IAffectRows; } diff --git a/src/page/SQLManagement/SQLPanel/column.tsx b/src/page/SQLManagement/SQLPanel/column.tsx index ec43fa23..3a4be702 100644 --- a/src/page/SQLManagement/SQLPanel/column.tsx +++ b/src/page/SQLManagement/SQLPanel/column.tsx @@ -115,6 +115,22 @@ export const SQLPanelColumns: (params: { { dataIndex: 'instance_name', title: () => t('sqlManagement.table.instanceName'), + render: (name) => { + if (!name) { + return '--'; + } + return name; + }, + }, + { + dataIndex: 'schema_name', + title: () => 'Schema', + render: (schema) => { + if (!schema) { + return '--'; + } + return schema; + }, }, { dataIndex: 'audit_result', @@ -168,23 +184,24 @@ export const SQLPanelColumns: (params: { } if (endpoints.length === 1) { return {endpoints[0]}; - } return ( - - { - endpoints.map((v) => ( - {v} - )) - } - - }> + + + {endpoints.map((v) => ( + {v} + ))} + + + } + > {endpoints[0]} {endpoints.length > 1 ? '...' : null} - - ) - } + + ); + }, }, { dataIndex: 'status', @@ -215,7 +232,10 @@ export const SQLPanelColumns: (params: { width: 200, render: (remark: string, record) => { return ( - {renderRemark(remark) ?? '--'}}> + {renderRemark(remark) ?? '--'}} + >