明树Git Lab

Commit c4679568 authored by zfp1's avatar zfp1

updae

parent 370c50af
...@@ -59,17 +59,17 @@ global.DB = { ...@@ -59,17 +59,17 @@ global.DB = {
/** /**
* 关联关系定义 * 关联关系定义
*/ */
/**用户-请求日志 1:n */
User.hasMany(RequestLog, { foreignKey: 'userId' }); User.hasMany(RequestLog, { foreignKey: 'userId' });
RequestLog.belongsTo(User, { foreignKey: 'userId' }); RequestLog.belongsTo(User, { foreignKey: 'userId' });
/**用户-角色 n:n */
User.belongsToMany(Role, { User.belongsToMany(Role, {
through: 'system_user_role', // 中间表名 through: 'system_user_role', // 中间表名
foreignKey: 'userId', // 用户ID外键 foreignKey: 'userId', // 用户ID外键
otherKey: 'roleId', // 角色ID外键 otherKey: 'roleId', // 角色ID外键
as: 'roles', as: 'roles',
}); });
Role.belongsToMany(User, { Role.belongsToMany(User, {
through: 'system_user_role', through: 'system_user_role',
foreignKey: 'roleId', foreignKey: 'roleId',
...@@ -77,26 +77,26 @@ Role.belongsToMany(User, { ...@@ -77,26 +77,26 @@ Role.belongsToMany(User, {
as: 'users' as: 'users'
}); });
/**角色-菜单 n:n */
Role.belongsToMany(Menu, { Role.belongsToMany(Menu, {
through: 'system_role_menu', through: 'system_role_menu',
foreignKey: 'roleId', foreignKey: 'roleId',
otherKey: 'menuId', otherKey: 'menuId',
as: 'menus' as: 'menus'
}); });
Menu.belongsToMany(Role, { Menu.belongsToMany(Role, {
through: 'system_role_menu', through: 'system_role_menu',
foreignKey: 'menuId', foreignKey: 'menuId',
otherKey: 'roleId' otherKey: 'roleId'
}); });
/**用户-部门 n:n */
User.belongsToMany(Depart, { User.belongsToMany(Depart, {
through: 'system_user_depart', // 中间表名 through: 'system_user_depart', // 中间表名
foreignKey: 'userId', // 用户ID外键 foreignKey: 'userId', // 用户ID外键
otherKey: 'departId', // 角色ID外键 otherKey: 'departId', // 角色ID外键
as: 'departs', as: 'departs',
}); });
Depart.belongsToMany(User, { Depart.belongsToMany(User, {
through: 'system_user_depart', through: 'system_user_depart',
foreignKey: 'departId', foreignKey: 'departId',
...@@ -104,6 +104,7 @@ Depart.belongsToMany(User, { ...@@ -104,6 +104,7 @@ Depart.belongsToMany(User, {
as: 'users' as: 'users'
}); });
/**用户-职位 n:n */
User.belongsToMany(Position, { User.belongsToMany(Position, {
through: 'system_user_position', // 中间表名 through: 'system_user_position', // 中间表名
foreignKey: 'userId', // 用户ID外键 foreignKey: 'userId', // 用户ID外键
...@@ -118,9 +119,8 @@ Position.belongsToMany(User, { ...@@ -118,9 +119,8 @@ Position.belongsToMany(User, {
as: 'users' as: 'users'
}); });
/**项目-资源信息 1:n */
Resources.hasMany(ResourcesInfo, { foreignKey: 'resourceId', as: 'resourcesInfos' }); Resources.hasMany(ResourcesInfo, { foreignKey: 'resourceId', as: 'resourcesInfos' });
ResourcesInfo.belongsTo(Resources, { foreignKey: 'resourceId' }); 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