明树Git Lab

Commit c4679568 authored by zfp1's avatar zfp1

updae

parent 370c50af
......@@ -59,17 +59,17 @@ global.DB = {
/**
* 关联关系定义
*/
/**用户-请求日志 1:n */
User.hasMany(RequestLog, { foreignKey: 'userId' });
RequestLog.belongsTo(User, { foreignKey: 'userId' });
/**用户-角色 n:n */
User.belongsToMany(Role, {
through: 'system_user_role', // 中间表名
foreignKey: 'userId', // 用户ID外键
otherKey: 'roleId', // 角色ID外键
as: 'roles',
});
Role.belongsToMany(User, {
through: 'system_user_role',
foreignKey: 'roleId',
......@@ -77,26 +77,26 @@ Role.belongsToMany(User, {
as: 'users'
});
/**角色-菜单 n:n */
Role.belongsToMany(Menu, {
through: 'system_role_menu',
foreignKey: 'roleId',
otherKey: 'menuId',
as: 'menus'
});
Menu.belongsToMany(Role, {
through: 'system_role_menu',
foreignKey: 'menuId',
otherKey: 'roleId'
});
/**用户-部门 n:n */
User.belongsToMany(Depart, {
through: 'system_user_depart', // 中间表名
foreignKey: 'userId', // 用户ID外键
otherKey: 'departId', // 角色ID外键
as: 'departs',
});
Depart.belongsToMany(User, {
through: 'system_user_depart',
foreignKey: 'departId',
......@@ -104,6 +104,7 @@ Depart.belongsToMany(User, {
as: 'users'
});
/**用户-职位 n:n */
User.belongsToMany(Position, {
through: 'system_user_position', // 中间表名
foreignKey: 'userId', // 用户ID外键
......@@ -118,9 +119,8 @@ Position.belongsToMany(User, {
as: 'users'
});
/**项目-资源信息 1:n */
Resources.hasMany(ResourcesInfo, { foreignKey: 'resourceId', as: 'resourcesInfos' });
ResourcesInfo.belongsTo(Resources, { foreignKey: 'resourceId' });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment