添加银行政府后端接口

This commit is contained in:
2025-09-25 15:53:44 +08:00
parent b17bdcc24c
commit 5b6b7e0a96
60 changed files with 5345 additions and 1920 deletions

View File

@@ -11,7 +11,7 @@ const Role = require('./Role');
const Account = require('./Account');
const Transaction = require('./Transaction');
const LoanProduct = require('./LoanProduct');
const Employee = require('./Employee');
const Employee = require('./Employee')(sequelize);
const Department = require('./Department');
const Position = require('./Position');
const Report = require('./Report');
@@ -62,29 +62,7 @@ Transaction.belongsTo(Account, {
// 交易记录与用户关联(通过账户)
// 移除不合理的Transaction->User through Account的belongsTo定义避免错误外键映射
// 员工与部门关联
Employee.belongsTo(Department, {
foreignKey: 'department_id',
as: 'department',
targetKey: 'id'
});
Department.hasMany(Employee, {
foreignKey: 'department_id',
as: 'employees'
});
// 员工与职位关联
Employee.belongsTo(Position, {
foreignKey: 'position_id',
as: 'position',
targetKey: 'id'
});
Position.hasMany(Employee, {
foreignKey: 'position_id',
as: 'employees'
});
// 员工关联关系Employee模型使用字符串字段存储部门和职位不需要关联
// 报表与用户关联
Report.belongsTo(User, {
@@ -100,7 +78,7 @@ User.hasMany(Report, {
// 项目与用户关联(创建人)
Project.belongsTo(User, {
foreignKey: 'createdBy',
foreignKey: { name: 'createdBy', field: 'createdBy' },
as: 'creator',
targetKey: 'id'
});
@@ -112,7 +90,7 @@ User.hasMany(Project, {
// 项目与用户关联(更新人)
Project.belongsTo(User, {
foreignKey: 'updatedBy',
foreignKey: { name: 'updatedBy', field: 'updatedBy' },
as: 'updater',
targetKey: 'id'
});
@@ -218,41 +196,8 @@ User.hasMany(LoanProduct, {
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, {
@@ -278,29 +223,8 @@ User.hasMany(AuditRecord, {
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 = {