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
69366744
Commit
69366744
authored
Aug 18, 2020
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暴露 组织结构接口
parent
96858a96
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
33 deletions
+58
-33
center-manage/app/base/controller/impl/common/companyCtl.js
+39
-30
center-manage/app/base/db/impl/auth/userDao.js
+3
-0
center-manage/app/base/service/impl/common/companySve.js
+16
-3
No files found.
center-manage/app/base/controller/impl/common/companyCtl.js
View file @
69366744
...
@@ -7,60 +7,69 @@ const CtlBase = require("../../ctl.base");
...
@@ -7,60 +7,69 @@ const CtlBase = require("../../ctl.base");
class
CompanyCtl
extends
CtlBase
{
class
CompanyCtl
extends
CtlBase
{
constructor
()
{
constructor
()
{
super
(
"common"
,
CtlBase
.
getServiceName
(
CompanyCtl
));
super
(
"common"
,
CtlBase
.
getServiceName
(
CompanyCtl
));
this
.
userSve
=
system
.
getObject
(
"service.auth.userSve"
);
}
}
async
update
(
p
,
q
,
req
)
{
async
update
(
p
,
q
,
req
)
{
let
u
=
await
super
.
update
(
p
,
q
,
req
)
let
u
=
await
super
.
update
(
p
,
q
,
req
)
//缓存失效
//缓存失效
await
this
.
cacheManager
[
"CompanyCache"
].
invalidate
(
p
.
companykey
)
await
this
.
cacheManager
[
"CompanyCache"
].
invalidate
(
p
.
companykey
)
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
getMyApps
(
p
,
q
,
req
)
{
async
getMyApps
(
p
,
q
,
req
)
{
let
userfind
=
await
this
.
cacheManager
[
"UserCache"
].
cache
(
p
.
username
)
let
userfind
=
await
this
.
cacheManager
[
"UserCache"
].
cache
(
p
.
username
)
let
isSuper
=
userfind
.
isSuper
let
isSuper
=
userfind
.
isSuper
if
(
userfind
.
company
.
appids
&&
userfind
.
company
.
appids
!=
""
)
{
if
(
userfind
.
company
.
appids
&&
userfind
.
company
.
appids
!=
""
)
{
let
appsarray
=
userfind
.
company
.
appids
.
split
(
","
)
let
appsarray
=
userfind
.
company
.
appids
.
split
(
","
)
let
appidsquery
=
appsarray
.
map
(
astr
=>
{
let
appidsquery
=
appsarray
.
map
(
astr
=>
{
return
astr
.
split
(
"|"
)[
0
]
return
astr
.
split
(
"|"
)[
0
]
})
})
let
apps
=
await
this
.
service
.
getMyApps
(
appidsquery
,
isSuper
)
let
apps
=
await
this
.
service
.
getMyApps
(
appidsquery
,
isSuper
)
return
system
.
getResult
(
apps
)
return
system
.
getResult
(
apps
)
}
else
{
}
else
{
return
[]
return
[]
}
}
}
}
async
bindApps
(
p
,
q
,
req
)
{
async
bindApps
(
p
,
q
,
req
)
{
let
appids
=
p
.
appids
let
appids
=
p
.
appids
let
cmpid
=
p
.
postcmpid
let
cmpid
=
p
.
postcmpid
let
appids2
=
appids
.
map
(
item
=>
{
let
appids2
=
appids
.
map
(
item
=>
{
return
item
.
appid
+
"|"
+
item
.
title
return
item
.
appid
+
"|"
+
item
.
title
})
})
let
appidstrs
=
appids2
.
join
(
","
)
let
appidstrs
=
appids2
.
join
(
","
)
await
this
.
service
.
bindApps
(
appidstrs
,
cmpid
)
await
this
.
service
.
bindApps
(
appidstrs
,
cmpid
)
return
system
.
getResult
(
appids
)
return
system
.
getResult
(
appids
)
}
}
async
setOrgs
(
p
,
q
,
req
)
{
async
setOrgs
(
p
,
q
,
req
)
{
//let companynew=await this.service.findById(p.company_id)
//let companynew=await this.service.findById(p.company_id)
let
orgs
=
await
this
.
service
.
setOrgs
(
p
)
let
orgs
=
await
this
.
service
.
setOrgs
(
p
)
return
system
.
getResult
(
orgs
)
return
system
.
getResult
(
orgs
)
}
}
async
getOrgs
(
p
,
q
,
req
)
{
async
getOrgs
(
p
,
q
,
req
)
{
//let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey)
//let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey)
let
companynew
=
await
this
.
service
.
findById
(
p
.
company_id
)
let
companynew
=
await
this
.
service
.
findById
(
p
.
company_id
);
let
orgjsonstr
=
companynew
.
orgJson
const
userData
=
await
this
.
userSve
.
findById
(
p
.
userid
);
let
rtnjson
=
null
let
orgjsonstr
=
companynew
.
orgJson
;
if
(
orgjsonstr
&&
orgjsonstr
!=
""
){
let
rtnjson
=
null
;
rtnjson
=
JSON
.
parse
(
companynew
.
orgJson
)
if
(
orgjsonstr
&&
orgjsonstr
!=
""
)
{
}
else
{
rtnjson
=
JSON
.
parse
(
companynew
.
orgJson
);
rtnjson
=
[]
}
else
{
rtnjson
=
[];
}
if
(
userData
)
{
if
(
userData
.
isAdmin
||
userData
.
isSuper
)
{
return
system
.
getResult
({
orgJson
:
rtnjson
});
}
else
{
return
system
.
getResult
({
orgJson
:
this
.
service
.
buildOrgs
(
rtnjson
,
userData
.
ptags
)
});
}
}
else
{
return
system
.
getResult
({
orgJson
:
[]
});
}
}
return
system
.
getResult
({
orgJson
:
rtnjson
})
}
}
async
refQuery
(
pobj
,
qobj
,
req
)
{
async
refQuery
(
pobj
,
qobj
,
req
)
{
let
rtn
=
await
this
.
service
.
refQuery
(
pobj
);
let
rtn
=
await
this
.
service
.
refQuery
(
pobj
);
return
rtn
return
rtn
}
}
}
}
module
.
exports
=
CompanyCtl
;
module
.
exports
=
CompanyCtl
;
center-manage/app/base/db/impl/auth/userDao.js
View file @
69366744
...
@@ -101,6 +101,9 @@ class UserDao extends Dao {
...
@@ -101,6 +101,9 @@ class UserDao extends Dao {
w
[
strq
]
=
{
[
this
.
db
.
Op
.
like
]:
"%"
+
search
[
lnkKey
]
+
"%"
};
w
[
strq
]
=
{
[
this
.
db
.
Op
.
like
]:
"%"
+
search
[
lnkKey
]
+
"%"
};
}
}
qc
.
attributes
=
{
exclude
:
[
"password"
,
"jwtkey"
,
"jwtsecret"
]
}
return
w
;
return
w
;
}
}
async
preUpdate
(
u
)
{
async
preUpdate
(
u
)
{
...
...
center-manage/app/base/service/impl/common/companySve.js
View file @
69366744
...
@@ -5,7 +5,7 @@ class CompanyService extends ServiceBase {
...
@@ -5,7 +5,7 @@ class CompanyService extends ServiceBase {
constructor
()
{
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
CompanyService
));
super
(
"common"
,
ServiceBase
.
getDaoName
(
CompanyService
));
}
}
async
getMyApps
(
appids
,
isSuper
)
{
async
getMyApps
(
appids
,
isSuper
)
{
let
appsrtn
=
null
let
appsrtn
=
null
if
(
isSuper
)
{
if
(
isSuper
)
{
appsrtn
=
this
.
db
.
models
.
app
.
findAll
({
appsrtn
=
this
.
db
.
models
.
app
.
findAll
({
...
@@ -24,14 +24,14 @@ class CompanyService extends ServiceBase {
...
@@ -24,14 +24,14 @@ class CompanyService extends ServiceBase {
}
}
return
appsrtn
return
appsrtn
}
}
async
bindApps
(
appids
,
companyid
)
{
async
bindApps
(
appids
,
companyid
)
{
var
self
=
this
var
self
=
this
return
this
.
db
.
transaction
(
async
function
(
t
)
{
return
this
.
db
.
transaction
(
async
function
(
t
)
{
let
u
=
await
self
.
dao
.
update
({
appids
:
appids
,
id
:
companyid
},
t
)
let
u
=
await
self
.
dao
.
update
({
appids
:
appids
,
id
:
companyid
},
t
)
return
appids
return
appids
})
})
}
}
async
setOrgs
(
p
,
cmk
)
{
async
setOrgs
(
p
,
cmk
)
{
var
self
=
this
var
self
=
this
let
curNodeData
=
p
.
curdata
let
curNodeData
=
p
.
curdata
let
opathstr
=
curNodeData
.
orgpath
let
opathstr
=
curNodeData
.
orgpath
...
@@ -106,5 +106,18 @@ class CompanyService extends ServiceBase {
...
@@ -106,5 +106,18 @@ class CompanyService extends ServiceBase {
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
})
})
}
}
buildOrgs
(
rtnjson
,
code
)
{
if
(
rtnjson
.
length
>
0
)
{
for
(
let
val
of
rtnjson
)
{
if
(
val
.
code
===
code
)
{
return
[
val
]
}
else
{
return
this
.
buildOrgs
(
val
.
children
||
[],
code
)
}
}
}
else
{
return
rtnjson
}
}
}
}
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