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
3b101b11
Commit
3b101b11
authored
Aug 21, 2020
by
王悦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add推送管理、组织结构监控
parent
ae750f27
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
144 additions
and
19 deletions
+144
-19
center-manage/app/base/controller/impl/common/companyCtl.js
+13
-3
center-manage/app/base/controller/impl/common/pushCtl.js
+71
-0
center-manage/app/base/service/impl/common/companySve.js
+53
-16
center-manage/app/config/settings.js
+7
-0
No files found.
center-manage/app/base/controller/impl/common/companyCtl.js
View file @
3b101b11
...
@@ -9,6 +9,7 @@ class CompanyCtl extends CtlBase {
...
@@ -9,6 +9,7 @@ class CompanyCtl extends CtlBase {
super
(
"common"
,
CtlBase
.
getServiceName
(
CompanyCtl
));
super
(
"common"
,
CtlBase
.
getServiceName
(
CompanyCtl
));
this
.
userSve
=
system
.
getObject
(
"service.auth.userSve"
);
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
)
//缓存失效
//缓存失效
...
@@ -16,6 +17,7 @@ class CompanyCtl extends CtlBase {
...
@@ -16,6 +17,7 @@ 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
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
...
@@ -30,6 +32,7 @@ class CompanyCtl extends CtlBase {
...
@@ -30,6 +32,7 @@ class CompanyCtl extends CtlBase {
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
...
@@ -40,11 +43,13 @@ class CompanyCtl extends CtlBase {
...
@@ -40,11 +43,13 @@ class CompanyCtl extends CtlBase {
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
);
...
@@ -58,13 +63,17 @@ class CompanyCtl extends CtlBase {
...
@@ -58,13 +63,17 @@ class CompanyCtl extends CtlBase {
}
}
if
(
userData
)
{
if
(
userData
)
{
if
(
userData
.
isAdmin
||
userData
.
isSuper
)
{
if
(
userData
.
isAdmin
||
userData
.
isSuper
)
{
return
system
.
getResult
({
orgJson
:
rtnjson
});
return
system
.
getResult
({
orgJson
:
rtnjson
});
}
else
{
}
else
{
return
system
.
getResult
({
orgJson
:
this
.
service
.
buildOrgs
(
rtnjson
,
userData
.
ptags
)
});
return
system
.
getResult
({
orgJson
:
this
.
service
.
buildOrgs
(
rtnjson
,
userData
.
ptags
)
});
}
}
}
else
{
}
else
{
return
system
.
getResult
({
orgJson
:
[]
});
return
system
.
getResult
({
orgJson
:
[]});
}
}
}
async
getWatchOrgNodes
(
p
,
q
,
req
)
{
return
await
this
.
service
.
getWatchOrgNodes
(
p
.
company_id
);
}
}
async
refQuery
(
pobj
,
qobj
,
req
)
{
async
refQuery
(
pobj
,
qobj
,
req
)
{
...
@@ -72,4 +81,5 @@ class CompanyCtl extends CtlBase {
...
@@ -72,4 +81,5 @@ class CompanyCtl extends CtlBase {
return
rtn
return
rtn
}
}
}
}
module
.
exports
=
CompanyCtl
;
module
.
exports
=
CompanyCtl
;
center-manage/app/base/controller/impl/common/pushCtl.js
0 → 100644
View file @
3b101b11
var
system
=
require
(
"../../../system"
)
const
http
=
require
(
"http"
)
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
class
PushCtl
extends
CtlBase
{
constructor
()
{
super
(
"common"
,
CtlBase
.
getServiceName
(
PushCtl
));
}
async
findAndCountAll
(
pobj
,
qobj
,
req
)
{
let
query
=
{
pageSize
:
pobj
.
pageInfo
.
pageSize
,
pageIndex
:
pobj
.
pageInfo
.
pageNo
};
if
(
pobj
.
messageBody
)
query
.
messageBody
=
pobj
.
messageBody
;
if
(
pobj
.
identify_code
)
query
.
identifyCode
=
pobj
.
identify_code
;
if
(
pobj
.
request_id
)
query
.
requestIdInfo
=
pobj
.
request_id
;
let
actionType
;
switch
(
pobj
.
bizpath
)
{
case
"/sysmag/pushfail"
:
actionType
=
"getPushFailureList"
;
break
;
case
"/sysmag/pusherror"
:
actionType
=
"getPushErrorList"
;
break
}
let
rtn
=
await
system
.
postJsonTypeReq
(
settings
.
pushUrl
(),
{
"actionType"
:
actionType
,
"actionBody"
:
query
});
if
(
rtn
.
statusCode
===
200
)
{
rtn
=
rtn
.
data
;
if
(
rtn
&&
rtn
.
status
===
1
)
{
return
system
.
getResult
({
results
:
{
count
:
rtn
.
totalCount
,
rows
:
rtn
&&
rtn
.
data
||
[]
}
});
}
else
{
return
system
.
getResultFail
(
rtn
&&
rtn
.
message
||
'请联系管理员'
);
}
}
else
{
return
system
.
getResultFail
(
rtn
)
}
}
async
repush
(
pobj
,
qobj
,
req
)
{
let
rtn
=
await
system
.
postJsonTypeReq
(
settings
.
pushUrl
(),
{
"actionType"
:
"pushAgainFailureLog"
,
"actionBody"
:
{
id
:
pobj
.
id
}
});
if
(
rtn
.
statusCode
===
200
)
{
return
rtn
.
data
;
}
else
{
return
system
.
getResultFail
(
rtn
)
}
}
}
module
.
exports
=
PushCtl
;
center-manage/app/base/service/impl/common/companySve.js
View file @
3b101b11
const
system
=
require
(
"../../../system"
);
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
settings
=
require
(
"../../../../config/settings"
);
class
CompanyService
extends
ServiceBase
{
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
({
where
:
where
:
{
{
id
:
{
[
this
.
db
.
Op
.
ne
]:
settings
.
pmappid
}
id
:
{[
this
.
db
.
Op
.
ne
]:
settings
.
pmappid
}
}
}
})
})
}
else
{
}
else
{
appsrtn
=
this
.
db
.
models
.
app
.
findAll
({
appsrtn
=
this
.
db
.
models
.
app
.
findAll
({
where
:
where
:
{
{
id
:
{
[
this
.
db
.
Op
.
in
]:
appids
}
id
:
{[
this
.
db
.
Op
.
in
]:
appids
}
}
}
})
})
}
}
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
})
})
}
}
buildNoPositionNode
(
treejson
,
rtnArray
)
{
treejson
.
forEach
((
n
)
=>
{
if
(
n
.
children
)
{
this
.
buildNoPositionNode
(
n
.
children
,
rtnArray
)
}
if
(
n
.
hasOwnProperty
(
"isPosition"
)
&&
!
n
.
isPosition
)
{
rtnArray
.
push
(
n
)
}
})
}
async
getWatchOrgNodes
(
cmid
)
{
let
rtn
=
[]
let
companynew
=
await
this
.
findById
(
cmid
)
let
orgjsonstr
=
companynew
.
orgJson
if
(
orgjsonstr
&&
orgjsonstr
!=
""
)
{
let
treejson
=
JSON
.
parse
(
companynew
.
orgJson
)
this
.
buildNoPositionNode
(
treejson
,
rtn
)
}
return
rtn
}
async
setOrgs
(
p
,
cmk
)
{
async
setOrgs
(
p
,
cmk
)
{
var
self
=
this
var
self
=
this
let
curNodeData
=
p
.
curdata
let
curNodeData
=
p
.
curdata
...
@@ -42,14 +68,14 @@ class CompanyService extends ServiceBase {
...
@@ -42,14 +68,14 @@ class CompanyService extends ServiceBase {
let
oldopath
=
''
let
oldopath
=
''
if
(
!
oldNodeData
)
{
//如果不传老对象,表示当前操作是删除节点操作,检查是否存在用户,如果已经存在
if
(
!
oldNodeData
)
{
//如果不传老对象,表示当前操作是删除节点操作,检查是否存在用户,如果已经存在
//那么就提示不能删除
//那么就提示不能删除
let
us
=
await
self
.
db
.
models
.
user
.
findOne
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
opathstr
}
%`
}
}
})
let
us
=
await
self
.
db
.
models
.
user
.
findOne
({
where
:
{
opath
:
{[
self
.
db
.
Op
.
like
]:
`%
${
opathstr
}
%`
}}
})
if
(
us
)
{
if
(
us
)
{
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}
});
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}
});
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
}
else
{
}
else
{
let
u
=
await
this
.
dao
.
update
(
p
)
let
u
=
await
this
.
dao
.
update
(
p
)
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}
});
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}
});
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
}
}
}
else
{
}
else
{
oldopath
=
oldNodeData
.
orgpath
==
''
?
'123456'
:
oldNodeData
.
orgpath
oldopath
=
oldNodeData
.
orgpath
==
''
?
'123456'
:
oldNodeData
.
orgpath
...
@@ -63,7 +89,10 @@ class CompanyService extends ServiceBase {
...
@@ -63,7 +89,10 @@ class CompanyService extends ServiceBase {
if
(
curNodeData
)
{
if
(
curNodeData
)
{
if
(
curNodeData
.
isPosition
)
{
if
(
curNodeData
.
isPosition
)
{
let
us
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
oldopath
}
%`
}
},
transaction
:
t
})
let
us
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:
{
opath
:
{[
self
.
db
.
Op
.
like
]:
`%
${
oldopath
}
%`
}},
transaction
:
t
})
//查询出角色
//查询出角色
let
roleids
=
curNodeData
.
roles
let
roleids
=
curNodeData
.
roles
// let rs=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:roleids},app_id:p.app_id,company_id:p.company_id},transaction:t})
// let rs=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:roleids},app_id:p.app_id,company_id:p.company_id},transaction:t})
...
@@ -74,13 +103,16 @@ class CompanyService extends ServiceBase {
...
@@ -74,13 +103,16 @@ class CompanyService extends ServiceBase {
roleids
.
push
(
settings
.
pmroleid
[
"pr"
])
roleids
.
push
(
settings
.
pmroleid
[
"pr"
])
}
}
}
}
let
rs
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
roleids
}
},
transaction
:
t
})
let
rs
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{[
self
.
db
.
Op
.
in
]:
roleids
}},
transaction
:
t
})
for
(
let
u
of
us
)
{
for
(
let
u
of
us
)
{
await
u
.
setRoles
(
rs
,
{
transaction
:
t
})
await
u
.
setRoles
(
rs
,
{
transaction
:
t
})
//if (opathstr != oldopath) {
//if (opathstr != oldopath) {
u
.
opath
=
opathstr
+
"/"
+
u
.
userName
u
.
opath
=
opathstr
+
"/"
+
u
.
userName
u
.
ptags
=
curNodeData
.
ptags
u
.
ptags
=
curNodeData
.
ptags
u
.
save
({
transaction
:
t
})
u
.
save
({
transaction
:
t
})
// }
// }
//令用户缓存失效
//令用户缓存失效
await
self
.
cacheManager
[
"UserCache"
].
invalidate
(
u
.
userName
)
await
self
.
cacheManager
[
"UserCache"
].
invalidate
(
u
.
userName
)
...
@@ -88,12 +120,15 @@ class CompanyService extends ServiceBase {
...
@@ -88,12 +120,15 @@ class CompanyService extends ServiceBase {
}
else
{
//不是岗位节点,检查修改后的路径是否和原始一致,如果不一致,那么需要查出原始的用户数据
}
else
{
//不是岗位节点,检查修改后的路径是否和原始一致,如果不一致,那么需要查出原始的用户数据
//把原来的路径替换当前新的code
//把原来的路径替换当前新的code
if
(
opathstr
!=
oldopath
)
{
if
(
opathstr
!=
oldopath
)
{
let
us2
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
oldopath
}
%`
}
},
transaction
:
t
})
let
us2
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:
{
opath
:
{[
self
.
db
.
Op
.
like
]:
`%
${
oldopath
}
%`
}},
transaction
:
t
})
for
(
let
u
of
us2
)
{
for
(
let
u
of
us2
)
{
let
curpath
=
u
.
opath
let
curpath
=
u
.
opath
let
newpath
=
curpath
.
replace
(
oldNodeData
.
code
,
curNodeData
.
code
)
let
newpath
=
curpath
.
replace
(
oldNodeData
.
code
,
curNodeData
.
code
)
u
.
opath
=
newpath
u
.
opath
=
newpath
u
.
save
({
transaction
:
t
})
u
.
save
({
transaction
:
t
})
//令用户缓存失效
//令用户缓存失效
await
self
.
cacheManager
[
"UserCache"
].
invalidate
(
u
.
userName
)
await
self
.
cacheManager
[
"UserCache"
].
invalidate
(
u
.
userName
)
}
}
...
@@ -102,10 +137,11 @@ class CompanyService extends ServiceBase {
...
@@ -102,10 +137,11 @@ class CompanyService extends ServiceBase {
}
}
}
}
let
companytmp
=
await
self
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
},
transaction
:
t
});
let
companytmp
=
await
self
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
},
transaction
:
t
});
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
})
})
}
}
buildOrgs
(
rtnjson
,
code
)
{
buildOrgs
(
rtnjson
,
code
)
{
if
(
rtnjson
.
length
>
0
)
{
if
(
rtnjson
.
length
>
0
)
{
for
(
let
val
of
rtnjson
)
{
for
(
let
val
of
rtnjson
)
{
...
@@ -120,4 +156,5 @@ class CompanyService extends ServiceBase {
...
@@ -120,4 +156,5 @@ class CompanyService extends ServiceBase {
}
}
}
}
}
}
module
.
exports
=
CompanyService
;
module
.
exports
=
CompanyService
;
center-manage/app/config/settings.js
View file @
3b101b11
...
@@ -53,6 +53,13 @@ var settings = {
...
@@ -53,6 +53,13 @@ var settings = {
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
}
}
},
},
pushUrl
:
function
()
{
if
(
this
.
env
==
"localhost"
)
{
return
"http://192.168.1.128:4018/api/queueAction/producer/springBoard"
;
}
else
{
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
}
},
pmappname
:
"center-app"
,
pmappname
:
"center-app"
,
pmappid
:
1
,
pmappid
:
1
,
pmcompanyid
:
1
,
pmcompanyid
:
1
,
...
...
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