明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
jt_backend
Commits
c4679568
Commit
c4679568
authored
Nov 19, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updae
parent
370c50af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
index.js
db/index.js
+6
-6
No files found.
db/index.js
View file @
c4679568
...
@@ -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'
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment