Unverified Commit 39d3a16e authored by gaoyan's avatar gaoyan Committed by GitHub

refactor doc database (#2834)

* refactor doc * refactor doc * formate code * formate code
parent cdec3e07
......@@ -55,7 +55,7 @@ public class FlinkServiceImpl implements FlinkService {
dataList.add(cascaderVO);
}
List<CascaderVO> voList = documentService.lambdaQuery().eq(Document::getCategory, "Variable").list().stream()
List<CascaderVO> voList = documentService.lambdaQuery().eq(Document::getType, "FLINK_OPTIONS").list().stream()
.map(d -> new CascaderVO(d.getName().replace("set ", "")))
.collect(Collectors.toList());
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -800,7 +800,7 @@ export default {
'rc.ci.version': 'Version',
'rc.ci.desc': 'Note',
'rc.ci.search': 'Search Name/Alias/Note',
'rc.doc.category': 'Document Type',
'rc.doc.category': 'Register Type',
'rc.doc.categoryPlaceholder': 'Please select the type of this Document!',
'rc.doc.create': 'Create Document',
'rc.doc.delete': 'Delete Document',
......@@ -811,7 +811,7 @@ export default {
'rc.doc.fillValueHelp': 'Please enter the fill value',
'rc.doc.fillValuePlaceholder':
'Please enter the fill value, use the name in the editor to trigger the prompt eg',
'rc.doc.functionType': 'Function Type',
'rc.doc.functionType': 'Document Type',
'rc.doc.management': 'Document Management',
'rc.doc.modify': 'Modify Document',
'rc.doc.name': 'Name',
......
......@@ -768,7 +768,7 @@ export default {
'rc.ci.version': '版本',
'rc.ci.desc': '描述',
'rc.ci.search': '搜索 名称/别名/备注',
'rc.doc.category': '文档类型',
'rc.doc.category': '注册类型',
'rc.doc.categoryPlaceholder': '请选择该文档所属类型!',
'rc.doc.create': '创建文档',
'rc.doc.delete': '删除文档',
......@@ -778,7 +778,7 @@ export default {
'rc.doc.fillValue': '填充值',
'rc.doc.fillValueHelp': '请输入填充值',
'rc.doc.fillValuePlaceholder': '请输入填充值,编辑器内使用名称触发提示 eg',
'rc.doc.functionType': '函数类型',
'rc.doc.functionType': '文档类型',
'rc.doc.management': '文档管理',
'rc.doc.modify': '修改文档',
'rc.doc.name': '名称',
......
......@@ -19,26 +19,25 @@
import CodeEdit from '@/components/CustomEditor/CodeEdit';
import {
DOCUMENT_CATEGORY,
DOCUMENT_FUNCTION_TYPE,
DOCUMENT_SUBTYPE,
VERSIONS
DOCUMENT_TYPE_ENUMS, VERSIONS, DOCUMENT_FUNCTION_TYPE_ENUMS, DOCUMENT_CATEGORY_ENUMS
} from '@/pages/RegCenter/Document/constans';
import { FORM_LAYOUT_PUBLIC } from '@/services/constants';
import { Document } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import {FORM_LAYOUT_PUBLIC} from '@/services/constants';
import {Document} from '@/types/RegCenter/data';
import {l} from '@/utils/intl';
import {
ProForm,
ProFormItem,
ProFormItem, ProFormSegmented,
ProFormSelect,
ProFormSwitch,
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
import { DefaultOptionType } from 'rc-select/lib/Select';
import React, { useState } from 'react';
import {FormInstance} from 'antd/es/form/hooks/useForm';
import {Values} from 'async-validator';
import {DefaultOptionType} from 'rc-select/lib/Select';
import React, {useState} from 'react';
import {ProFormDependency} from "@ant-design/pro-form";
import {JOB_TYPE} from "@/pages/DataStudio/LeftContainer/Project/constants";
type DocumentFormProps = {
values: Partial<Document>;
......@@ -51,39 +50,39 @@ const CodeEditProps = {
};
const DocumentForm: React.FC<DocumentFormProps> = (props) => {
const { values, form } = props;
const {values, form} = props;
/**
* status
*/
const [codeFillValue, setCodeFillValue] = useState<string>(values.fillValue || '');
const [categoryList] = useState<DefaultOptionType[]>(
DOCUMENT_CATEGORY.map((item) => ({ label: item.text, value: item.value }))
);
const [typeList] = useState<DefaultOptionType[]>(
DOCUMENT_FUNCTION_TYPE.map((item) => ({
label: item.text,
value: item.value
}))
const {
FLINK_OPTIONS,
SQL_TEMPLATE,
FUN_UDF,
OTHER
} = DOCUMENT_TYPE_ENUMS;
const [CATEGORY_LIST] = useState<DefaultOptionType[]>(
Object.values(DOCUMENT_CATEGORY_ENUMS).map((item) => ({label: item.text, value: item.value}))
);
const [subTypeList] = useState<DefaultOptionType[]>(
DOCUMENT_SUBTYPE.map((item) => ({ label: item.text, value: item.value }))
const [FUNCTION_TYPES] = useState<DefaultOptionType[]>(
Object.values(DOCUMENT_FUNCTION_TYPE_ENUMS).map((item) => ({label: item.text, value: item.value}))
);
const [versionOptions] = useState<DefaultOptionType[]>(
VERSIONS.map((item) => ({ label: item.text, value: item.value }))
const [VERSION_OPTIONS] = useState<DefaultOptionType[]>(
VERSIONS.map((item) => ({label: item.text, value: item.value}))
);
/**
* code editor change callback
* @param value
*/
const handleFillValueChange = (value: string) => {
setCodeFillValue(value);
};
const onTypeAndNameChange = (type: string, name: string) => {
if (type == FLINK_OPTIONS.value) {
const fillValue = "set '" + name + "' = '${1:}'";
form.setFieldsValue({category: "Varible"});
form.setFieldsValue({fillValue: fillValue});
setCodeFillValue(fillValue);
}
}
/**
* form
......@@ -92,48 +91,52 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
const documentFormRender = () => {
return (
<>
<ProFormText
name='name'
label={l('rc.doc.name')}
placeholder={l('rc.doc.namePlaceholder')}
rules={[{ required: true, message: l('rc.doc.namePlaceholder') }]}
/>
<ProFormSelect
name='category'
label={l('rc.doc.category')}
rules={[{ required: true, message: l('rc.doc.categoryPlaceholder') }]}
options={categoryList}
/>
<ProFormSelect
<ProFormSegmented
name='type'
label={l('rc.doc.functionType')}
rules={[{ required: true, message: l('rc.doc.typePlaceholder') }]}
options={typeList}
rules={[{required: true, message: l('rc.doc.typePlaceholder')}]}
valueEnum={DOCUMENT_TYPE_ENUMS}
/>
<ProFormSelect
name='subtype'
label={l('rc.doc.subFunctionType')}
rules={[{ required: true, message: l('rc.doc.subTypePlaceholder') }]}
options={subTypeList}
<ProFormText
name='name'
label={l('rc.doc.name')}
placeholder={l('rc.doc.namePlaceholder')}
rules={[{required: true, message: l('rc.doc.namePlaceholder')}]}
/>
<ProFormTextArea
name='description'
label={l('rc.doc.description')}
placeholder={l('rc.doc.descriptionPlaceholder')}
/>
<ProFormDependency name={['type', 'name']}>
{
({type, name}) => {
onTypeAndNameChange(type, name);
return <>
{type != FLINK_OPTIONS.value && type != OTHER.value &&
<ProFormSelect
name='subtype'
label={l('rc.doc.subFunctionType')}
rules={[{required: true, message: l('rc.doc.subTypePlaceholder')}]}
options={type == FUN_UDF.value ? FUNCTION_TYPES : JOB_TYPE}
/>}
<ProFormSelect
disabled={type == FLINK_OPTIONS.value}
name='category'
label={l('rc.doc.category')}
rules={[{required: true, message: l('rc.doc.categoryPlaceholder')}]}
options={CATEGORY_LIST}
/>
</>
}
}
</ProFormDependency>
<ProFormItem
name='fillValue'
label={l('rc.doc.fillValue')}
tooltip={l('rc.doc.fillValuePlaceholder')}
rules={[{ required: true, message: l('rc.doc.fillValueHelp') }]}
rules={[{required: true, message: l('rc.doc.fillValueHelp')}]}
>
<CodeEdit
onChange={handleFillValueChange}
code={codeFillValue}
language={'sql'}
enableSuggestions={false}
......@@ -141,11 +144,17 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
/>
</ProFormItem>
<ProFormTextArea
name='description'
label={l('rc.doc.description')}
placeholder={l('rc.doc.descriptionPlaceholder')}
/>
<ProFormSelect
name='version'
label={l('rc.doc.version')}
rules={[{ required: true, message: l('rc.doc.versionPlaceholder') }]}
options={versionOptions}
rules={[{required: true, message: l('rc.doc.versionPlaceholder')}]}
options={VERSION_OPTIONS}
/>
<ProFormSwitch
......
......@@ -26,12 +26,9 @@ import { Authorized, HasAuthority } from '@/hooks/useAccess';
import DocumentDrawer from '@/pages/RegCenter/Document/components/DocumentDrawer';
import DocumentModalForm from '@/pages/RegCenter/Document/components/DocumentModal';
import {
DOCUMENT_CATEGORY,
DOCUMENT_CATEGORY_ENUMS,
DOCUMENT_FUNCTION_ENUMS,
DOCUMENT_FUNCTION_TYPE,
DOCUMENT_SUBTYPE,
DOCUMENT_SUBTYPE_ENUMS
DOCUMENT_TYPE_ENUMS,
DOCUMENT_FUNCTION_TYPE_ENUMS
} from '@/pages/RegCenter/Document/constans';
import { queryList } from '@/services/api';
import { handleAddOrUpdate, handleRemoveById, updateDataByParam } from '@/services/BusinessCrud';
......@@ -111,29 +108,29 @@ const DocumentTableList: React.FC = () => {
return <a onClick={() => handleOpenDrawer(record)}>{dom}</a>;
}
},
{
title: l('rc.doc.category'),
sorter: true,
dataIndex: 'category',
filterMultiple: false,
filters: DOCUMENT_CATEGORY,
valueEnum: DOCUMENT_CATEGORY_ENUMS
},
{
title: l('rc.doc.functionType'),
sorter: true,
dataIndex: 'type',
filterMultiple: false,
filters: DOCUMENT_FUNCTION_TYPE,
valueEnum: DOCUMENT_FUNCTION_ENUMS
filterMultiple: true,
filters:true,
valueEnum: DOCUMENT_TYPE_ENUMS
},
{
title: l('rc.doc.subFunctionType'),
sorter: true,
dataIndex: 'subtype',
filters: DOCUMENT_SUBTYPE,
filterMultiple: false,
valueEnum: DOCUMENT_SUBTYPE_ENUMS
filters: true,
filterMultiple: true,
valueEnum: DOCUMENT_FUNCTION_TYPE_ENUMS
},
{
title: l('rc.doc.category'),
sorter: true,
dataIndex: 'category',
filterMultiple: true,
filters: true,
valueEnum: DOCUMENT_CATEGORY_ENUMS
},
{
title: l('rc.doc.description'),
......
......@@ -17,202 +17,46 @@
*
*/
export const DOCUMENT_CATEGORY = [
{
text: 'Variable',
value: 'Variable'
},
{
text: 'Module',
value: 'Module'
},
{
text: 'Operator',
value: 'Operator'
},
{
text: 'Function',
value: 'Function'
},
{
text: 'Property',
value: 'Property'
},
{
text: 'Method',
value: 'Method'
},
{
text: 'Reference',
value: 'Reference'
}
];
/**
* document category enum map
*/
export const DOCUMENT_CATEGORY_ENUMS = {
Variable: { text: 'Variable' },
Module: { text: 'Module' },
Operator: { text: 'Operator' },
Function: { text: 'Function' },
Property: { text: 'Property' },
Method: { text: 'Method' },
Reference: { text: 'Reference' }
Variable: {text: 'Variable', value: 'Variable'},
Module: {text: 'Module', value: 'Module'},
Operator: {text: 'Operator', value: 'Operator'},
Function: {text: 'Function', value: 'Function'},
Property: {text: 'Property', value: 'Property'},
Method: {text: 'Method', value: 'Method'},
Reference: {text: 'Reference', value: 'Reference'}
};
/**
* document type
*/
export const DOCUMENT_FUNCTION_TYPE = [
{
text: '优化参数',
value: '优化参数'
},
{
text: '建表语句',
value: '建表语句'
},
{
text: 'CataLog',
value: 'CataLog'
},
{
text: '设置参数',
value: '设置参数'
},
{
text: '内置函数',
value: '内置函数'
},
{
text: 'UDF',
value: 'UDF'
},
{
text: 'Other',
value: 'Other'
}
];
/**
* document function type enum map
*/
export const DOCUMENT_FUNCTION_ENUMS = {
优化参数: { text: '优化参数' },
建表语句: { text: '建表语句' },
CataLog: { text: 'CataLog' },
设置参数: { text: '设置参数' },
内置函数: { text: '内置函数' },
UDF: { text: 'UDF' },
Other: { text: 'Other' }
export const DOCUMENT_TYPE_ENUMS = {
SQL_TEMPLATE: {text: '代码片段/模板', value: 'SQL_TEMPLATE'},
FLINK_OPTIONS: {text: 'Flink参数', value: 'FLINK_OPTIONS'},
FUN_UDF: {text: '函数/UDF', value: 'FUN_UDF'},
OTHER: {text: '其他', value: 'OTHER'},
};
export const DOCUMENT_SUBTYPE = [
{
text: 'Batch/Streaming',
value: 'Batch/Streaming'
},
{
text: 'Batch',
value: 'Batch'
},
{
text: 'Streaming',
value: 'Streaming'
},
{
text: 'Other',
value: 'Other'
},
{
text: '比较函数',
value: '比较函数'
},
{
text: '逻辑函数',
value: '逻辑函数'
},
{
text: '算术函数',
value: '算术函数'
},
{
text: '字符串函数',
value: '字符串函数'
},
{
text: '时间函数',
value: '时间函数'
},
{
text: '类型转换函数功能',
value: '类型转换函数功能'
},
{
text: '条件函数',
value: '条件函数'
},
{
text: 'Collection 函数',
value: 'Collection 函数'
},
{
text: 'Value Construction函数',
value: 'Value Construction函数'
},
{
text: 'Value Access函数',
value: 'Value Access函数'
},
{
text: '分组函数',
value: '分组函数'
},
{
text: 'hash函数',
value: 'hash函数'
},
{
text: '聚合函数',
value: '聚合函数'
},
{
text: '列函数',
value: '列函数'
},
{
text: '表值聚合函数',
value: '表值聚合函数'
},
{
text: '其他函数',
value: '其他函数'
}
];
export const DOCUMENT_SUBTYPE_ENUMS = {
'Batch/Streaming': { text: 'Batch/Streaming' },
Batch: { text: 'Batch' },
Streaming: { text: 'Streaming' },
Other: { text: 'Other' },
比较函数: { text: '比较函数' },
逻辑函数: { text: '逻辑函数' },
算术函数: { text: '算术函数' },
字符串函数: { text: '字符串函数' },
时间函数: { text: '时间函数' },
条件函数: { text: '条件函数' },
类型转换函数功能: { text: '类型转换函数功能' },
'Collection 函数': { text: 'Collection 函数' },
'Value Construction函数': { text: 'Value Construction函数' },
'Value Access函数': { text: 'Value Access函数' },
分组函数: { text: '分组函数' },
hash函数: { text: 'hash函数' },
聚合函数: { text: '聚合函数' },
列函数: { text: '列函数' },
表值聚合函数: { text: '表值聚合函数' },
其他函数: { text: '其他函数' }
export const DOCUMENT_FUNCTION_TYPE_ENUMS = {
COMPARE_FUNCTION: {text: '比较函数', value: 'COMPARE_FUNCTION'},
LOGICAL_FUNCTION: {text: '逻辑函数', value: 'LOGICAL_FUNCTION'},
ARITHMETIC_FUNCTIONS: {text: '算术函数', value: 'ARITHMETIC_FUNCTIONS'},
STRING_FUNCTIONS: {text: '字符串函数', value: 'STRING_FUNCTIONS'},
TIME_FUNCTION: {text: '时间函数', value: 'TIME_FUNCTION'},
CONDITIONAL_FUNCTION: {text: '条件函数', value: 'CONDITIONAL_FUNCTION'},
TYPE_CONVER_FUNCTION: {text: '类型转换函数功能', value: 'TYPE_CONVER_FUNCTION'},
COLLECTION_FUNCTION: {text: 'Collection 函数', value: 'COLLECTION_FUNCTION'},
VALUE_CONSTRUCTION_FUNCTION: {text: 'Value Construction函数', value: 'VALUE_CONSTRUCTION_FUNCTION Construction函数'},
VALUE_ACCESS_FUNCTION: {text: 'Value Access函数', value: 'VALUE_ACCESS_FUNCTION'},
GROUP_FUNCTION: {text: '分组函数', value: 'GROUP_FUNCTION'},
HASH_FUNCTION: {text: 'hash函数', value: 'HASH_FUNCTION'},
AGGREGATE_FUNCTION: {text: '聚合函数', value: 'AGGREGATE_FUNCTION'},
COLUMN_FUNCTION: {text: '列函数', value: 'COLUMN_FUNCTION'},
TABLE_AGGREGATE_FUNCTION: {text: '表值聚合函数', value: 'TABLE_AGGREGATE_FUNCTION'},
OTHER_FUNCTION: {text: '其他函数', value: 'OTHER_FUNCTION'},
};
/**
* versions select options
*/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -821,6 +821,33 @@ update dinky_task set save_point_strategy = 0 where save_point_strategy is not n
UPDATE dinky_flink_document t SET t.type = 'FLINK_OPTIONS',t.subtype = '' WHERE t.type = '优化参数';
UPDATE dinky_flink_document t SET t.type = 'SQL_TEMPLATE',t.subtype = 'FlinkSql' WHERE t.type = '建表语句';
UPDATE dinky_flink_document t SET t.type = 'SQL_TEMPLATE',t.subtype = 'FlinkSql' WHERE t.type = 'CataLog';
UPDATE dinky_flink_document t SET t.type = 'FLINK_OPTIONS',t.subtype = '' WHERE t.type = '设置参数';
UPDATE dinky_flink_document t SET t.type = 'FUN_UDF' WHERE t.type = '内置函数';
UPDATE dinky_flink_document t SET t.type = 'FUN_UDF' WHERE t.type = 'UDF';
UPDATE dinky_flink_document t SET t.subtype = 'COMPARE_FUNCTION' WHERE t.subtype = '比较函数';
UPDATE dinky_flink_document t SET t.subtype = 'LOGICAL_FUNCTION' WHERE t.subtype = '逻辑函数';
UPDATE dinky_flink_document t SET t.subtype = 'ARITHMETIC_FUNCTIONS' WHERE t.subtype = '算术函数';
UPDATE dinky_flink_document t SET t.subtype = 'STRING_FUNCTIONS' WHERE t.subtype = '字符串函数';
UPDATE dinky_flink_document t SET t.subtype = 'TIME_FUNCTION' WHERE t.subtype = '时间函数';
UPDATE dinky_flink_document t SET t.subtype = 'CONDITIONAL_FUNCTION' WHERE t.subtype = '条件函数';
UPDATE dinky_flink_document t SET t.subtype = 'TYPE_CONVER_FUNCTION' WHERE t.subtype = '类型转换函数功能';
UPDATE dinky_flink_document t SET t.subtype = 'COLLECTION_FUNCTION' WHERE t.subtype = 'Collection 函数';
UPDATE dinky_flink_document t SET t.subtype = 'VALUE_CONSTRUCTION_FUNCTION' WHERE t.subtype = 'Value Construction函数';
UPDATE dinky_flink_document t SET t.subtype = 'VALUE_ACCESS_FUNCTION' WHERE t.subtype = 'Value Access函数';
UPDATE dinky_flink_document t SET t.subtype = 'GROUP_FUNCTION' WHERE t.subtype = '分组函数';
UPDATE dinky_flink_document t SET t.subtype = 'HASH_FUNCTION' WHERE t.subtype = 'hash函数';
UPDATE dinky_flink_document t SET t.subtype = 'AGGREGATE_FUNCTION' WHERE t.subtype = '聚合函数';
UPDATE dinky_flink_document t SET t.subtype = 'COLUMN_FUNCTION' WHERE t.subtype = '列函数';
UPDATE dinky_flink_document t SET t.subtype = 'TABLE_AGGREGATE_FUNCTION' WHERE t.subtype = '表值聚合函数';
UPDATE dinky_flink_document t SET t.subtype = 'OTHER_FUNCTION' WHERE t.subtype = '其他函数';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment