peng.peng 2 years ago
parent
commit
fc5f4dee3d
  1. 1
      api/.vscode/launch.json
  2. 78
      api/app/lib/controllers/latestMetadata/index.js
  3. 3
      api/app/lib/routes/latestMetadata/index.js
  4. 6
      web/client/src/sections/dataQuality/containers/ruleLibrary.js
  5. 36
      web/client/src/sections/metadataManagement/actions/businessMetadata.js
  6. 237
      web/client/src/sections/metadataManagement/components/releaseModal.js
  7. 33
      web/client/src/sections/metadataManagement/containers/databasesTable.js
  8. 1
      web/client/src/utils/webapi.js

1
api/.vscode/launch.json

@ -16,6 +16,7 @@
"-p 4400", "-p 4400",
// //
"-g postgres://FashionAdmin:123456@10.8.30.39:5432/GovernmentDataResourceCenter", "-g postgres://FashionAdmin:123456@10.8.30.39:5432/GovernmentDataResourceCenter",
// "-g postgres://FashionAdmin:123456@10.8.30.156:5432/gdrcenter",
"-b http://10.8.30.161:31420" "-b http://10.8.30.161:31420"
] ]
}, },

78
api/app/lib/controllers/latestMetadata/index.js

@ -3,7 +3,7 @@
const moment = require("moment/moment"); const moment = require("moment/moment");
//获取资源目录 //获取资源目录
async function getResourceCatalog(ctx) { async function getResourceCatalog (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const rslt = await models.ResourceCatalog.findAll({ const rslt = await models.ResourceCatalog.findAll({
@ -20,7 +20,7 @@ async function getResourceCatalog(ctx) {
} }
} }
//新建资源目录 //新建资源目录
async function postResourceCatalog(ctx) { async function postResourceCatalog (ctx) {
try { try {
const { name, code } = ctx.request.body; const { name, code } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -49,7 +49,7 @@ async function postResourceCatalog(ctx) {
} }
} }
//修改资源目录 //修改资源目录
async function putResourceCatalog(ctx) { async function putResourceCatalog (ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { name, code, description } = ctx.request.body; const { name, code, description } = ctx.request.body;
@ -78,7 +78,7 @@ async function putResourceCatalog(ctx) {
} }
} }
//删除资源目录 //删除资源目录
async function delResourceCatalog(ctx) { async function delResourceCatalog (ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -117,7 +117,7 @@ async function delResourceCatalog(ctx) {
} }
} }
//获取库表元数据列表 //获取库表元数据列表
async function getMetadataDatabases(ctx) { async function getMetadataDatabases (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', id = null, resourceId } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', id = null, resourceId } = ctx.query;
@ -169,7 +169,7 @@ async function getMetadataDatabases(ctx) {
} }
} }
//获取文件元数据列表 //获取文件元数据列表
async function getMetadataFiles(ctx) { async function getMetadataFiles (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { catalog, limit, offset, keywords, orderBy = 'updateAt', orderDirection = 'desc', resourceId } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'updateAt', orderDirection = 'desc', resourceId } = ctx.query;
@ -214,7 +214,7 @@ async function getMetadataFiles(ctx) {
} }
} }
//获取接口元数据列表 //获取接口元数据列表
async function getMetadataRestapis(ctx) { async function getMetadataRestapis (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', resourceId } = ctx.query; const { catalog, limit, offset, keywords, orderBy = 'createAt', orderDirection = 'desc', resourceId } = ctx.query;
@ -257,7 +257,7 @@ async function getMetadataRestapis(ctx) {
} }
} }
//获取元数据模型 //获取元数据模型
async function getMetadataModels(ctx) { async function getMetadataModels (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { modelTypes } = ctx.query; const { modelTypes } = ctx.query;
@ -281,7 +281,7 @@ async function getMetadataModels(ctx) {
} }
//新建库表元数据 //新建库表元数据
async function postMetadataDatabases(ctx) { async function postMetadataDatabases (ctx) {
try { try {
const { name, code, catalog, parent } = ctx.request.body; const { name, code, catalog, parent } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -318,7 +318,7 @@ async function postMetadataDatabases(ctx) {
} }
//修改库表元数据 //修改库表元数据
async function putMetadataDatabases(ctx) { async function putMetadataDatabases (ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { catalog, name, code } = ctx.request.body; const { catalog, name, code } = ctx.request.body;
@ -354,7 +354,7 @@ async function putMetadataDatabases(ctx) {
} }
} }
//删除库表元数据 //删除库表元数据
async function delMetadataDatabases(ctx) { async function delMetadataDatabases (ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -409,7 +409,7 @@ async function delMetadataDatabases(ctx) {
} }
} }
//获取库表元数据基本信息 //获取库表元数据基本信息
async function getMetadataDatabasesById(ctx) { async function getMetadataDatabasesById (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
@ -440,7 +440,7 @@ async function getMetadataDatabasesById(ctx) {
} }
//打标元数据 //打标元数据
async function postTagMetadata(ctx) { async function postTagMetadata (ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const { tags, database, file, restapi } = ctx.request.body; const { tags, database, file, restapi } = ctx.request.body;
@ -481,7 +481,7 @@ async function postTagMetadata(ctx) {
} }
//获取元数据已打标数据 //获取元数据已打标数据
async function getTagMetadata(ctx) { async function getTagMetadata (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
@ -525,12 +525,20 @@ async function getTagMetadata(ctx) {
} }
} }
//申请资源 //申请资源
async function postMetadataResourceApplications(ctx) { async function postMetadataResourceApplications (ctx) {
try { try {
const { resourceName, applyBy, resourceType, resourceId } = ctx.request.body; const { resourceName, applyBy, resourceType, resourceId } = ctx.request.body;
if (!resourceName || !applyBy || !resourceType || !resourceId) { if (!resourceName || !applyBy || !resourceType || !resourceId) {
ctx.status = 400; ctx.status = 400;
ctx.body = { message: '参数不全,请重新申请资源' } ctx.body = { message: '参数不全,请重新申请资源' }
} else {
const models = ctx.fs.dc.models;
const postOne = await models.ResourceConsumption.findOne({
where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType }
});
if (postOne) {
ctx.status = 400;
ctx.body = { message: '参数不全,请重新申请资源' }
} else { } else {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const postOne = await models.ResourceConsumption.findOne({ const postOne = await models.ResourceConsumption.findOne({
@ -555,7 +563,7 @@ async function postMetadataResourceApplications(ctx) {
} }
//获取元数据资源申请记录 //获取元数据资源申请记录
async function getMetadataResourceApplications(ctx) { async function getMetadataResourceApplications (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { resourceNames, type } = ctx.query; const { resourceNames, type } = ctx.query;
@ -577,7 +585,7 @@ async function getMetadataResourceApplications(ctx) {
} }
//新建文件元数据 //新建文件元数据
async function postMetadataFiles(ctx) { async function postMetadataFiles (ctx) {
try { try {
const { name, catalog, type, fileName } = ctx.request.body; const { name, catalog, type, fileName } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -606,7 +614,7 @@ async function postMetadataFiles(ctx) {
} }
} }
//修改文件元数据 //修改文件元数据
async function putMetadataFiles(ctx) { async function putMetadataFiles (ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { updateFileName } = ctx.query; const { updateFileName } = ctx.query;
@ -646,7 +654,7 @@ async function putMetadataFiles(ctx) {
} }
} }
//删除文件元数据 //删除文件元数据
async function delMetadataFiles(ctx) { async function delMetadataFiles (ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -694,7 +702,7 @@ async function delMetadataFiles(ctx) {
} }
//新建接口元数据 //新建接口元数据
async function postMetadataRestapis(ctx) { async function postMetadataRestapis (ctx) {
try { try {
const { name, catalog, method, url } = ctx.request.body; const { name, catalog, method, url } = ctx.request.body;
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -724,7 +732,7 @@ async function postMetadataRestapis(ctx) {
} }
//修改接口元数据 //修改接口元数据
async function putMetadataRestapis(ctx) { async function putMetadataRestapis (ctx) {
try { try {
const { id } = ctx.params; const { id } = ctx.params;
const { catalog, name, method, url } = ctx.request.body; const { catalog, name, method, url } = ctx.request.body;
@ -758,7 +766,7 @@ async function putMetadataRestapis(ctx) {
} }
} }
//删除接口元数据 //删除接口元数据
async function delMetadataRestapis(ctx) { async function delMetadataRestapis (ctx) {
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -804,6 +812,29 @@ async function delMetadataRestapis(ctx) {
ctx.body = { message: '删除元数据失败' } ctx.body = { message: '删除元数据失败' }
} }
} }
//获取对表的库与字段信息
async function listStructuredData (ctx) {
try {
const models = ctx.fs.dc.models;
const { id, parent } = ctx.query;
let field = await models.MetadataDatabase.findAll({ where: { parent: id } }) || []
let database = await models.MetadataDatabase.findOne({ where: { id: parent } }) || {}
ctx.status = 200;
ctx.body = {
field: field,
database: database
};
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "获取元数据资源申请记录失败"
}
}
}
module.exports = { module.exports = {
getResourceCatalog, getResourceCatalog,
postResourceCatalog, postResourceCatalog,
@ -826,5 +857,6 @@ module.exports = {
delMetadataFiles, delMetadataFiles,
postMetadataRestapis, postMetadataRestapis,
putMetadataRestapis, putMetadataRestapis,
delMetadataRestapis delMetadataRestapis,
listStructuredData
} }

3
api/app/lib/routes/latestMetadata/index.js

@ -68,4 +68,7 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['DEL/metadata/restapis/:id'] = { content: '删除接口元数据', visible: true }; app.fs.api.logAttr['DEL/metadata/restapis/:id'] = { content: '删除接口元数据', visible: true };
router.delete('/metadata/restapis/:id', latestMetadata.delMetadataRestapis); router.delete('/metadata/restapis/:id', latestMetadata.delMetadataRestapis);
app.fs.api.logAttr['GET/listStructuredData'] = { content: '获取对表的库与字段信息', visible: true };
router.get('/listStructuredData', latestMetadata.listStructuredData);
}; };

6
web/client/src/sections/dataQuality/containers/ruleLibrary.js

@ -97,7 +97,7 @@ function RuleLibrary ({ loading, clientHeight, actions, dispatch, }) {
return <> return <>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 20 }}>
<Button onClick={() => { <Button onClick={() => {
setRuleModal(true); setRuleModal(true);
}}>新建业务规则</Button> }}>新建业务规则</Button>
@ -123,7 +123,7 @@ function RuleLibrary ({ loading, clientHeight, actions, dispatch, }) {
<Table <Table
columns={columns} columns={columns}
dataSource={tableList?.rows || []} dataSource={tableList?.rows || []}
scroll={{ scrollToFirstRowOnChange: true, y: clientHeight - 260 }} scroll={{ scrollToFirstRowOnChange: true, y: clientHeight - 240 }}
pagination={{ pagination={{
current: query?.page + 1, current: query?.page + 1,
pageSize: query?.limit, pageSize: query?.limit,
@ -146,7 +146,7 @@ function RuleLibrary ({ loading, clientHeight, actions, dispatch, }) {
close={() => { close={() => {
setRuleModal(false); setRuleModal(false);
setEditData({}) setEditData({})
} } }}
success={() => { success={() => {
resourceData({ limit: 10, page: 0, keyword }) resourceData({ limit: 10, page: 0, keyword })
} }

36
web/client/src/sections/metadataManagement/actions/businessMetadata.js

@ -3,7 +3,7 @@
import { basicAction } from '@peace/utils' import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils' import { ApiTable } from '$utils'
export function getBusinessMetadataDatabases(params) { export function getBusinessMetadataDatabases (params) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
@ -15,7 +15,7 @@ export function getBusinessMetadataDatabases(params) {
}); });
} }
export function postBusinessMetadataDatabases(data) { export function postBusinessMetadataDatabases (data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
data: data, data: data,
@ -27,7 +27,7 @@ export function postBusinessMetadataDatabases(data) {
}); });
} }
export function putBusinessMetadataDatabases(id, data) { export function putBusinessMetadataDatabases (id, data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'put', type: 'put',
data: data, data: data,
@ -40,7 +40,7 @@ export function putBusinessMetadataDatabases(id, data) {
}); });
} }
export function delBusinessMetadataDatabases(id) { export function delBusinessMetadataDatabases (id) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'del', type: 'del',
dispatch, dispatch,
@ -53,7 +53,7 @@ export function delBusinessMetadataDatabases(id) {
} }
export function getBusinessMetadataFiles(params) { export function getBusinessMetadataFiles (params) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
@ -65,7 +65,7 @@ export function getBusinessMetadataFiles(params) {
}); });
} }
export function postBusinessMetadataFiles(data) { export function postBusinessMetadataFiles (data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
data: data, data: data,
@ -77,7 +77,7 @@ export function postBusinessMetadataFiles(data) {
}); });
} }
export function putBusinessMetadataFiles(id, data) { export function putBusinessMetadataFiles (id, data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'put', type: 'put',
data: data, data: data,
@ -90,7 +90,7 @@ export function putBusinessMetadataFiles(id, data) {
}); });
} }
export function delBusinessMetadataFiles(id) { export function delBusinessMetadataFiles (id) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'del', type: 'del',
dispatch, dispatch,
@ -103,7 +103,7 @@ export function delBusinessMetadataFiles(id) {
} }
export function getBusinessMetadataRestapis(params) { export function getBusinessMetadataRestapis (params) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
@ -115,7 +115,7 @@ export function getBusinessMetadataRestapis(params) {
}); });
} }
export function postBusinessMetadataRestapis(data) { export function postBusinessMetadataRestapis (data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
data: data, data: data,
@ -127,7 +127,7 @@ export function postBusinessMetadataRestapis(data) {
}); });
} }
export function putBusinessMetadataRestapis(id, data) { export function putBusinessMetadataRestapis (id, data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'put', type: 'put',
data: data, data: data,
@ -140,7 +140,7 @@ export function putBusinessMetadataRestapis(id, data) {
}); });
} }
export function delBusinessMetadataRestapis(id) { export function delBusinessMetadataRestapis (id) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'del', type: 'del',
dispatch, dispatch,
@ -151,3 +151,15 @@ export function delBusinessMetadataRestapis(id) {
} }
}); });
} }
export function listStructuredData (query = {}) {
return dispatch => basicAction({
type: 'get',
query,
dispatch: dispatch,
actionType: 'GET_LIST_STRUCTURED_DATA',
url: ApiTable.listStructuredData,
msg: { error: '获取对表的库与字段信息失败' },
reducer: {}
});
}

