Browse Source

修改表字段重复

master
wenlele 2 years ago
parent
commit
8bd8f0ef78
  1. 26
      api/app/lib/controllers/dataService/index.js
  2. 6
      api/app/lib/controllers/latestMetadata/index.js
  3. 4
      web/client/src/sections/dataService/components/editModal.js

26
api/app/lib/controllers/dataService/index.js

@ -96,34 +96,26 @@ function getLookField (opts) {
let option = {
where: {
$or: []
// code: table,
// 'metadataDatabase.code': fields
code: table,
},
order: [["id", "desc"]],
include: [{
model: models.MetadataDatabase,
include: [{
model: models.MetadataDatabase,
}],
where: { code: fields, },
distinct: true
}],
distinct: true
}
option.where.$or.push(
{
code: table,
}
)
option.where.$or.push(
{
'$metadataDatabase.code$': fields
},
)
let res = await models.MetadataDatabase.findOne(option)
let list = await models.MetadataDatabase.findOne(option)
let res = await models.MetadataDatabase.findAll({
where: {
type: '字段',
parent: list && list.metadataDatabases[0] && list.metadataDatabases[0].id
}
})
ctx.status = 200;

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

@ -819,8 +819,8 @@ async function listStructuredData (ctx) {
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 } }) || {}
let field = await models.MetadataDatabase.findAll({ where: { parent: id, type: '字段' } }) || []
let database = await models.MetadataDatabase.findOne({ where: { id: parent, type: '库' } }) || {}
ctx.status = 200;
ctx.body = {
@ -831,7 +831,7 @@ async function listStructuredData (ctx) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "获取元数据资源申请记录失败"
"message": "获取对表的库与字段信息失败"
}
}
}

4
web/client/src/sections/dataService/components/editModal.js

@ -12,7 +12,7 @@ function EditModal ({ loading, parent, user, actions, editData = {}, dispatch, c
const { dataService } = actions
const [lookFiold, setLookFiold] = useState([]);
const [interfaceName, setInterfaceName] = useState()
useEffect(() => {
setInterfaceName(editData?.name);
dispatch(dataService.getLookField({ table: editData?.table, fields: editData?.fields })).then(res => {
@ -62,7 +62,7 @@ function EditModal ({ loading, parent, user, actions, editData = {}, dispatch, c
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>意义</div>
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>说明</div>
</div>
{lookFiold?.metadataDatabases?.map((s, index) => {
{lookFiold?.map((s, index) => {
return <div key={'lookFiold' + index} style={{ display: 'flex' }}>
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>{s.code}</div>
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>{s.name}</div>

Loading…
Cancel
Save