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) => {