Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
07f9258c
Commit
07f9258c
authored
May 15, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
b3bda62f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
8 deletions
+45
-8
center-manage/app/base/controller/impl/common/companyCtl.js
+10
-0
center-manage/app/base/db/impl/common/connection.js
+7
-8
center-manage/app/base/service/impl/common/companySve.js
+28
-0
No files found.
center-manage/app/base/controller/impl/common/companyCtl.js
View file @
07f9258c
...
@@ -15,5 +15,15 @@ class CompanyCtl extends CtlBase {
...
@@ -15,5 +15,15 @@ class CompanyCtl extends CtlBase {
let
company
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
p
.
companykey
)
let
company
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
p
.
companykey
)
return
system
.
getResult
(
company
)
return
system
.
getResult
(
company
)
}
}
async
setOrgs
(
p
,
q
,
req
){
let
orgs
=
await
this
.
service
.
setOrgs
(
p
,
req
.
xctx
.
fromcompanykey
)
return
system
.
getResult
({
orgJson
:
JSON
.
parse
(
companynew
.
orgJson
)})
}
async
getOrgs
(
p
,
q
,
req
){
let
companynew
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
fromcompanykey
)
return
system
.
getResult
({
orgJson
:
JSON
.
parse
(
companynew
.
orgJson
)})
}
}
}
module
.
exports
=
CompanyCtl
;
module
.
exports
=
CompanyCtl
;
center-manage/app/base/db/impl/common/connection.js
View file @
07f9258c
...
@@ -28,22 +28,21 @@ class DbFactory{
...
@@ -28,22 +28,21 @@ class DbFactory{
}
}
async
initRelations
(){
async
initRelations
(){
this
.
db
.
models
.
dataauth
.
belongsTo
(
this
.
db
.
models
.
user
,{
constraints
:
false
,});
this
.
db
.
models
.
dataauth
.
belongsTo
(
this
.
db
.
models
.
user
,{
constraints
:
false
,});
/*建立用户和角色之间的关系*/
/*建立用户和角色之间的关系*/
this
.
db
.
models
.
user
.
belongsToMany
(
this
.
db
.
models
.
role
,
{
as
:
"Roles"
,
through
:
'p_userrole'
,
constraints
:
false
,});
this
.
db
.
models
.
user
.
belongsToMany
(
this
.
db
.
models
.
role
,
{
as
:
"Roles"
,
through
:
'p_userrole'
,
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsToMany
(
this
.
db
.
models
.
user
,
{
as
:
"Users"
,
through
:
'p_userrole'
,
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsToMany
(
this
.
db
.
models
.
user
,
{
as
:
"Users"
,
through
:
'p_userrole'
,
constraints
:
false
,});
/*组织机构自引用*/
/*组织机构自引用*/
this
.
db
.
models
.
org
.
belongsTo
(
this
.
db
.
models
.
org
,{
constraints
:
false
,});
//
this.db.models.org.belongsTo(this.db.models.org,{constraints: false,});
this
.
db
.
models
.
org
.
hasMany
(
this
.
db
.
models
.
org
,{
constraints
:
false
,});
//
this.db.models.org.hasMany(this.db.models.org,{constraints: false,});
//组织机构和角色是多对多关系,建立兼职岗位,给岗位赋予多个角色,从而同步修改用户的角色
//组织机构和角色是多对多关系,建立兼职岗位,给岗位赋予多个角色,从而同步修改用户的角色
//通过岗位接口去修改用户的角色
//通过岗位接口去修改用户的角色
this
.
db
.
models
.
role
.
belongsToMany
(
this
.
db
.
models
.
org
,{
through
:
this
.
db
.
models
.
orgrole
,
constraints
:
false
,});
//
this.db.models.role.belongsToMany(this.db.models.org,{through: this.db.models.orgrole,constraints: false,});
this
.
db
.
models
.
org
.
belongsToMany
(
this
.
db
.
models
.
role
,{
through
:
this
.
db
.
models
.
orgrole
,
constraints
:
false
,});
//
this.db.models.org.belongsToMany(this.db.models.role,{through: this.db.models.orgrole,constraints: false,});
//组织机构和用户是1对多,
//组织机构和用户是1对多,
this
.
db
.
models
.
user
.
belongsTo
(
this
.
db
.
models
.
org
,{
constraints
:
false
,});
//
this.db.models.user.belongsTo(this.db.models.org,{constraints: false,});
this
.
db
.
models
.
org
.
hasMany
(
this
.
db
.
models
.
user
,{
constraints
:
false
,});
//
this.db.models.org.hasMany(this.db.models.user,{constraints: false,});
this
.
db
.
models
.
user
.
belongsTo
(
this
.
db
.
models
.
app
,{
constraints
:
false
,});
this
.
db
.
models
.
user
.
belongsTo
(
this
.
db
.
models
.
app
,{
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsTo
(
this
.
db
.
models
.
app
,
{
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsTo
(
this
.
db
.
models
.
app
,
{
constraints
:
false
,});
...
@@ -58,7 +57,7 @@ class DbFactory{
...
@@ -58,7 +57,7 @@ class DbFactory{
this
.
db
.
models
.
user
.
belongsTo
(
this
.
db
.
models
.
company
,{
constraints
:
false
,});
this
.
db
.
models
.
user
.
belongsTo
(
this
.
db
.
models
.
company
,{
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsTo
(
this
.
db
.
models
.
company
,
{
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsTo
(
this
.
db
.
models
.
company
,
{
constraints
:
false
,});
this
.
db
.
models
.
org
.
belongsTo
(
this
.
db
.
models
.
company
,{
constraints
:
false
,});
//
this.db.models.org.belongsTo(this.db.models.company,{constraints: false,});
this
.
db
.
models
.
route
.
belongsTo
(
this
.
db
.
models
.
app
,{
constraints
:
false
,});
this
.
db
.
models
.
route
.
belongsTo
(
this
.
db
.
models
.
app
,{
constraints
:
false
,});
...
...
center-manage/app/base/service/impl/common/companySve.js
View file @
07f9258c
...
@@ -5,5 +5,33 @@ class CompanyService extends ServiceBase {
...
@@ -5,5 +5,33 @@ class CompanyService extends ServiceBase {
constructor
()
{
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
CompanyService
));
super
(
"common"
,
ServiceBase
.
getDaoName
(
CompanyService
));
}
}
async
setOrgs
(
p
,
cmk
)
{
var
self
=
this
return
this
.
db
.
transaction
(
async
function
(
t
)
{
let
strjson
=
JSON
.
stringify
(
p
.
orgJson
)
p
.
id
=
p
.
company_id
p
.
orgJson
=
strjson
//更新组织机构
let
u
=
await
self
.
dao
.
update
(
p
,
t
)
//更新,还得传输当前节点,查询出当前节点的角色
//按照当前节点的opath查询出所有的用户,更新这些用户的角色信息
let
curNodeData
=
p
.
curdata
if
(
curNodeData
&&
curNodeData
.
isPosition
){
let
opathstr
=
curNodeData
.
orgpath
let
users
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:{
opath
:
opathstr
},
transaction
:
t
})
//查询出角色
let
roleids
=
curNodeData
.
roles
var
roles
=
await
self
.
roleDao
.
model
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
roleids
},
app_id
:
p
.
app_id
,
company_id
:
p
.
company_id
},
transaction
:
t
});
users
.
forEach
((
u
)
=>
{
await
u
.
setRoles
(
roles
,
{
transaction
:
t
});
})
}
//用户缓存也要失效
//缓存失效
await
self
.
cacheManager
[
"CompanyCache"
].
invalidate
(
cmk
)
let
companynew
=
await
self
.
cacheManager
[
"CompanyCache"
].
cache
(
cmk
)
return
{
orgJson
:
JSON
.
parse
(
companynew
.
orgJson
)}
})
}
}
}
module
.
exports
=
CompanyService
;
module
.
exports
=
CompanyService
;
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