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
42392cf4
Commit
42392cf4
authored
Jul 11, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
c2b3c2f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
center-manage/app/base/api/api.base.js
+42
-0
No files found.
center-manage/app/base/api/api.base.js
View file @
42392cf4
...
@@ -5,6 +5,11 @@ class APIBase{
...
@@ -5,6 +5,11 @@ class APIBase{
constructor
()
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
async
setContextParams
(
pobj
,
qobj
,
req
)
{
async
setContextParams
(
pobj
,
qobj
,
req
)
{
let
custtags
=
req
.
headers
[
"x-consumetag"
]?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
):
null
;
let
custtags
=
req
.
headers
[
"x-consumetag"
]?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
):
null
;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
...
@@ -15,6 +20,8 @@ class APIBase{
...
@@ -15,6 +20,8 @@ class APIBase{
username
:
req
.
headers
[
"x-consumer-username"
],
username
:
req
.
headers
[
"x-consumer-username"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
codename
:
req
.
headers
[
"xcodename"
],
codetitle
:
req
.
headers
[
"xcodetitle"
]?
decodeURI
(
req
.
headers
[
"xcodetitle"
]):
''
,
}
}
if
(
!
req
.
xctx
.
appkey
){
if
(
!
req
.
xctx
.
appkey
){
return
[
-
200
,
"请求头缺少应用x-app-key"
]
return
[
-
200
,
"请求头缺少应用x-app-key"
]
...
@@ -44,8 +51,43 @@ class APIBase{
...
@@ -44,8 +51,43 @@ class APIBase{
}
}
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
rtn
.
requestId
=
this
.
getUUID
()
req
.
params
.
param
=
pobj
let
t
=
req
.
xctx
.
codetitle
let
codename
=
req
.
xctx
.
codename
if
(
t
==
''
){
t
=
"外部调用"
codename
=
req
.
xctx
.
appkey
}
system
.
execLogs
(
t
,
req
.
params
,
codename
,
rtn
,
null
).
then
(
res
=>
{
if
(
res
&&
res
.
status
==
1
){
console
.
log
(
"log.....success"
)
}
else
{
console
.
log
(
"log.....fail"
)
}
}).
catch
(
e
=>
{
console
.
log
(
"log.....fail"
)
})
return
rtn
;
return
rtn
;
}
catch
(
e
)
{
}
catch
(
e
)
{
let
rtn
=
{}
rtn
.
requestId
=
this
.
getUUID
()
req
.
params
.
param
=
pobj
let
t
=
req
.
xctx
.
codetitle
let
codename
=
req
.
xctx
.
codename
if
(
t
==
''
){
t
=
"外部调用"
codename
=
req
.
xctx
.
appkey
}
system
.
execLogs
(
t
,
req
.
params
,
codename
,
rtn
,
e
.
stack
).
then
(
res
=>
{
if
(
res
&&
res
.
status
==
1
){
console
.
log
(
"log.....success"
)
}
else
{
console
.
log
(
"log.....fail"
)
}
}).
catch
(
e
=>
{
console
.
log
(
"log.....fail"
)
})
console
.
log
(
e
.
stack
,
"api调用异常--error..................."
);
console
.
log
(
e
.
stack
,
"api调用异常--error..................."
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
return
rtnerror
;
return
rtnerror
;
...
...
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