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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
14 deletions
+48
-14
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
-0
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{
...
@@ -5,19 +5,44 @@ class APIBase{
constructor
()
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
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
)
{
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
try
{
console
.
log
(
"**********************************************"
)
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
console
.
log
(
req
.
headers
)
if
(
xarg
&&
xarg
[
0
]
<
0
){
let
custtags
=
req
.
headers
[
"x-consumetag"
].
split
(
"|"
);
return
system
.
getResultFail
(...
xarg
);
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有值了
}
}
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
return
rtn
;
return
rtn
;
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
center-manage/app/base/api/impl/meta/oss.js
View file @
c1aaceed
...
@@ -8,6 +8,7 @@ var accessKeyId='LTAIyAUK8AD04P5S';
...
@@ -8,6 +8,7 @@ var accessKeyId='LTAIyAUK8AD04P5S';
var
url
=
"https://gsb-zc.oss-cn-beijing.aliyuncs.com"
;
var
url
=
"https://gsb-zc.oss-cn-beijing.aliyuncs.com"
;
class
OSSAPI
extends
APIBase
{
class
OSSAPI
extends
APIBase
{
constructor
(){
constructor
(){
super
()
}
}
async
getOssConfig
(){
async
getOssConfig
(){
var
policyText
=
{
var
policyText
=
{
...
@@ -30,7 +31,7 @@ class OSSAPI extends APIBase{
...
@@ -30,7 +31,7 @@ class OSSAPI extends APIBase{
url
:
url
url
:
url
};
};
return
data
;
return
system
.
getResult
(
data
)
;
};
};
async
upfile
(
srckey
,
dest
){
async
upfile
(
srckey
,
dest
){
var
oss
=
System
.
getObject
(
"util.ossClient"
);
var
oss
=
System
.
getObject
(
"util.ossClient"
);
...
...
center-manage/app/base/controller/impl/common/metaCtl.js
View file @
c1aaceed
This diff is collapsed.
Click to expand it.
center-manage/app/base/db/initData.js
View file @
c1aaceed
...
@@ -20,7 +20,7 @@ db.sync({force:true}).then(async ()=>{
...
@@ -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
:
"ta"
,
name
:
"租户"
,
app_id
:
appnew
.
id
,
company_id
:
settings
.
pmcompanyid
})
await
Role
.
create
({
code
:
"pr"
,
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) => {
...
@@ -34,6 +34,10 @@ module.exports = (db, DataTypes) => {
type
:
DataTypes
.
BOOLEAN
,
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
defaultValue
:
false
},
},
isSystem
:{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
center_id
:
DataTypes
.
STRING
,
center_id
:
DataTypes
.
STRING
,
jwtkey
:
DataTypes
.
STRING
,
jwtkey
:
DataTypes
.
STRING
,
jwtsecret
:
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 {
...
@@ -103,12 +103,15 @@ class UserService extends ServiceBase {
//先
//先
let
userfind
=
await
self
.
dao
.
model
.
findOne
({
let
userfind
=
await
self
.
dao
.
model
.
findOne
({
where
:
{
userName
:
p
.
userName
,
app_id
:
settings
.
pmappid
},
where
:
{
userName
:
p
.
userName
,
app_id
:
settings
.
pmappid
},
attributes
:
[
'userName'
,
'nickName'
,
'headUrl'
,
'jwtkey'
,
'jwtsecret'
],
include
:
[{
model
:
self
.
db
.
models
.
company
,
raw
:
true
,
attributes
:
[
"companykey"
]
}]
include
:
[{
model
:
self
.
db
.
models
.
company
,
raw
:
true
,
attributes
:
[
"companykey"
]
}]
});
});
if
(
userfind
)
{
if
(
userfind
)
{
let
token
=
await
self
.
cmakejwt
(
userfind
.
jwtkey
,
userfind
.
jwtsecret
,
null
);
let
token
=
await
self
.
cmakejwt
(
userfind
.
jwtkey
,
userfind
.
jwtsecret
,
null
);
rtn
.
token
=
token
;
rtn
.
token
=
token
;
delete
userfind
[
"jwtkey"
]
delete
userfind
[
"jwtsecret"
]
rtn
.
user
=
userfind
;
rtn
.
user
=
userfind
;
return
rtn
;
return
rtn
;
}
else
{
}
else
{
...
@@ -119,6 +122,7 @@ class UserService extends ServiceBase {
...
@@ -119,6 +122,7 @@ class UserService extends ServiceBase {
async
getUserInfo
(
uname
){
async
getUserInfo
(
uname
){
let
userfind
=
await
this
.
dao
.
model
.
findOne
({
let
userfind
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
userName
:
uname
,
app_id
:
settings
.
pmappid
},
where
:
{
userName
:
uname
,
app_id
:
settings
.
pmappid
},
attributes
:
[
'userName'
,
'nickName'
,
"headUrl"
],
include
:
[{
model
:
this
.
db
.
models
.
company
,
raw
:
true
,
attributes
:
[
"companykey"
]
}]
include
:
[{
model
:
this
.
db
.
models
.
company
,
raw
:
true
,
attributes
:
[
"companykey"
]
}]
});
});
return
userfind
;
return
userfind
;
...
@@ -247,7 +251,7 @@ class UserService extends ServiceBase {
...
@@ -247,7 +251,7 @@ class UserService extends ServiceBase {
var
self
=
this
;
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
return
this
.
db
.
transaction
(
async
function
(
t
)
{
let
up
=
await
self
.
dao
.
update
(
qobj
,
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
){
if
(
roles
&&
roles
.
length
>
0
){
await
up
.
setRoles
(
roles
,
{
transaction
:
t
});
await
up
.
setRoles
(
roles
,
{
transaction
:
t
});
}
}
...
...
center-manage/app/base/system.js
View file @
c1aaceed
...
@@ -211,7 +211,7 @@ class System {
...
@@ -211,7 +211,7 @@ class System {
try
{
try
{
ClassObj
=
require
(
objabspath
);
ClassObj
=
require
(
objabspath
);
}
catch
(
e
){
}
catch
(
e
){
console
.
log
(
e
)
//
console.log(e)
let
fname
=
objsettings
[
packageName
+
"base"
];
let
fname
=
objsettings
[
packageName
+
"base"
];
ClassObj
=
require
(
fname
);
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