添加银行端后端接口
This commit is contained in:
@@ -17,6 +17,11 @@ const Position = require('./Position');
|
||||
const Report = require('./Report');
|
||||
const Project = require('./Project');
|
||||
const SupervisionTask = require('./SupervisionTask');
|
||||
const InstallationTask = require('./InstallationTask');
|
||||
const CompletedSupervision = require('./CompletedSupervision');
|
||||
const LoanApplication = require('./LoanApplication');
|
||||
const AuditRecord = require('./AuditRecord');
|
||||
const LoanContract = require('./LoanContract');
|
||||
|
||||
// 定义模型关联关系
|
||||
|
||||
@@ -141,6 +146,162 @@ User.hasMany(SupervisionTask, {
|
||||
as: 'updatedSupervisionTasks'
|
||||
});
|
||||
|
||||
// 待安装任务与用户关联(创建人)
|
||||
InstallationTask.belongsTo(User, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'creator',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(InstallationTask, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'createdInstallationTasks'
|
||||
});
|
||||
|
||||
// 待安装任务与用户关联(更新人)
|
||||
InstallationTask.belongsTo(User, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updater',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(InstallationTask, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updatedInstallationTasks'
|
||||
});
|
||||
|
||||
// 监管任务已结项与用户关联(创建人)
|
||||
CompletedSupervision.belongsTo(User, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'creator',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(CompletedSupervision, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'createdCompletedSupervisions'
|
||||
});
|
||||
|
||||
// 监管任务已结项与用户关联(更新人)
|
||||
CompletedSupervision.belongsTo(User, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updater',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(CompletedSupervision, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updatedCompletedSupervisions'
|
||||
});
|
||||
|
||||
// 贷款商品与用户关联(创建人)
|
||||
LoanProduct.belongsTo(User, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'creator',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanProduct, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'createdLoanProducts'
|
||||
});
|
||||
|
||||
// 贷款商品与用户关联(更新人)
|
||||
LoanProduct.belongsTo(User, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updater',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanProduct, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updatedLoanProducts'
|
||||
});
|
||||
|
||||
// 贷款申请与用户关联(申请人)
|
||||
LoanApplication.belongsTo(User, {
|
||||
foreignKey: 'applicantId',
|
||||
as: 'applicant',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanApplication, {
|
||||
foreignKey: 'applicantId',
|
||||
as: 'loanApplications'
|
||||
});
|
||||
|
||||
// 贷款申请与用户关联(审批人)
|
||||
LoanApplication.belongsTo(User, {
|
||||
foreignKey: 'approvedBy',
|
||||
as: 'approver',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanApplication, {
|
||||
foreignKey: 'approvedBy',
|
||||
as: 'approvedApplications'
|
||||
});
|
||||
|
||||
// 贷款申请与用户关联(拒绝人)
|
||||
LoanApplication.belongsTo(User, {
|
||||
foreignKey: 'rejectedBy',
|
||||
as: 'rejector',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanApplication, {
|
||||
foreignKey: 'rejectedBy',
|
||||
as: 'rejectedApplications'
|
||||
});
|
||||
|
||||
// 审核记录与贷款申请关联
|
||||
AuditRecord.belongsTo(LoanApplication, {
|
||||
foreignKey: 'applicationId',
|
||||
as: 'application',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
LoanApplication.hasMany(AuditRecord, {
|
||||
foreignKey: 'applicationId',
|
||||
as: 'auditRecords'
|
||||
});
|
||||
|
||||
// 审核记录与用户关联(审核人)
|
||||
AuditRecord.belongsTo(User, {
|
||||
foreignKey: 'auditorId',
|
||||
as: 'auditorUser',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(AuditRecord, {
|
||||
foreignKey: 'auditorId',
|
||||
as: 'auditRecords'
|
||||
});
|
||||
|
||||
// 贷款合同与用户关联(创建人)
|
||||
LoanContract.belongsTo(User, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'creator',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanContract, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'createdLoanContracts'
|
||||
});
|
||||
|
||||
// 贷款合同与用户关联(更新人)
|
||||
LoanContract.belongsTo(User, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updater',
|
||||
targetKey: 'id'
|
||||
});
|
||||
|
||||
User.hasMany(LoanContract, {
|
||||
foreignKey: 'updatedBy',
|
||||
as: 'updatedLoanContracts'
|
||||
});
|
||||
|
||||
// 导出所有模型和数据库实例
|
||||
module.exports = {
|
||||
sequelize,
|
||||
@@ -154,5 +315,10 @@ module.exports = {
|
||||
Position,
|
||||
Report,
|
||||
Project,
|
||||
SupervisionTask
|
||||
SupervisionTask,
|
||||
InstallationTask,
|
||||
CompletedSupervision,
|
||||
LoanApplication,
|
||||
AuditRecord,
|
||||
LoanContract
|
||||
};
|
||||
Reference in New Issue
Block a user