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
c1aaceed
Commit
c1aaceed
authored
Apr 27, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
c1675293
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
520 deletions
+48
-520
center-manage/app/base/api/api.base.js
+35
-10
center-manage/app/base/api/impl/meta/oss.js
+2
-1
center-manage/app/base/controller/impl/common/metaCtl.js
+0
-506
center-manage/app/base/db/initData.js
+1
-1
center-manage/app/base/db/models/auth/user.js
+4
-0
center-manage/app/base/service/impl/auth/userSve.js
+5
-1
center-manage/app/base/system.js
+1
-1
No files found.
center-manage/app/base/api/api.base.js
View file @
c1aaceed
...
...
@@ -5,19 +5,44 @@ class APIBase{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
async
setContextParams
(
pobj
,
qobj
,
req
)
{
let
custtags
=
req
.
headers
[
"x-consumetag"
]?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
):
null
;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req
.
xctx
=
{
appkey
:
req
.
headers
[
"xappkey"
],
//用于系统管理区分应用,比如角色
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]:
null
,
password
:
custtags
?
custtags
[
1
].
split
(
"_"
)[
1
]:
null
,
username
:
req
.
headers
[
"x-consumer-username"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
}
if
(
!
req
.
xctx
.
appkey
){
return
[
-
200
,
"请求头缺少应用x-app-key"
]
}
else
{
let
app
=
await
this
.
cacheManager
[
"AppCache"
].
cache
(
req
.
xctx
.
appkey
);
req
.
xctx
.
appid
=
app
.
id
;
pobj
.
app_id
=
app
.
id
;
//传递参数对象里注入app_id
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
companykey
){
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
companykey
);
req
.
xctx
.
companyid
=
comptmp
.
id
;
}
if
(
req
.
xctx
.
companyid
){
//在请求传递数据对象注入公司id
pobj
.
company_id
=
req
.
xctx
.
companyid
;
}
}
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
console
.
log
(
"**********************************************"
)
console
.
log
(
req
.
headers
)
let
custtags
=
req
.
headers
[
"x-consumetag"
].
split
(
"|"
);
req
.
xctx
=
{
appkey
:
req
.
headers
[
"x-app-key"
],
companyid
:
custtags
[
0
].
split
(
"_"
)[
1
],
password
:
custtags
[
1
].
split
(
"_"
)[
1
],
username
:
req
.
headers
[
"x-consumer-username"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
companykey
:
req
.
headers
[
"x-company-key"
],
//这个头没有必要,因为来访companyid有值了
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
if
(
xarg
&&
xarg
[
0
]
<
0
){
return
system
.
getResultFail
(...
xarg
);
}
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
return
rtn
;
}
catch
(
e
)
{
...
...
center-manage/app/base/api/impl/meta/oss.js
View file @
c1aaceed
...
...
@@ -8,6 +8,7 @@ var accessKeyId='LTAIyAUK8AD04P5S';
var
url
=
"https://gsb-zc.oss-cn-beijing.aliyuncs.com"
;
class
OSSAPI
extends
APIBase
{
constructor
(){
super
()
}
async
getOssConfig
(){
var
policyText
=
{
...
...
@@ -30,7 +31,7 @@ class OSSAPI extends APIBase{
url
:
url
};
return
data
;
return
system
.
getResult
(
data
)
;
};
async
upfile
(
srckey
,
dest
){
var
oss
=
System
.
getObject
(
"util.ossClient"
);
...
...
center-manage/app/base/controller/impl/common/metaCtl.js
View file @
c1aaceed
...
...
@@ -5,512 +5,6 @@ var cacheBaseComp = null;
class
MetaCtl
extends
CtlBase
{
constructor
()
{
super
(
"common"
,
CtlBase
.
getServiceName
(
MetaCtl
));
this
.
userS
=
system
.
getObject
(
"service.auth.userSve"
);
this
.
authS
=
system
.
getObject
(
"service.auth.authSve"
);
}
async
getApiDoc
(
pobj
,
queryObj
,
req
)
{
var
appid
=
pobj
.
appid
;
var
docUrl
=
pobj
.
doc
;
if
(
appid
==
settings
.
platformid
)
{
var
result
=
await
this
.
service
.
getApiDoc
(
appid
);
return
system
.
getResult
(
result
);
}
else
{
var
result
=
await
this
.
service
.
getApiDocRemote
(
appid
,
docUrl
);
return
system
.
getResult
(
result
);
}
return
system
.
getResultFail
();
}
//根据查询参数来确定当前会话对应的应用
async
getAppInfo
(
req
)
{
var
appkey
=
req
.
query
.
appKey
;
var
companyKey
=
req
.
query
.
companyKey
;
if
(
!
appkey
)
{
appkey
=
settings
.
appKey
;
//为了查询权限
req
.
tocompanyid
=
settings
.
platformcompanyid
;
}
var
app
=
await
this
.
appS
.
getApp
(
appkey
);
var
rs
=
await
this
.
getRsConfig2
(
null
,
req
);
var
company
=
req
.
session
.
company
?
req
.
session
.
company
:
null
;
var
tocompany
=
req
.
session
.
tocompany
?
req
.
session
.
tocompany
:
null
;
if
(
!
tocompany
&&
companyKey
){
//说明自主登录或注册
tocompany
=
await
this
.
comS
.
findOne
({
companykey
:
companyKey
});
req
.
session
.
tocompany
=
tocompany
;
}
var
companystr
=
company
?
escape
(
JSON
.
stringify
(
company
)):
escape
(
JSON
.
stringify
({
status
:
-
1
}));
var
tocompanystr
=
tocompany
?
escape
(
JSON
.
stringify
(
tocompany
)):
escape
(
JSON
.
stringify
({
status
:
-
1
}));
var
rtn
=
{
"appinfo"
:
escape
(
JSON
.
stringify
(
app
)),
"rsconfig"
:
escape
(
JSON
.
stringify
(
rs
)),
"basecom"
:
this
.
getBaseComp
(),
"app"
:
app
,
"company"
:
companystr
,
"tocompany"
:
tocompanystr
};
req
.
session
.
app
=
app
;
return
rtn
;
}
getBaseComp
()
{
// if (cacheBaseComp) {
// return cacheBaseComp;
// }
var
glob
=
require
(
"glob"
);
var
vuePath
=
settings
.
basepath
+
"/app/front/vues/base"
;
var
baseComps
=
[];
var
rs
=
glob
.
sync
(
vuePath
+
"/**/*.vue"
);
if
(
rs
)
{
rs
.
forEach
(
function
(
r
)
{
var
comp
=
""
;
if
(
settings
.
env
==
"dev"
)
{
delete
require
.
cache
[
r
];
comp
=
require
(
r
).
replace
(
/
\n
/g
,
""
);
}
else
{
comp
=
require
(
r
).
replace
(
/
\n
/g
,
""
);
}
baseComps
.
push
(
comp
);
});
}
cacheBaseComp
=
escape
(
JSON
.
stringify
(
baseComps
));
return
cacheBaseComp
;
}
//权限 角色+资源节点code+权限字符串,codepath--
async
getUiConfig
(
pobj
,
queryObj
,
req
)
{
var
bizCode
=
queryObj
.
biz
;
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
console
.
log
(
cfg
);
var
tmpRoleAuthStr
=
""
;
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
var
tmpRoles
=
[];
if
(
req
.
session
.
user
.
Roles
)
{
req
.
session
.
user
.
Roles
.
forEach
(
r
=>
{
tmpRoles
.
push
(
r
.
code
);
});
//按照角色获取权限列表
var
auths
=
await
this
.
authS
.
findAuthsByRole
(
tmpRoles
,
req
.
session
.
user
.
app_id
,
req
.
tocompanyid
);
var
codeauthattrs
=
auths
.
map
(
r
=>
{
if
(
r
.
authstrs
&&
r
.
authstrs
!=
""
)
{
return
r
.
authstrs
;
}
else
{
return
""
;
}
});
tmpRoleAuthStr
=
codeauthattrs
.
join
(
","
);
}
}
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
var
toolbar
=
[];
const
bizConfigData
=
cfg
.
config
[
"bizs"
][
bizCode
];
console
.
log
(
bizCode
);
Object
.
keys
(
bizConfigData
.
config
.
auth
).
map
(
k
=>
{
//只要有权限就添加
if
(
req
.
session
.
user
&&
req
.
session
.
user
.
isAdmin
)
{
toolbar
=
toolbar
.
concat
(
bizConfigData
.
config
.
auth
[
k
]);
}
else
{
if
(
tmpRoleAuthStr
.
indexOf
(
k
)
>=
0
)
{
toolbar
=
toolbar
.
concat
(
bizConfigData
.
config
.
auth
[
k
]);
}
}
})
bizConfigData
.
config
.
toolbar
=
toolbar
;
return
system
.
getResult
(
bizConfigData
.
config
);
}
async
getDicConfig
(
pobj
,
queryObj
,
req
)
{
var
dicKey
=
queryObj
[
"dicKey"
];
if
(
req
.
appid
==
settings
.
platformid
||
(
dicKey
!=
"configType"
&&
dicKey
!=
"data_priv"
))
{
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
if
(
dicKey
==
"data_priv"
)
{
if
(
req
.
session
&&
req
.
session
.
user
&&
!
req
.
session
.
user
.
isSuper
)
{
delete
cfg
.
config
[
"pdict"
][
dicKey
][
"company"
];
}
}
return
system
.
getResult
(
cfg
.
config
[
"pdict"
][
dicKey
]);
}
else
{
if
(
dicKey
==
"configType"
||
dicKey
==
"data_priv"
)
{
//跨应用调用,先获取访问token,然后访问远程应用,去获取远程应用的配置项
var
app
=
req
.
session
.
app
;
var
uiconfigUrl
=
app
.
uiconfigUrl
;
var
cfg
=
await
this
.
service
.
getRemoteUiConfig
(
req
.
appkey
,
uiconfigUrl
);
return
system
.
getResult
(
cfg
.
config
[
"pdict"
][
dicKey
]);
}
}
}
async
findSubSystems
(
p
,
q
,
req
)
{
var
rtnSubs
=
[];
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
var
tmpRoleCodepathStr
=
[];
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
var
tmpRoles
=
[];
if
(
req
.
session
.
user
.
Roles
)
{
req
.
session
.
user
.
Roles
.
forEach
(
r
=>
{
tmpRoles
.
push
(
r
.
code
);
});
//按照角色获取权限列表
var
auths
=
await
this
.
authS
.
findAuthsByRole
(
tmpRoles
,
req
.
session
.
user
.
app_id
,
req
.
tocompanyid
);
var
codepathattrs
=
auths
.
map
(
r
=>
{
if
(
r
.
authstrs
&&
r
.
authstrs
!=
""
)
{
if
(
r
.
codepath
)
{
var
cparr
=
r
.
codepath
.
split
(
"/"
);
for
(
var
c
of
cparr
)
{
tmpRoleCodepathStr
.
push
(
c
);
}
}
return
r
.
codepath
;
}
else
{
return
""
;
}
});
for
(
var
i
=
0
;
i
<
cfg
.
config
[
"rstree"
].
children
.
length
;
i
++
)
{
var
r
=
cfg
.
config
[
"rstree"
].
children
[
i
];
if
(
r
.
isSubmenu
)
{
if
(
tmpRoleCodepathStr
.
indexOf
(
r
.
code
)
>=
0
)
{
rtnSubs
.
push
({
subcode
:
r
.
code
,
subtitle
:
r
.
label
});
}
else
{
if
(
req
.
session
.
user
.
isAdmin
)
{
if
(
r
.
code
.
indexOf
(
"pmg"
)
<
0
&&
r
.
code
.
indexOf
(
"tanent"
)
<
0
)
{
rtnSubs
.
push
({
subcode
:
r
.
code
,
subtitle
:
r
.
label
});
}
else
{
if
(
req
.
session
.
user
.
isSuper
)
{
rtnSubs
.
push
({
subcode
:
r
.
code
,
subtitle
:
r
.
label
});
}
}
}
}
}
}
}
}
return
system
.
getResult
(
rtnSubs
);
}
async
getRsConfig2
(
q
,
req
)
{
var
rs2
=
[];
console
.
log
(
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
);
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
console
.
log
(
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
);
var
tmpRoleCodepathStr
=
[];
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
var
tmpRoles
=
[];
if
(
req
.
session
.
user
.
Roles
)
{
req
.
session
.
user
.
Roles
.
forEach
(
r
=>
{
tmpRoles
.
push
(
r
.
code
);
});
//按照角色获取权限列表
var
auths
=
await
this
.
authS
.
findAuthsByRole
(
tmpRoles
,
req
.
session
.
user
.
app_id
,
req
.
tocompanyid
);
var
codepathattrs
=
auths
.
map
(
r
=>
{
if
(
r
.
authstrs
&&
r
.
authstrs
!=
""
)
{
if
(
r
.
codepath
)
{
var
cparr
=
r
.
codepath
.
split
(
"/"
);
for
(
var
c
of
cparr
)
{
tmpRoleCodepathStr
.
push
(
c
);
}
}
return
r
.
codepath
;
}
else
{
return
""
;
}
});
}
}
console
.
log
(
".....................获取当前登录人的角色,进而获取权限,进而合并工具栏目.getRsConfig"
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
for
(
var
i
=
0
;
i
<
cfg
.
config
[
"rstree"
].
children
.
length
;
i
++
)
{
var
r
=
cfg
.
config
[
"rstree"
].
children
[
i
];
console
.
log
(
r
.
code
);
var
funcrange
=
function
(
n
)
{
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
if
(
req
.
session
.
user
.
isAdmin
||
req
.
session
.
user
.
isSuper
)
{
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
<
0
&&
req
.
session
.
user
.
isAdmin
)
{
n
.
hidden
=
false
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
>=
0
&&
req
.
session
.
user
.
isAdmin
)
{
n
.
hidden
=
true
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
>=
0
&&
req
.
session
.
user
.
isSuper
)
{
console
.
log
(
"isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper"
);
n
.
hidden
=
false
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
<
0
&&
req
.
session
.
user
.
isSuper
&&
!
req
.
session
.
user
.
isAdmin
)
{
console
.
log
(
"isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper"
);
n
.
hidden
=
true
;
}
}
else
{
if
(
tmpRoleCodepathStr
.
indexOf
(
n
.
code
)
<
0
)
{
if
(
n
.
isctl
&&
n
.
isctl
==
"no"
)
{
n
.
hidden
=
false
;
console
.
log
(
n
.
code
,
"no ctl"
,
"show menu"
);
}
else
{
n
.
hidden
=
true
;
console
.
log
(
n
.
code
,
"no authed"
,
"hide menu"
);
}
}
else
{
n
.
hidden
=
false
;
console
.
log
(
n
.
code
,
"authed......"
,
"show menu"
);
}
}
}
if
(
n
.
children
)
{
n
.
children
.
forEach
((
dd
)
=>
{
return
funcrange
(
dd
);
});
}
else
{
if
(
n
.
isctl
&&
n
.
isctl
==
"no"
)
{
n
.
hidden
=
false
;
}
return
;
}
};
funcrange
(
r
);
}
return
(
cfg
.
config
[
"rstree"
]);
}
async
getAppRsConfig
(
p
,
q
,
req
)
{
var
rs2
=
[];
var
cfg
=
null
;
if
(
req
.
appid
==
settings
.
platformid
)
{
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
}
else
{
var
app
=
req
.
session
.
app
;
var
uiconfigUrl
=
app
.
uiconfigUrl
;
var
cfg
=
await
this
.
service
.
getRemoteUiConfig
(
req
.
appkey
,
uiconfigUrl
);
}
console
.
log
(
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
);
var
tmpRoleCodepathStr
=
[];
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
var
tmpRoles
=
[];
if
(
req
.
session
.
user
.
Roles
)
{
req
.
session
.
user
.
Roles
.
forEach
(
r
=>
{
tmpRoles
.
push
(
r
.
code
);
});
//按照角色获取权限列表
var
auths
=
await
this
.
authS
.
findAuthsByRole
(
tmpRoles
,
req
.
session
.
user
.
app_id
);
var
codepathattrs
=
auths
.
map
(
r
=>
{
if
(
r
.
authstrs
&&
r
.
authstrs
!=
""
)
{
if
(
r
.
codepath
)
{
var
cparr
=
r
.
codepath
.
split
(
"/"
);
for
(
var
c
of
cparr
)
{
tmpRoleCodepathStr
.
push
(
c
);
}
}
return
r
.
codepath
;
}
else
{
return
""
;
}
});
}
}
console
.
log
(
".....................获取当前登录人的角色,进而获取权限,进而合并工具栏目.getRsConfig"
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
for
(
var
i
=
0
;
i
<
cfg
.
config
[
"rstree"
].
children
.
length
;
i
++
)
{
var
r
=
cfg
.
config
[
"rstree"
].
children
[
i
];
console
.
log
(
r
.
code
);
var
funcrange
=
function
(
n
)
{
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
if
(
req
.
session
.
user
.
isAdmin
||
req
.
session
.
user
.
isSuper
)
{
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
<
0
&&
req
.
session
.
user
.
isAdmin
)
{
n
.
hidden
=
false
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
>=
0
&&
req
.
session
.
user
.
isAdmin
)
{
n
.
hidden
=
true
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
>=
0
&&
req
.
session
.
user
.
isSuper
)
{
console
.
log
(
"isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper"
);
n
.
hidden
=
false
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
<
0
&&
req
.
session
.
user
.
isSuper
&&
!
req
.
session
.
user
.
isAdmin
)
{
console
.
log
(
"isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper"
);
n
.
hidden
=
true
;
}
}
else
{
if
(
tmpRoleCodepathStr
.
indexOf
(
n
.
code
)
<
0
)
{
if
(
n
.
isctl
&&
n
.
isctl
==
"no"
)
{
n
.
hidden
=
false
;
console
.
log
(
n
.
code
,
"no ctl"
,
"show menu"
);
}
else
{
n
.
hidden
=
true
;
console
.
log
(
n
.
code
,
"no authed"
,
"hide menu"
);
}
}
else
{
n
.
hidden
=
false
;
console
.
log
(
n
.
code
,
"authed......"
,
"show menu"
);
}
}
}
if
(
n
.
children
)
{
n
.
children
.
forEach
((
dd
)
=>
{
return
funcrange
(
dd
);
});
}
else
{
if
(
n
.
isctl
&&
n
.
isctl
==
"no"
)
{
n
.
hidden
=
false
;
}
return
;
}
};
funcrange
(
r
);
}
return
(
cfg
.
config
[
"rstree"
]);
}
//每个角色有一个code/codepath的集合
//只要当前code出现在codepath中,就返回
//针对叶子节点授权,那么父节点出现在codepath中,所以可以实现父节点返回
async
getRsConfig
(
q
,
req
)
{
var
rs2
=
[];
console
.
log
(
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
);
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
console
.
log
(
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
);
var
tmpRoleCodepathStr
=
[];
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
//按照用户查询角色
// try{
// var user= await this.userS.getAuths(req.session.user.id);
// var roles=await user.getRoles({raw:true});
// console.log(roles);
// }catch(e){
// console.log(e);
// }
var
tmpRoles
=
[];
if
(
req
.
session
.
user
.
Roles
)
{
req
.
session
.
user
.
Roles
.
forEach
(
r
=>
{
tmpRoles
.
push
(
r
.
code
);
});
//按照角色获取权限列表
var
auths
=
await
this
.
authS
.
findAuthsByRole
(
tmpRoles
,
req
.
session
.
user
.
app_id
,
req
.
tocompanyid
);
var
codepathattrs
=
auths
.
map
(
r
=>
{
if
(
r
.
authstrs
&&
r
.
authstrs
!=
""
)
{
if
(
r
.
codepath
)
{
var
cparr
=
r
.
codepath
.
split
(
"/"
);
for
(
var
c
of
cparr
)
{
tmpRoleCodepathStr
.
push
(
c
);
}
}
return
r
.
codepath
;
}
else
{
return
""
;
}
});
}
}
console
.
log
(
".....................获取当前登录人的角色,进而获取权限,进而合并工具栏目.getRsConfig"
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
for
(
var
i
=
0
;
i
<
cfg
.
config
[
"rstree"
].
children
.
length
;
i
++
)
{
var
r
=
cfg
.
config
[
"rstree"
].
children
[
i
];
console
.
log
(
r
.
code
);
var
funcrange
=
function
(
n
)
{
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
if
(
req
.
session
.
user
.
isAdmin
||
req
.
session
.
user
.
isSuper
)
{
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
<
0
&&
req
.
session
.
user
.
isAdmin
)
{
n
.
hidden
=
false
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
>=
0
&&
req
.
session
.
user
.
isAdmin
)
{
n
.
hidden
=
true
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
>=
0
&&
req
.
session
.
user
.
isSuper
)
{
console
.
log
(
"isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper"
);
n
.
hidden
=
false
;
}
if
(
n
.
codePath
.
indexOf
(
"pmg"
)
<
0
&&
req
.
session
.
user
.
isSuper
&&
!
req
.
session
.
user
.
isAdmin
)
{
console
.
log
(
"isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper"
);
n
.
hidden
=
true
;
}
}
else
{
if
(
tmpRoleCodepathStr
.
indexOf
(
n
.
code
)
<
0
)
{
if
(
n
.
isctl
&&
n
.
isctl
==
"no"
)
{
n
.
hidden
=
false
;
console
.
log
(
n
.
code
,
"no ctl"
,
"show menu"
);
}
else
{
n
.
hidden
=
true
;
console
.
log
(
n
.
code
,
"no authed"
,
"hide menu"
);
}
}
else
{
n
.
hidden
=
false
;
console
.
log
(
n
.
code
,
"authed......"
,
"show menu"
);
}
}
}
if
(
n
.
children
)
{
n
.
children
.
forEach
((
dd
)
=>
{
return
funcrange
(
dd
);
});
}
else
{
if
(
n
.
isctl
&&
n
.
isctl
==
"no"
)
{
n
.
hidden
=
false
;
}
return
;
}
};
funcrange
(
r
);
}
return
system
.
getResult
(
cfg
.
config
[
"rstree"
]);
}
async
getRouteConfig
()
{
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
appKey
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
var
tmp
=
{};
tmp
.
bizs
=
cfg
.
config
[
"bizs"
];
// var products=await this.productS.list(settings.wxconfig.appId);
// tmp.ps=await this.productC.addVisitCountData(products);
return
system
.
getResult
(
tmp
);
}
async
getRouteConfigWithoutProduct
(
q
,
req
)
{
console
.
log
(
"...............req.hostname................................................................."
);
console
.
log
(
req
.
hostname
);
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
wxconfig
.
appId
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
var
tmp
=
{};
tmp
.
bizs
=
cfg
.
config
[
"bizs"
];
if
(
settings
.
env
==
"dev"
)
{
if
(
req
.
hostname
.
indexOf
(
"igsuper"
)
<
0
)
{
tmp
.
isp
=
0
;
}
else
{
tmp
.
isp
=
1
;
}
}
else
{
if
(
req
.
hostname
.
indexOf
(
"igirl"
)
<
0
)
{
tmp
.
isp
=
0
;
}
else
{
tmp
.
isp
=
1
;
}
}
return
system
.
getResult
(
tmp
);
}
async
getRouteConfigWithoutProduct2
(
q
,
req
)
{
var
tmp
=
{};
try
{
console
.
log
(
req
.
hostname
);
var
cfg
=
await
this
.
service
.
getUiConfig
(
settings
.
wxconfig
.
appId
);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
tmp
.
bizs
=
cfg
.
config
[
"bizs"
];
if
(
settings
.
env
==
"dev"
)
{
if
(
req
.
hostname
.
indexOf
(
"igsuper"
)
<
0
)
{
tmp
.
isp
=
0
;
}
else
{
tmp
.
isp
=
1
;
}
}
else
{
if
(
req
.
hostname
.
indexOf
(
"igirl"
)
<
0
)
{
tmp
.
isp
=
0
;
}
else
{
tmp
.
isp
=
1
;
}
}
}
catch
(
e
)
{
}
return
tmp
;
}
}
module
.
exports
=
MetaCtl
;
center-manage/app/base/db/initData.js
View file @
c1aaceed
...
...
@@ -20,7 +20,7 @@ db.sync({force:true}).then(async ()=>{
await
Role
.
create
({
code
:
"ta"
,
name
:
"租户"
,
app_id
:
appnew
.
id
,
company_id
:
settings
.
pmcompanyid
})
await
Role
.
create
({
code
:
"pr"
,
name
:
"个人"
,
app_id
:
appnew
.
id
,
company_id
:
settings
.
pmcompanyid
})
let
usuper
=
await
usS
.
pmregister
({
userName
:
"sm"
,
password
:
"951753"
,
isSuper
:
true
,
isAdmin
:
true
,
isEnabled
:
true
,
nickName
:
"superman"
,
app_id
:
appnew
.
id
,
company_id
:
settings
.
id
})
let
usuper
=
await
usS
.
pmregister
({
userName
:
"sm"
,
password
:
"951753"
,
isSuper
:
true
,
isAdmin
:
true
,
is
System
:
true
,
is
Enabled
:
true
,
nickName
:
"superman"
,
app_id
:
appnew
.
id
,
company_id
:
settings
.
id
})
...
...
center-manage/app/base/db/models/auth/user.js
View file @
c1aaceed
...
...
@@ -34,6 +34,10 @@ module.exports = (db, DataTypes) => {
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
isSystem
:{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
center_id
:
DataTypes
.
STRING
,
jwtkey
:
DataTypes
.
STRING
,
jwtsecret
:
DataTypes
.
STRING
,
...
...
center-manage/app/base/service/impl/auth/userSve.js
View file @
c1aaceed
...
...
@@ -103,12 +103,15 @@ class UserService extends ServiceBase {
//先
let
userfind
=
await
self
.
dao
.
model
.
findOne
({
where
:
{
userName
:
p
.
userName
,
app_id
:
settings
.
pmappid
},
attributes
:
[
'userName'
,
'nickName'
,
'headUrl'
,
'jwtkey'
,
'jwtsecret'
],
include
:
[{
model
:
self
.
db
.
models
.
company
,
raw
:
true
,
attributes
:
[
"companykey"
]
}]
});
if
(
userfind
)
{
let
token
=
await
self
.
cmakejwt
(
userfind
.
jwtkey
,
userfind
.
jwtsecret
,
null
);
rtn
.
token
=
token
;
delete
userfind
[
"jwtkey"
]
delete
userfind
[
"jwtsecret"
]
rtn
.
user
=
userfind
;
return
rtn
;
}
else
{
...
...
@@ -119,6 +122,7 @@ class UserService extends ServiceBase {
async
getUserInfo
(
uname
){
let
userfind
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
userName
:
uname
,
app_id
:
settings
.
pmappid
},
attributes
:
[
'userName'
,
'nickName'
,
"headUrl"
],
include
:
[{
model
:
this
.
db
.
models
.
company
,
raw
:
true
,
attributes
:
[
"companykey"
]
}]
});
return
userfind
;
...
...
@@ -247,7 +251,7 @@ class UserService extends ServiceBase {
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
let
up
=
await
self
.
dao
.
update
(
qobj
,
t
);
let
roles
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
this
.
db
.
Op
.
in
]:
qobj
.
roles
}
}
});
let
roles
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
qobj
.
roles
}
}
});
if
(
roles
&&
roles
.
length
>
0
){
await
up
.
setRoles
(
roles
,
{
transaction
:
t
});
}
...
...
center-manage/app/base/system.js
View file @
c1aaceed
...
...
@@ -211,7 +211,7 @@ class System {
try
{
ClassObj
=
require
(
objabspath
);
}
catch
(
e
){
console
.
log
(
e
)
//
console.log(e)
let
fname
=
objsettings
[
packageName
+
"base"
];
ClassObj
=
require
(
fname
);
}
...
...
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