diff --git a/src/api/common.d.ts b/src/api/common.d.ts index b274a93d..7fee20d3 100644 --- a/src/api/common.d.ts +++ b/src/api/common.d.ts @@ -2247,7 +2247,7 @@ export interface ISQLQueryConfigResV1 { export interface ISource { audit_plan_name?: string; - sql_audit_record_id?: string; + sql_audit_record_ids?: string[]; type?: SourceTypeEnum; } diff --git a/src/api/rule_template/index.d.ts b/src/api/rule_template/index.d.ts index 54076dcc..12f81ac3 100644 --- a/src/api/rule_template/index.d.ts +++ b/src/api/rule_template/index.d.ts @@ -127,6 +127,24 @@ export interface IExportProjectRuleTemplateV1Params { rule_template_name: string; } +export interface IGetCustomRuleKnowledgeV1Params { + rule_name: string; + + db_type: string; +} + +export interface IGetCustomRuleKnowledgeV1Return + extends IGetRuleKnowledgeResV1 {} + +export interface IUpdateCustomRuleKnowledgeParams + extends IUpdateRuleKnowledgeReq { + rule_name: string; + + db_type: string; +} + +export interface IUpdateCustomRuleKnowledgeReturn extends IBaseRes {} + export interface IGetRuleKnowledgeV1Params { rule_name: string; diff --git a/src/api/rule_template/index.ts b/src/api/rule_template/index.ts index adb7585e..2100b98a 100644 --- a/src/api/rule_template/index.ts +++ b/src/api/rule_template/index.ts @@ -34,6 +34,10 @@ import { ICloneProjectRuleTemplateV1Params, ICloneProjectRuleTemplateV1Return, IExportProjectRuleTemplateV1Params, + IGetCustomRuleKnowledgeV1Params, + IGetCustomRuleKnowledgeV1Return, + IUpdateCustomRuleKnowledgeParams, + IUpdateCustomRuleKnowledgeReturn, IGetRuleKnowledgeV1Params, IGetRuleKnowledgeV1Return, IUpdateRuleKnowledgeParams, @@ -279,6 +283,42 @@ class RuleTemplateService extends ServiceBase { ); } + public getCustomRuleKnowledgeV1( + params: IGetCustomRuleKnowledgeV1Params, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const db_type = paramsData.db_type; + delete paramsData.db_type; + + const rule_name = paramsData.rule_name; + delete paramsData.rule_name; + + return this.get( + `/v1/rule_knowledge/db_types/${db_type}/custom_rules/${rule_name}/`, + paramsData, + options + ); + } + + public updateCustomRuleKnowledge( + params: IUpdateCustomRuleKnowledgeParams, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const db_type = paramsData.db_type; + delete paramsData.db_type; + + const rule_name = paramsData.rule_name; + delete paramsData.rule_name; + + return this.patch( + `/v1/rule_knowledge/db_types/${db_type}/custom_rules/${rule_name}/`, + paramsData, + options + ); + } + public getRuleKnowledgeV1( params: IGetRuleKnowledgeV1Params, options?: AxiosRequestConfig diff --git a/src/api/sql_audit_record/index.d.ts b/src/api/sql_audit_record/index.d.ts index 0fe3e698..1e8641ef 100644 --- a/src/api/sql_audit_record/index.d.ts +++ b/src/api/sql_audit_record/index.d.ts @@ -20,6 +20,8 @@ export interface IGetSQLAuditRecordsV1Params { filter_create_time_to?: string; + filter_sql_audit_record_ids?: string; + page_index: number; page_size: number; diff --git a/src/page/SQLManagement/SQLPanel/column.tsx b/src/page/SQLManagement/SQLPanel/column.tsx index 3ed31e26..8edf51ae 100644 --- a/src/page/SQLManagement/SQLPanel/column.tsx +++ b/src/page/SQLManagement/SQLPanel/column.tsx @@ -17,6 +17,10 @@ import EditText from '../../../components/EditText/EditText'; import AssignMember from './AssignMember'; import EmptyBox from '../../../components/EmptyBox'; import UpdateSQLStatus from './UpdateSQLStatus'; +import { + SQLAuditRecordIDValuesSplit, + SQLAuditRecordListUrlParamsKey, +} from '../../SqlAuditRecord/List/index.data'; export const SQLPanelColumns: (params: { projectName: string; @@ -80,7 +84,13 @@ export const SQLPanelColumns: (params: { ) { return ( {t(sourceDictionary[source.type])} diff --git a/src/page/SqlAuditRecord/List/index.data.ts b/src/page/SqlAuditRecord/List/index.data.ts new file mode 100644 index 00000000..5b1f8e41 --- /dev/null +++ b/src/page/SqlAuditRecord/List/index.data.ts @@ -0,0 +1,5 @@ +export const SQLAuditRecordListUrlParamsKey = { + SQLAuditRecordID: 'SQLAuditRecordID', +}; + +export const SQLAuditRecordIDValuesSplit = ','; diff --git a/src/page/SqlAuditRecord/List/index.tsx b/src/page/SqlAuditRecord/List/index.tsx index 04845862..70eedaa1 100644 --- a/src/page/SqlAuditRecord/List/index.tsx +++ b/src/page/SqlAuditRecord/List/index.tsx @@ -12,15 +12,19 @@ import { useTheme } from '@mui/styles'; import { SQLAuditListColumn } from './column'; import sql_audit_record from '../../../api/sql_audit_record'; import { translateTimeForRequest } from '../../../utils/Common'; -import { useCallback } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { ResponseCode } from '../../../data/common'; import './index.less'; +import { useLocation } from 'react-router-dom'; +import { SQLAuditRecordListUrlParamsKey } from './index.data'; const SQLAuditList: React.FC = () => { const { t } = useTranslation(); const { projectName } = useCurrentProjectName(); const theme = useTheme(); + const location = useLocation(); + const [resolveUrlParamFlag, setResolveUrlParamFlag] = useState(false); const { pagination, @@ -29,6 +33,7 @@ const SQLAuditList: React.FC = () => { resetFilter, submitFilter, tableChange, + setFilterInfo, } = useTable(); const { data, refresh, loading } = useRequest( @@ -47,6 +52,7 @@ const SQLAuditList: React.FC = () => { filter_create_time_to: translateTimeForRequest( filterInfo.filter_create_time?.[1] ), + filter_sql_audit_record_ids: filterInfo.filter_sql_audit_record_ids, }) .then((res) => { return { @@ -55,6 +61,7 @@ const SQLAuditList: React.FC = () => { }; }), { + ready: resolveUrlParamFlag, refreshDeps: [pagination, filterInfo, projectName], } ); @@ -76,6 +83,21 @@ const SQLAuditList: React.FC = () => { }, [projectName, refresh, t] ); + + useEffect(() => { + const searchStr = new URLSearchParams(location.search); + const filter: SQLAuditListFilterFormFields = {}; + if (searchStr.has(SQLAuditRecordListUrlParamsKey.SQLAuditRecordID)) { + filter.filter_sql_audit_record_ids = searchStr.get( + SQLAuditRecordListUrlParamsKey.SQLAuditRecordID + ) as string; + } + if (Object.keys(filter).length > 0) { + setFilterInfo(filter); + } + setResolveUrlParamFlag(true); + }, [filterForm, location.search, setFilterInfo]); + return ( <> & { + filter_create_time?: moment.Moment[]; }; export type SQLAuditListFilterFormProps = {