diff --git a/api/app/lib/controllers/member/index.js b/api/app/lib/controllers/member/index.js index 2b0a2af..aac924c 100644 --- a/api/app/lib/controllers/member/index.js +++ b/api/app/lib/controllers/member/index.js @@ -18,6 +18,7 @@ function getUserList(opts) { where: searchWhere, order: [["id", "desc"]], attributes: { exclude: ['password'] }, + include: [{ model: models.Organization }] } if (name) { diff --git a/api/app/lib/controllers/resourceConsumption/index.js b/api/app/lib/controllers/resourceConsumption/index.js index 85b2cd1..302aeac 100644 --- a/api/app/lib/controllers/resourceConsumption/index.js +++ b/api/app/lib/controllers/resourceConsumption/index.js @@ -5,7 +5,7 @@ function getApproveList(opts) { return async function (ctx, next) { const models = ctx.fs.dc.models; - const { page, limit, applyAt, approveState, resourceName, applyBy, applyById, state ,} = ctx.query; + const { page, limit, applyAt, approveState, resourceName, applyBy, applyById, state, } = ctx.query; let errMsg = { message: '获取消费审批列表失败' } try { @@ -17,12 +17,38 @@ function getApproveList(opts) { include: [{ model: models.User, as: 'applyUser', - attributes: ['id', 'name'] + attributes: ['id', 'name'], + include: [{ model: models.Organization }] }, { model: models.User, as: 'approveUser', attributes: ['id', 'name'] - },] + }, + { + model: models.MetadataDatabase, + attributes: ['id', 'name'], + include: [{ + model: models.ResourceCatalog, + attributes: ['id', 'name'], + include: [{ + model: models.Organization, + attributes: ['id', 'name'], + }] + }] + }, + { + model: models.RestfulApi, + attributes: ['id', 'name'], + include: [{ + model: models.ResourceCatalog, + attributes: ['id', 'name'], + include: [{ + model: models.Organization, + attributes: ['id', 'name'], + }] + }] + } + ] } if (resourceName) { option.where.resourceName = { $iLike: `%${resourceName}%` } diff --git a/api/app/lib/index.js b/api/app/lib/index.js index aabd9b3..9c0f409 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -104,4 +104,12 @@ module.exports.models = function (dc) { RestfulApiRecord.belongsTo(RestfulApi, { foreignKey: 'restServiceId', targetKey: 'id' }); User.belongsTo(Organization, { foreignKey: 'orgId', targetKey: 'id' }); + + ResourceConsumption.belongsTo(MetadataDatabase, { foreignKey: 'resourceId', targetKey: 'id' }); + ResourceConsumption.belongsTo(RestfulApi, { foreignKey: 'restServiceId', targetKey: 'id' }); + + MetadataDatabase.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' }); + RestfulApi.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' }); + + ResourceCatalog.belongsTo(Organization, { foreignKey: 'orgId', targetKey: 'id' }); }; diff --git a/api/app/lib/models/restful_api.js b/api/app/lib/models/restful_api.js index e1dea90..c7d8df3 100644 --- a/api/app/lib/models/restful_api.js +++ b/api/app/lib/models/restful_api.js @@ -78,6 +78,15 @@ module.exports = dc => { primaryKey: false, field: "fields", autoIncrement: false + }, + catalog: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "catalog", + autoIncrement: false } }, { tableName: "t_restful_api", diff --git a/scripts/0.0.14/01_add_organization.sql b/scripts/0.0.14/01_add_organization.sql new file mode 100644 index 0000000..b92a2cf --- /dev/null +++ b/scripts/0.0.14/01_add_organization.sql @@ -0,0 +1,16 @@ +create table organization +( + id serial + constraint organization_pk + primary key, + name varchar, + code varchar, + ability varchar +); + +comment on table organization is '用户机构'; + +comment on column organization.ability is '职能'; + +create unique index organization_id_uindex + on organization (id); diff --git a/scripts/0.0.14/02_alter_organization.sql b/scripts/0.0.14/02_alter_organization.sql new file mode 100644 index 0000000..04367d8 --- /dev/null +++ b/scripts/0.0.14/02_alter_organization.sql @@ -0,0 +1,8 @@ +alter table t_user + add "orgId" int; + +alter table t_resource_catalog + add "orgId" int; + +alter table t_restful_api + add catalog int; \ No newline at end of file diff --git a/web/client/src/sections/memberManagement/containers/member.js b/web/client/src/sections/memberManagement/containers/member.js index 2b9993f..d7c7599 100644 --- a/web/client/src/sections/memberManagement/containers/member.js +++ b/web/client/src/sections/memberManagement/containers/member.js @@ -50,6 +50,13 @@ function Member(props) { title: '角色', dataIndex: 'role', }, + { + title: '机构', + dataIndex: 'org', + render: (text, record) => { + return record?.organization?.name + } + }, { title: '状态', dataIndex: 'enabled', diff --git a/web/client/src/sections/metadataManagement/components/releaseModal.js b/web/client/src/sections/metadataManagement/components/releaseModal.js index 62a4f4f..a7fbde7 100644 --- a/web/client/src/sections/metadataManagement/components/releaseModal.js +++ b/web/client/src/sections/metadataManagement/components/releaseModal.js @@ -249,6 +249,7 @@ const ReleaseModal = ({ actions, dispatch, onConfirm, onCancel, editData = {} }) }); } else { dispatch(metadataManagement.publishingServices({ + catalog: database?.catalog, table: database?.code, fields: editData?.code, conditions: sql, @@ -269,7 +270,7 @@ const ReleaseModal = ({ actions, dispatch, onConfirm, onCancel, editData = {} }) ) } -function mapStateToProps (state) { +function mapStateToProps(state) { const { global, auth, } = state; return { user: auth.user, diff --git a/web/client/src/sections/metadataManagement/components/resourceCatalogModal.js b/web/client/src/sections/metadataManagement/components/resourceCatalogModal.js index c486c60..6e20c96 100644 --- a/web/client/src/sections/metadataManagement/components/resourceCatalogModal.js +++ b/web/client/src/sections/metadataManagement/components/resourceCatalogModal.js @@ -77,10 +77,9 @@ const ResourceCatalogModal = (props) => { - { organization?.map(s => ({s.name})) } diff --git a/web/client/src/sections/resourceConsumption/containers/approve.js b/web/client/src/sections/resourceConsumption/containers/approve.js index 36cb578..956ac1e 100644 --- a/web/client/src/sections/resourceConsumption/containers/approve.js +++ b/web/client/src/sections/resourceConsumption/containers/approve.js @@ -2,13 +2,11 @@ import React, { useEffect, useState } from 'react' import { connect } from 'react-redux'; import moment from 'moment'; import ApproveModal from '../components/approveModal'; - - import { Tabs, Form, Input, DatePicker, Button, Table } from 'antd'; -import { v1 } from 'uuid'; +import { Func } from '$utils' -function Approve ({ loading, clientHeight, actions, dispatch, }) { +function Approve({ loading, clientHeight, actions, dispatch, }) { const { resourceConsumption } = actions const [tabsKey, setTabsKey] = useState("stay") @@ -41,6 +39,10 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { title: '申请人', dataIndex: 'applyBy', render: (text, record) => record?.applyUser?.name + }, { + title: '申请人机构', + dataIndex: 'approveOrg', + render: (text, record) => record?.applyUser?.organization?.name }, { title: '需求描述', dataIndex: 'requirements', @@ -83,10 +85,13 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { title: '操作', dataIndex: 'handle', // ellipsis: true, - render: (text, record) => + render: (text, record) => { + let enable = Func?.isOrgOrSuperAdmin(record?.applyUser?.organization?.id) + return enable ? : + } }, ]; @@ -175,7 +180,7 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { } -function mapStateToProps (state) { +function mapStateToProps(state) { const { global, auth, resourceCatalog } = state; return { user: auth.user, diff --git a/web/client/src/sections/resourceConsumption/containers/myApplication.js b/web/client/src/sections/resourceConsumption/containers/myApplication.js index 4fcf89f..e69b23a 100644 --- a/web/client/src/sections/resourceConsumption/containers/myApplication.js +++ b/web/client/src/sections/resourceConsumption/containers/myApplication.js @@ -8,7 +8,7 @@ import { Tabs, Form, Input, DatePicker, Button, Table, Select } from 'antd'; import { v1 } from 'uuid'; -function MyApplication ({ loading, clientHeight, actions, dispatch, user }) { +function MyApplication({ loading, clientHeight, actions, dispatch, user }) { const { resourceConsumption } = actions @@ -34,7 +34,14 @@ function MyApplication ({ loading, clientHeight, actions, dispatch, user }) { const columns = [{ title: '资源名称', dataIndex: 'resourceName', - }, { + }, + { + title: '数据资源机构', + dataIndex: 'org', + render: (text, record) => record?.metadataDatabase?.resourceCatalog?.organization?.name || + record?.restfulApi?.resourceCatalog?.organization?.name + }, + { title: '审批人', dataIndex: 'approveBy', render: (text, record) => record?.approveUser?.name @@ -136,7 +143,7 @@ function MyApplication ({ loading, clientHeight, actions, dispatch, user }) { } -function mapStateToProps (state) { +function mapStateToProps(state) { const { global, auth, resourceCatalog } = state; return { user: auth.user, diff --git a/web/client/src/utils/func.js b/web/client/src/utils/func.js index e473145..ac049ab 100644 --- a/web/client/src/utils/func.js +++ b/web/client/src/utils/func.js @@ -1,13 +1,21 @@ 'use strict'; - export default class Func { - static isAuthorized(authcode) { - if (JSON.parse(sessionStorage.getItem('user'))) { - const { resources } = JSON.parse(sessionStorage.getItem('user')); - return resources.includes(authcode); - }else{ - return false; - } - } - } - \ No newline at end of file +export default class Func { + static isAuthorized(authcode) { + if (JSON.parse(sessionStorage.getItem('user'))) { + const { resources } = JSON.parse(sessionStorage.getItem('user')); + return resources.includes(authcode); + } else { + return false; + } + } + + static isOrgOrSuperAdmin(id) { + if (JSON.parse(sessionStorage.getItem('user'))) { + const { username, orgId } = JSON.parse(sessionStorage.getItem('user')); + return username == 'SuperAdmin' || orgId == id; + } else { + return false; + } + } +}