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
14241c05
Commit
14241c05
authored
Nov 04, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel
parents
b50a980c
6eaadd66
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
25 deletions
+92
-25
center-channel/app/base/api/impl/opreceive/need2.js
+1
-1
center-channel/app/base/service/impl/common/baseCenterOrderSve.js
+8
-21
center-channel/app/base/service/impl/utilsSve/utilsNeedSve2.js
+3
-3
center-channel/app/base/utils/baiduClient.js
+66
-0
center-channel/app/base/utils/execClient.js
+14
-0
No files found.
center-channel/app/base/api/impl/opreceive/need2.js
View file @
14241c05
...
...
@@ -81,7 +81,7 @@ class Need2 extends APIBase {
opResult
=
await
this
.
utilsNeedSve
.
submitIcpIntention
(
pobj
,
pobj
.
actionBody
);
break
;
case
"queryIntentionList"
:
// 2020 0827 lin 新增 4.2 需求列表查询
opResult
=
await
this
.
utilsNeedSve
.
queryIntentionList
(
pobj
,
pobj
.
actionBody
);
opResult
=
await
this
.
utilsNeedSve
2
.
queryIntentionList
(
pobj
,
pobj
.
actionBody
);
break
;
case
"confirmIcpIntention"
:
// 2020 0827 lin 新增 4.3 用户需求确认
opResult
=
await
this
.
utilsNeedSve
.
confirmIcpIntention
(
pobj
,
pobj
.
actionBody
);
...
...
center-channel/app/base/service/impl/common/baseCenterOrderSve.js
View file @
14241c05
...
...
@@ -205,25 +205,12 @@ class BaseCenterOrderService extends AppServiceBase {
if
(
typeof
(
ab
.
material
)
==
"string"
)
{
ab
.
material
=
JSON
.
parse
(
ab
.
material
);
}
var
uappIds
=
res
.
data
.
uapp_id
;
if
(
uappIds
==
uappId
.
ali
){
//推送数据至阿里
var
pushObj
=
{
BizId
:
ab
.
BizId
,
Note
:
ab
.
Note
};
//关闭方案
this
.
aliclient
.
reqbyget
({
action
:
"CloseIcpProduce"
,
reqbody
:
pushObj
,
apiVersion
:
"2019-05-08"
});
}
if
(
uappIds
==
uappId
.
baidu
){
//推送数据至baidu
var
pushObj
=
{
bizId
:
ab
.
BizId
,
note
:
ab
.
Note
};
//关闭方案
this
.
baiduclient
.
baiduReqbyget
({
action
:
"closeIcpProduce"
,
reqbody
:
pushObj
});
}
//推送数据至阿里
var
pushObj
=
{
BizId
:
ab
.
BizId
,
Note
:
ab
.
Note
};
//关闭方案
this
.
aliclient
.
reqbyget
({
action
:
"CloseIcpProduce"
,
reqbody
:
pushObj
,
apiVersion
:
"2019-05-08"
});
return
system
.
getResultSuccess
();
}
return
res
;
...
...
@@ -284,7 +271,7 @@ class BaseCenterOrderService extends AppServiceBase {
};
var
self
=
this
;
//推送方案材料
var
r
=
self
.
baiduclient
.
baiduReqbyget
({
action
:
"savePartnerSubmitM
aterial"
,
reqbody
:
pushObj
});
var
r
=
self
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/license/m
aterial"
,
reqbody
:
pushObj
});
console
.
log
(
"r++"
,
res
)
}
return
system
.
getResultSuccess
();
...
...
@@ -314,7 +301,7 @@ class BaseCenterOrderService extends AppServiceBase {
applicationStatus
:
res
.
data
.
ApplicationStatus
};
//推送状态变更
this
.
baiduclient
.
baiduReqbyget
({
action
:
"acceptPartnerNotification
"
,
reqbody
:
pushObj
});
this
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/requirement/update
"
,
reqbody
:
pushObj
});
}
return
system
.
getResultSuccess
();
}
...
...
center-channel/app/base/service/impl/utilsSve/utilsNeedSve2.js
View file @
14241c05
...
...
@@ -501,11 +501,11 @@ class UtilsNeedService2 extends AppServiceBase {
//2020-10-28 laolan start
if
(
result
&&
result
.
status
==
0
&&
result
.
data
&&
result
.
data
.
uappIds
){
if
(
result
.
data
.
uappIds
==
uappId
.
ali
){
var
res
=
await
self
.
aliclient
.
reqbyget
({
action
:
"
W
riteCommunicationLog"
,
reqbody
:
{
BizId
:
pobj
.
actionBody
.
intentionBizId
,
Note
:
pobj
.
actionBody
.
note
},
apiVersion
:
"2019-05-08"
});
var
res
=
await
self
.
aliclient
.
reqbyget
({
action
:
"
w
riteCommunicationLog"
,
reqbody
:
{
BizId
:
pobj
.
actionBody
.
intentionBizId
,
Note
:
pobj
.
actionBody
.
note
},
apiVersion
:
"2019-05-08"
});
console
.
log
(
"ali+res"
,
res
)
}
if
(
result
.
data
.
uappIds
==
uappId
.
baidu
){
var
ress
=
await
self
.
baiduclient
.
baiduReqbyget
({
action
:
"writeCommunicationLog
"
,
reqbody
:
{
bizId
:
pobj
.
actionBody
.
intentionBizId
,
note
:
pobj
.
actionBody
.
note
}
});
var
ress
=
await
self
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/communication
"
,
reqbody
:
{
bizId
:
pobj
.
actionBody
.
intentionBizId
,
note
:
pobj
.
actionBody
.
note
}
});
console
.
log
(
"baidu+res"
,
ress
)
}
}
...
...
@@ -559,7 +559,7 @@ class UtilsNeedService2 extends AppServiceBase {
if
(
result
.
data
.
uapp_id
==
uappId
.
baidu
){
var
res
=
await
this
.
baiduclient
.
baiduReqbyget
({
action
:
"queryExpertApplyCommunicationLogs
"
,
reqbody
:
{
path
:
"/api/bla/providerommunication/list
"
,
reqbody
:
{
beginTime
:
pobj
.
actionBody
.
BeginTime
?
pobj
.
actionBody
.
BeginTime
:
""
,
endTime
:
pobj
.
actionBody
.
EndTime
?
pobj
.
actionBody
.
EndTime
:
""
,
bizId
:
pobj
.
actionBody
.
intentionBizId
,
...
...
center-channel/app/base/utils/baiduClient.js
View file @
14241c05
const
co
=
require
(
"co"
);
var
request
=
require
(
"request"
);
const
crypto
=
require
(
'crypto'
);
const
sha256
=
require
(
'sha256'
);
var
urlencode
=
require
(
'urlencode'
);
const
system
=
require
(
"../system"
);
class
baiduClient
{
constructor
()
{
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
}
//2020 1027 laolan 调用百度网关
...
...
@@ -101,5 +103,69 @@ class baiduClient {
return
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
}
}
async
test
(){
var
obj
=
{
path
:
"/api/bla/provider/plan"
,
reqbody
:{
"area"
:
"北京"
,
"companyName"
:
"demoData"
,
"companyAddress"
:
"demoData"
,
"requirementId"
:
"TRE-nmnHtEoTjeE"
,
"type"
:
"ICP"
}
};
var
actionBody
=
obj
.
reqbody
;
var
path
=
obj
.
path
;
let
domain
=
"https://gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
;
let
url
=
domain
+
path
;
let
version
=
"bce-auth-v1"
;
let
accessKey
=
"ed0f5c4c7c2d4e87aa335d9b07bf9bd4"
;
let
secretKey
=
"f600c4e91f6d43998d637401e6e34ef9"
;
let
timestamp
=
new
Date
().
toISOString
();
let
signedHeaders
=
"host"
;
let
extime
=
1800
;
var
signArr
=
[];
var
keys
=
Object
.
keys
(
actionBody
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数信息为空"
);
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
actionBody
[
tKey
]
&&
!
(
typeof
(
actionBody
[
tKey
])
===
"object"
))
{
signArr
.
push
(
urlencode
(
tKey
)
+
"="
+
urlencode
(
actionBody
[
tKey
]));
}
}
let
resultSignStr
=
signArr
.
join
(
"&"
);
console
.
log
(
'resultSignStr+++'
,
resultSignStr
)
let
canonicalHeaders
=
"host:gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
//中间结果1:规范化请求和前缀字符串
let
canonicalRequest
=
"POST"
+
"
\
n"
+
path
+
"
\
n"
+
resultSignStr
+
"
\
n"
+
canonicalHeaders
;
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
let
authStringPrefix
=
version
+
"/"
+
accessKey
+
"/"
+
timestamp
+
"/"
+
extime
;
//中间结果2:派生签名密钥 signingKey
let
signingKey
=
crypto
.
createHmac
(
'sha256'
,
secretKey
)
.
update
(
authStringPrefix
)
.
digest
(
'hex'
);
//中间结果3:签名摘要 signature
let
signature
=
crypto
.
createHmac
(
'sha256'
,
signingKey
)
.
update
(
canonicalRequest
)
.
digest
(
'hex'
);
//最终结果:认证字符串 authorization
let
authorization
=
authStringPrefix
+
"/"
+
signedHeaders
+
"/"
+
signature
;
var
baiduObj
=
{
authorization
:
authorization
,
data
:
actionBody
}
var
rtn
=
await
this
.
execClient
.
execBaiduPost
(
baiduObj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
!
result
||
!
result
.
result
){
return
system
.
getResultFail
(
"推送失败"
);
}
return
system
.
getResultSuccess
();
}
}
module
.
exports
=
baiduClient
;
center-channel/app/base/utils/execClient.js
View file @
14241c05
...
...
@@ -12,6 +12,8 @@ class ExecClient {
this
.
cmdFeishuPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
//360
this
.
cmd360PostPattern
=
"curl -u gongsibao:qPa4PsVsxbQ847i5pOKSmfPKrzRoNKqx -d '{data}' -X POST {url}"
this
.
cmdBaiduPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -44,6 +46,13 @@ class ExecClient {
console
.
log
(
cmd
);
return
cmd
;
}
FetchBaiduPostCmd
(
subData
,
url
)
{
var
data
=
JSON
.
stringify
(
subData
);
var
cmd
=
this
.
cmdBaiduPostPattern
.
replace
(
/
\{
data
\}
/g
,
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
Authorization
\}
/g
,
subData
.
authorization
);
console
.
log
(
cmd
);
return
cmd
;
}
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
)
{
var
requestId
=
requestId
||
this
.
getUUID
();
var
data
=
JSON
.
stringify
(
subData
);
...
...
@@ -62,6 +71,11 @@ class ExecClient {
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
async
execBaiduPost
(
subData
,
url
)
{
let
cmd
=
this
.
FetchBaiduPostCmd
(
subData
,
url
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
async
execPushDataPost
(
subData
,
url
,
token
,
requestId
)
{
let
cmd
=
this
.
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
);
var
options
=
{
...
...
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