237
web/client/src/sections/metadataManagement/components/releaseModal.js

@ -0,0 +1,237 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Modal, Input, Form, Tabs, Avatar, Checkbox, Button, Select } from 'antd';
import { PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons';
const { TabPane } = Tabs;
const { TextArea } = Input;
const CheckboxGroup = Checkbox.Group;
const ReleaseModal = ({ actions, dispatch, onConfirm, onCancel, editData = {} }) => {
const { metadataManagement } = actions;
const [activeKey, setActiveKeyl] = useState("field")
const [fieldList, setFiedList] = useState([])
const [fieldData, setFiedData] = useState([])
const [database, setDatabase] = useState({})
const [fieldValue, setFiedValue] = useState([])
const [indeterminate, setIndeterminate] = useState(false)
const [fromData, setFromData] = useState([{ value1: '', value2: '', value3: '' }])
const [sql, setSql] = useState()
const [form] = Form.useForm();
useEffect(() => {
dispatch(metadataManagement.listStructuredData({ id: editData?.id, parent: editData?.parent })).then(res => {
if (res.success) {
setFiedData(res.payload.data?.field || [])
setFiedList(res.payload.data?.field?.map(v => v.code) || [])
setDatabase(res.payload.data?.database || {})
}
})
}, []);
let operator = [{ value: '=', label: '=' },
{ value: '!=', label: '!=' },
{ value: '>', label: '>' },
{ value: '<', label: '<' },
{ value: '>=', label: '>=' },
{ value: '<=', label: '<=' },
{ value: 'BETWEEN', label: 'BETWEEN' },
{ value: 'LIKE', label: 'LIKE' },
{ value: 'IN', label: 'IN' }]
return (
<Modal title={'发布REST服务'} open={true} destroyOnClose
width={800}
// onOk={() => handleOk(null)}
onCancel={onCancel}
footer={null}
>
<div style={{ width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-around' }}>
{[{ name: '选择字段', key: "field" },
{ name: '配置条件', key: "condition" },
{ name: '预览SQL', key: "SQL" },
{ name: '服务发布', key: "release" }].map((v, index) => {
let title = []
if (index > 0) {
title.push(<div style={{ width: '14%', border: '1px solid #0000004a' }}></div>)
}
title.push(<div style={{ width: '14%', color: activeKey == v.key ? '#1e6ee5' : "", }}>
<Avatar style={{
backgroundColor: activeKey == v.key ? "rgb(30 110 229 / 74%)" : 'rgb(200 192 185)'
}}
size="large" icon={index + 1} />
{v.name}
</div>)
return title
})}
</div>
<Tabs activeKey={activeKey} onChange={v => {
setActiveKeyl(v)
}} >
<TabPane key="field">
<div style={{ fontSize: 20, fontWeight: 600 }}>选择字段</div>
{/* <div style={{ marginLeft: 20 }}> */}
<Checkbox indeterminate={indeterminate} style={{ margin: '20px 40px' }} onChange={e => {
setFiedValue(e.target.checked ? fieldList : []);
setIndeterminate(e.target.checked);
}}>
全选
</Checkbox>
<div style={{ display: 'flex', marginLeft: 40 }}>
<div style={{ marginRight: 8 }}>字段:</div>
<CheckboxGroup options={fieldList} value={fieldValue} onChange={v => {
setFiedValue(v)
if (v?.length == fieldList?.length) {
setIndeterminate(true)
} else {
setIndeterminate(false)
}
}} />
</div>
</TabPane>
<TabPane key="condition">
<div style={{ fontSize: 20, margin: '20px 0', fontWeight: 600 }}>配置条件</div>
{fromData?.map((f, index) => {
return <div key={'key' + index} style={{ display: 'flex', marginBottom: 16 }}>
<Select
style={{ width: 200, marginRight: 10 }} value={f.value1 || null}
placeholder="请选择字段"
onChange={v => {
fromData?.splice(index, 1, { value1: v, value2: f.value2, value3: f.value3 })
setFromData([...fromData])
}}
options={fieldValue?.map(d => ({ value: d, label: d })) || []}
allowClear
/>
<Select
style={{ width: 200, marginRight: 10 }} value={f.value2 || null}
placeholder="请选择条件"
onChange={v => {
fromData?.splice(index, 1, { value1: f.value1, value2: v, value3: f.value3 })
setFromData([...fromData])
}}
options={operator}
allowClear
/>
<Input
style={{ width: 200, marginRight: 10 }} value={f.value3}
placeholder="请输入值"
onChange={v => {
fromData?.splice(index, 1, { value1: f.value1, value2: f.value2, value3: v?.target?.value })
setFromData([...fromData])
}}
allowClear
/>
{index == 0 ?
<PlusCircleOutlined style={{ fontSize: 20, marginTop: 6 }} onClick={() => {
fromData?.splice(index, 0, { value1: '', value2: '', value3: '' })
setFromData([...fromData])
}} />
: <MinusCircleOutlined style={{ fontSize: 20, marginTop: 6 }} onClick={() => {
fromData?.splice(index, 1)
setFromData([...fromData])
}} />
}
</div>
})}
</TabPane>
<TabPane key="SQL">
<div style={{ fontSize: 20, marginBottom: 20, fontWeight: 600, display: 'flex', justifyContent: 'space-between' }}>预览SQL<Button onClick={() => {
console.log(editData);
console.log(database);
console.log(fromData);
let whereOption = []
fromData.map(s => {
whereOption.push(`${editData?.code}.${s.value1} ${s.value2} ${s.value3}`);
})
let sqlData = `SELECT * FROM ${editData?.code} ${fromData.length ? 'WHERE ' + whereOption.join(' AND ') : ''}`
setSql(sqlData)
}}>生成SQL</Button></div>
<TextArea value={sql} autoSize={{ minRows: 5 }} disabled={true} />
</TabPane>
<TabPane key="release">
<div style={{ fontSize: 20, marginBottom: 10, fontWeight: 600 }}>服务发布</div>
<div style={{ display: 'flex' }}>接口名称<Input style={{ width: 180 }} placeholder='请输入' /></div>
<div style={{ display: 'flex', margin: '10px 0 10px 30px' }}>URL <Select
style={{ width: 200, marginRight: 10 }}
onChange={v => {
}}
defaultValue={"GET"}
options={[{ value: "GET", label: "GET" },
{ value: "POST", label: "POST" },
{ value: "PUT", label: "PUT" },
{ value: "DEL", label: "DEL" },]}
allowClear
/>
<Input style={{ width: 180, marginLeft: 20 }} placeholder='请输入' />
</div>
<div style={{ display: 'flex', marginLeft: 20 }}>返回值
<div style={{ display: 'flex', width: 250, flexDirection: 'column', alignItems: 'center' }}>
<div key={'fieldData' + index} style={{ display: 'flex' }}>
<div style={{ width: 80, border: '1px solid #dcc' }}>名称</div>
<div style={{ width: 80, border: '1px solid #dcc' }}>意义</div>
<div style={{ width: 80, border: '1px solid #dcc' }}>说明</div>
</div>
{fieldData?.map((s, index) => {
return <div key={'fieldData' + index} style={{ display: 'flex' }}>
<div style={{ width: 80, border: '1px solid #dcc' }}>{s.code}</div>
<div style={{ width: 80, border: '1px solid #dcc' }}>{s.name}</div>
<div style={{ width: 80, border: '1px solid #dcc' }}>{s.type}</div>
</div>
})}
</div>
</div>
</TabPane>
</Tabs >
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: 20 }}>
{activeKey == 'condition' || activeKey == 'SQL' || activeKey == 'release' ? <Button type="primary" onClick={() => {
if (activeKey == 'condition') {
setActiveKeyl('field')
} else if (activeKey == 'SQL') {
setActiveKeyl('condition')
} else if (activeKey == 'release') {
setActiveKeyl('SQL')
}
}}>上一步</Button> : ""}
{activeKey == 'condition' || activeKey == 'SQL' || activeKey == 'field' ? <Button style={{ marginLeft: 10 }} type="primary" onClick={() => {
if (activeKey == 'field') {
setActiveKeyl('condition')
} else if (activeKey == 'condition') {
setActiveKeyl('SQL')
} else if (activeKey == 'SQL') {
setActiveKeyl('release')
}
}}>下一步</Button> : ""}
{activeKey == 'release' ? <Button type="primary" style={{ marginLeft: 10 }} onClick={() => {
}}>完成 </Button> : ""}
<Button style={{ marginLeft: 10 }} onClick={() => onCancel()}>取消</Button>
</div>
</Modal >
)
}
function mapStateToProps (state) {
const { global, auth, } = state;
return {
user: auth.user,
actions: global.actions,
clientHeight: global.clientHeight,
};
}
export default connect(mapStateToProps)(ReleaseModal)

33
web/client/src/sections/metadataManagement/containers/databasesTable.js

@ -8,6 +8,7 @@ import MetadataDatabaseModal from '../components/metadataDatabaseModal';
import { ModelTypes } from '../constants/index'; import { ModelTypes } from '../constants/index';
import MetadataTagModal from '../components/metadataTagModal'; import MetadataTagModal from '../components/metadataTagModal';
import MetadataResourceModal from '../components/metadataResourceModal'; import MetadataResourceModal from '../components/metadataResourceModal';
import ReleaseModal from '../components/releaseModal';
const DatabaseTable = (props) => { const DatabaseTable = (props) => {
const { user, dispatch, actions, clientHeight, resourceCatalogId, resourceCatalogKey, const { user, dispatch, actions, clientHeight, resourceCatalogId, resourceCatalogKey,
@ -28,6 +29,7 @@ const DatabaseTable = (props) => {
const [editTagData, setEditTagData] = useState({}); const [editTagData, setEditTagData] = useState({});
const [resourceModalVisible, setResourceModalVisible] = useState(false); const [resourceModalVisible, setResourceModalVisible] = useState(false);
const [editResourceData, setEditResourceData] = useState({}); const [editResourceData, setEditResourceData] = useState({});
const [releaseModal, setReleaseModal] = useState(false);
useEffect(() => { useEffect(() => {
dispatch(metadataManagement.getTagList()); dispatch(metadataManagement.getTagList());
@ -73,7 +75,7 @@ const DatabaseTable = (props) => {
const marking = (id) => { const marking = (id) => {
dispatch(metadataManagement.getTagMetadata(id, 'database')).then(res => { dispatch(metadataManagement.getTagMetadata(id, 'database')).then(res => {
if (res.success) { if (res.success) {
const obj = { tagSet: [], tags: [], id: id }; const obj = { tagSet: [], tags: [], id: id }
if (res.payload.data.length) { if (res.payload.data.length) {
const tagSetIds = res.payload.data.map(d => d.tagSet) const tagSetIds = res.payload.data.map(d => d.tagSet)
obj.tagSet = [...new Set(tagSetIds)]; obj.tagSet = [...new Set(tagSetIds)];
@ -96,6 +98,13 @@ const DatabaseTable = (props) => {
setResourceModalVisible(true); setResourceModalVisible(true);
} }
const servicePublication = (record) => {
console.log(record);
setEditData(record)
setReleaseModal(true)
}
const onConfirmResource = (values) => { const onConfirmResource = (values) => {
dispatch(metadataManagement.postMetadataResourceApplications(values)).then(res => { dispatch(metadataManagement.postMetadataResourceApplications(values)).then(res => {
if (res.success) { if (res.success) {
@ -170,7 +179,7 @@ const DatabaseTable = (props) => {
width: '8%', width: '8%',
render: (text, record) => { render: (text, record) => {
let resourceApplicationsRecords = metadataResourceApplications.filter(ra => let resourceApplicationsRecords = metadataResourceApplications.filter(ra =>
ra.applyBy == user.id && ra.resourceName === record.name && ra.resourceId == record.id && !!record.token); ra.applyBy == user.id && ra.resourceName === record.name && ra.resourceId == record.id);
return <ButtonGroup> return <ButtonGroup>
<a onClick={() => onView(record)}>查看</a> <a onClick={() => onView(record)}>查看</a>
{user.role == '数据消费者' ? null : {user.role == '数据消费者' ? null :
@ -187,6 +196,10 @@ const DatabaseTable = (props) => {
{user.role !== '数据消费者' ? null : record.type === '表' ? resourceApplicationsRecords.length === 0 ? {user.role !== '数据消费者' ? null : record.type === '表' ? resourceApplicationsRecords.length === 0 ?
<a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> : <a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> :
<span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span> : null} <span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span> : null}
{user.role == '数据消费者' ? null :
record.type === '表' ?
<a style={{ marginLeft: 10 }} onClick={() => servicePublication(record)}>REST服务发布</a> : null
}
</ButtonGroup> </ButtonGroup>
} }
}]; }];
@ -332,9 +345,23 @@ const DatabaseTable = (props) => {
onCancel={() => setResourceModalVisible(false)} onCancel={() => setResourceModalVisible(false)}
onConfirm={onConfirmResource} /> : '' onConfirm={onConfirmResource} /> : ''
} }
{
releaseModal ?
<ReleaseModal
editData={editData}
onCancel={() => {
setReleaseModal(false)
setEditData({})
}}
onConfirm={() => {
}}
/>
: ''
}
</Spin > </Spin >
} }
function mapStateToProps(state) { function mapStateToProps (state) {
const { global, auth, metadataDatabases, metadataModels, tagList, tagMetadata, metadataResourceApplications } = state; const { global, auth, metadataDatabases, metadataModels, tagList, tagMetadata, metadataResourceApplications } = state;
return { return {
user: auth.user, user: auth.user,

1
web/client/src/utils/webapi.js

@ -22,6 +22,7 @@ export const ApiTable = {
postResourceCatalog: 'resource-catalog', postResourceCatalog: 'resource-catalog',
putResourceCatalog: 'resource-catalog/{id}', putResourceCatalog: 'resource-catalog/{id}',
delResourceCatalog: 'resource-catalog/{id}', delResourceCatalog: 'resource-catalog/{id}',
listStructuredData: 'listStructuredData',
//最新元数据-元数据列表查询 //最新元数据-元数据列表查询
getMetadataDatabases: 'metadata/databases', getMetadataDatabases: 'metadata/databases',
getMetadataFiles: 'metadata/files', getMetadataFiles: 'metadata/files',

Loading…
Cancel
Save