diff --git a/src/common/network/task.ts b/src/common/network/task.ts index e95474470..975049db3 100644 --- a/src/common/network/task.ts +++ b/src/common/network/task.ts @@ -442,6 +442,14 @@ export async function getSubTask(id: number): Promise { + const res = await request.post(`/api/v2/osc/swapTable/${taskId}`); + return !!res?.data; +} + /** * 获取数据源用户列表 */ diff --git a/src/component/Task/AlterDdlTask/CreateModal/index.tsx b/src/component/Task/AlterDdlTask/CreateModal/index.tsx index 284fcda25..ead9c1af1 100644 --- a/src/component/Task/AlterDdlTask/CreateModal/index.tsx +++ b/src/component/Task/AlterDdlTask/CreateModal/index.tsx @@ -56,6 +56,12 @@ enum SqlType { CREATE = 'CREATE', ALTER = 'ALTER', } + +export enum SwapTableType { + AUTO = 'AUTO', + MANUAL = 'MANUAL', +} + export enum ClearStrategy { ORIGIN_TABLE_RENAME_AND_RESERVED = 'ORIGIN_TABLE_RENAME_AND_RESERVED', ORIGIN_TABLE_DROP = 'ORIGIN_TABLE_DROP', @@ -105,6 +111,7 @@ const CreateDDLTaskModal: React.FC = (props) => { sqlType, sqlContent, swapTableNameRetryTimes, + swapTableType, lockTableTimeOutSeconds, originTableCleanStrategy, errorStrategy, @@ -121,6 +128,7 @@ const CreateDDLTaskModal: React.FC = (props) => { swapTableNameRetryTimes, originTableCleanStrategy, lockUsers, + swapTableType, }; const data = { projectId, @@ -507,6 +515,22 @@ const CreateDDLTaskModal: React.FC = (props) => { + + + 自动切换 + 手工切换 + + diff --git a/src/component/Task/AlterDdlTask/DetailContent/index.tsx b/src/component/Task/AlterDdlTask/DetailContent/index.tsx index 0b0669281..acd4af4bb 100644 --- a/src/component/Task/AlterDdlTask/DetailContent/index.tsx +++ b/src/component/Task/AlterDdlTask/DetailContent/index.tsx @@ -24,7 +24,7 @@ import { getFormatDateTime } from '@/util/utils'; import React from 'react'; import { Typography } from 'antd'; import { SimpleTextItem } from '../../component/SimpleTextItem'; -import { ClearStrategy } from '../CreateModal'; +import { ClearStrategy, SwapTableType } from '../CreateModal'; import { getDataSourceModeConfigByConnectionMode } from '@/common/datasource'; const { Text } = Typography; interface IDDLAlterParamters { @@ -40,6 +40,7 @@ interface IDDLAlterParamters { lockTableTimeOutSeconds: number; swapTableNameRetryTimes: number; originTableCleanStrategy: ClearStrategy; + swapTableType: SwapTableType; } const ErrorStrategyText = { ABORT: formatMessage({ @@ -61,6 +62,11 @@ const ClearStrategyMap = { }), //重命名不处理 }; +const SwapTableTypeMap = { + [SwapTableType.AUTO]: '自动切换', + [SwapTableType.MANUAL]: '手工切换', +}; + const SQLContentSection = ({ task }) => { return ( void }) => { +const getColumns = (params: { + onOpenDetail: (id: number) => void; + onSwapTable: (id: number) => void; +}) => { return [ { dataIndex: 'resultJson', @@ -52,16 +55,28 @@ const getColumns = (params: { onOpenDetail: (id: number) => void }) => { dataIndex: 'action', title: formatMessage({ id: 'odc.component.CommonDetailModal.TaskProgress.Operation' }), //操作 ellipsis: true, - width: 92, + width: 120, render: (_, record) => { + const resultJson = JSON.parse(record?.resultJson); return ( - { - params?.onOpenDetail(record?.id); - }} - > - {formatMessage({ id: 'odc.component.CommonDetailModal.TaskProgress.View' }) /*查看*/} - + <> + { + params?.onOpenDetail(record?.id); + }} + > + {formatMessage({ id: 'odc.component.CommonDetailModal.TaskProgress.View' }) /*查看*/} + + {resultJson?.manualSwapTableEnabled && ( + { + params?.onSwapTable(record?.id); + }} + > + 表名切换 + + )} + ); }, }, @@ -83,6 +98,14 @@ const TaskProgress: React.FC = (props) => { setSubTasks(res?.contents?.[0].tasks); }; + const handleSwapTable = async (id: number) => { + const res = await swapTableName(id); + if (res) { + message.success('开始表名切换'); + loadData(); + } + }; + useEffect(() => { loadData(); }, []); @@ -105,6 +128,7 @@ const TaskProgress: React.FC = (props) => { rowKey="id" columns={getColumns({ onOpenDetail: handleDetailVisible, + onSwapTable: handleSwapTable, })} dataSource={subTasks} expandable={{ diff --git a/src/page/Project/Sensitive/components/SensitiveColumn/components/FormSensitiveColumnDrawer.tsx b/src/page/Project/Sensitive/components/SensitiveColumn/components/FormSensitiveColumnDrawer.tsx index d9fee4b94..897f199f1 100644 --- a/src/page/Project/Sensitive/components/SensitiveColumn/components/FormSensitiveColumnDrawer.tsx +++ b/src/page/Project/Sensitive/components/SensitiveColumn/components/FormSensitiveColumnDrawer.tsx @@ -30,10 +30,10 @@ import { Button, Drawer, message, Space } from 'antd'; import { useForm } from 'antd/es/form/Form'; import { useContext, useEffect, useRef, useState } from 'react'; import styles from './index.less'; -import ManualForm from './ManualForm'; import ScanForm from './ScanForm'; import tracert from '@/util/tracert'; import SensitiveRule from '../../SensitiveRule'; +import { merge } from 'lodash'; const defaultScanTableData: Array = []; const checkResult = (resData: Array = []) => resData?.length > 0 ? resData : defaultScanTableData; @@ -116,7 +116,7 @@ const FormSensitiveColumnDrawer = ({ setSearchText(''); clearTimeout(timer.current); }; - const handleScanTableDataChange = ( + const handleScanTableDataChange = async ( key: string, columnName: string, maskingAlgorithmId: number, @@ -141,8 +141,6 @@ const FormSensitiveColumnDrawer = ({ }); } }); - setScanTableData(checkResult(resData)); - setOriginScanTableData(checkResult(resData)); } else { const newDataSource = sensitiveColumnMap.get(key).dataSource.map((item) => { if (item.columnName === columnName) { @@ -154,10 +152,20 @@ const FormSensitiveColumnDrawer = ({ sensitiveColumnMap?.forEach((ds) => { resData.push(ds); }); - setScanTableData(checkResult(resData)); - setOriginScanTableData(checkResult(resData)); } + setScanTableData(checkResult(resData)); + setOriginScanTableData(checkResult(resData)); setSensitiveColumnMap(sensitiveColumnMap); + const fieldsValue = await _formRef.getFieldsValue(); + await _formRef.setFieldsValue( + merge(fieldsValue, { + scanTableData: { + [`${key}`]: { + [`${columnName}`]: maskingAlgorithmId, + }, + }, + }), + ); }; const handleScanTableDataDelete = (database: string, tableName: string, columnName: string) => { const key = `${database}_${tableName}`; diff --git a/src/page/Project/Sensitive/components/SensitiveColumn/components/SacnRule.tsx b/src/page/Project/Sensitive/components/SensitiveColumn/components/SacnRule.tsx index dc50adc69..71d513edc 100644 --- a/src/page/Project/Sensitive/components/SensitiveColumn/components/SacnRule.tsx +++ b/src/page/Project/Sensitive/components/SensitiveColumn/components/SacnRule.tsx @@ -23,9 +23,6 @@ import { formatMessage } from '@/util/intl'; import { Button, Divider, Form, Select } from 'antd'; import { useContext, useEffect, useState } from 'react'; import SensitiveContext from '../../../SensitiveContext'; -import HelpDoc from '@/component/helpDoc'; -import { ProjectRole } from '@/d.ts/project'; -import { projectRoleTextMap } from '@/page/Project/User'; const ScanRule = ({ formRef, reset, setManageSensitiveRuleDrawerOpen }) => { const context = useContext(ProjectContext); const sensitiveContext = useContext(SensitiveContext); diff --git a/src/page/Project/Sensitive/components/SensitiveColumn/components/ScanForm.tsx b/src/page/Project/Sensitive/components/SensitiveColumn/components/ScanForm.tsx index 50ab19a0d..feff4cbbb 100644 --- a/src/page/Project/Sensitive/components/SensitiveColumn/components/ScanForm.tsx +++ b/src/page/Project/Sensitive/components/SensitiveColumn/components/ScanForm.tsx @@ -23,7 +23,6 @@ import { Empty, Form, Input, - Popover, Progress, Select, Space, @@ -39,6 +38,7 @@ import TableOutlined from '@/svgr/menuTable.svg'; import ViewSvg from '@/svgr/menuView.svg'; import { MaskRyleTypeMap } from '@/d.ts'; import { PopoverContainer } from '..'; +import { useCallback } from 'react'; const ScanForm = ({ formRef, _formRef, @@ -100,6 +100,283 @@ const ScanForm = ({ ); }; + const WrapCollapse = useCallback( + () => ( + index) + } + className={ + scanTableData?.length === 0 + ? classnames(styles.collapse) + : classnames(styles.collapse, styles.collapses) + } + > + {scanTableData?.length === 0 ? ( + + + {''} + + + {''} + + + } + > + + + ) : ( + <> + {scanTableData?.map(({ header: { database, tableName, type }, dataSource }, index) => { + return ( + + + {database} + + +
+
+ + + + + {tableName} + +
+ + { + e.preventDefault(); + e.stopPropagation(); + handleScanTableDataDeleteByTableName(database, tableName); + }} + /> + +
+
+ + } + key={index} + > + sensitiveContext?.sensitiveRuleIdMap?.[text], + }, + { + title: formatMessage({ + id: 'odc.SensitiveColumn.components.ScanForm.DesensitizationAlgorithm', + }), + //脱敏算法 + width: 180, + dataIndex: 'maskingAlgorithmId', + key: 'maskingAlgorithmId', + render: (text, record, _index) => { + return ( + + + + ); + }, + }, + { + title: formatMessage({ + id: 'odc.SensitiveColumn.components.ScanForm.Operation', + }), + //操作 + width: 88, + key: 'action', + render: (_, record) => ( + + + handleScanTableDataDelete( + database, + tableName, + (record as ScanTableDataItem)?.columnName, + ) + } + > + { + formatMessage({ + id: 'odc.SensitiveColumn.components.ScanForm.Delete', + }) /*删除*/ + } + + + ), + }, + ]} + dataSource={dataSource} + pagination={{ + showSizeChanger: false, + }} + /> + + ); + })} + + )} + + ), + [scanTableData], + ); return ( <> @@ -197,278 +474,7 @@ const ScanForm = ({ }} > - - {scanTableData?.length === 0 ? ( - - - {''} - - - {''} - - - } - > - - - ) : ( - <> - {scanTableData?.map( - ({ header: { database, tableName, type }, dataSource }, index) => { - return ( - - - {database} - - -
-
- - - - - {tableName} - -
- - { - e.preventDefault(); - e.stopPropagation(); - handleScanTableDataDeleteByTableName(database, tableName); - }} - /> - -
-
- - } - key={index} - > -
sensitiveContext?.sensitiveRuleIdMap?.[text], - }, - { - title: formatMessage({ - id: - 'odc.SensitiveColumn.components.ScanForm.DesensitizationAlgorithm', - }), - //脱敏算法 - width: 180, - dataIndex: 'maskingAlgorithmId', - key: 'maskingAlgorithmId', - render: (text, record, _index) => { - return ( - - ); - }, - }, - { - title: formatMessage({ - id: 'odc.SensitiveColumn.components.ScanForm.Operation', - }), - //操作 - width: 88, - key: 'action', - render: (_, record) => ( - - - handleScanTableDataDelete( - database, - tableName, - (record as ScanTableDataItem)?.columnName, - ) - } - > - { - formatMessage({ - id: 'odc.SensitiveColumn.components.ScanForm.Delete', - }) /*删除*/ - } - - - ), - }, - ]} - dataSource={dataSource} - pagination={{ - showSizeChanger: false, - }} - /> - - ); - }, - )} - - )} - + diff --git a/src/page/Secure/Record/RecordPage/interface.ts b/src/page/Secure/Record/RecordPage/interface.ts index 220d8ff26..56b8e23c1 100644 --- a/src/page/Secure/Record/RecordPage/interface.ts +++ b/src/page/Secure/Record/RecordPage/interface.ts @@ -547,7 +547,7 @@ export const AuditEventActionMap = { [AuditEventActionType.REJECT_APPLY_PROJECT_PERMISSION_TASK]: '拒绝申请项目权限', [AuditEventActionType.STOP_APPLY_PROJECT_PERMISSION_TASK]: '停止申请项目权限', // SQL安全规则管理 - [AuditEventActionType.UPDATE_SQL_SECURITY_RULE]: '更新SQL安全规则', + [AuditEventActionType.UPDATE_SQL_SECURITY_RULE]: '修改SQL安全规则', }; export function getEventFilterAndOptions(eventMeta: IAuditEvent[]) { const metas = diff --git a/src/page/Secure/components/RecordPage/interface.ts b/src/page/Secure/components/RecordPage/interface.ts index cb1d6a609..2a62ab7a1 100644 --- a/src/page/Secure/components/RecordPage/interface.ts +++ b/src/page/Secure/components/RecordPage/interface.ts @@ -539,7 +539,7 @@ export const AuditEventActionMap = { id: 'odc.src.page.Secure.components.RecordPage.StopExportResultsSetTask', }), //'停止导出结果集任务' // SQL安全规则管理 - [AuditEventActionType.UPDATE_SQL_SECURITY_RULE]: '更新SQL安全规则', + [AuditEventActionType.UPDATE_SQL_SECURITY_RULE]: '修改SQL安全规则', }; export function getEventFilterAndOptions(eventMeta: IAuditEvent[]) { const metas =