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
572c733c
Commit
572c733c
authored
Apr 28, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
4329ec54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
3 deletions
+77
-3
center-channel/app/base/service/app.base.js
+41
-0
center-channel/app/base/service/impl/utilsSve/utilsFgbusinesschanceSve.js
+10
-0
center-channel/app/base/utils/restClient.js
+18
-2
center-channel/app/config/settings.js
+8
-1
No files found.
center-channel/app/base/service/app.base.js
View file @
572c733c
...
...
@@ -67,6 +67,32 @@ class AppServiceBase {
return
system
.
getResult
(
null
,
errorMsg
);
}
}
async
restPostWithHValueUrl
(
pobj
,
url
,
hValue
)
{
//curl请求带请求头信息
try
{
if
(
!
hValue
)
{
hValue
=
"YLc6GsgLtuRGaVA5Om848x18NxLtHlyA"
;
}
var
rtn
=
await
this
.
restClient
.
execPostWithHValue
(
pobj
,
url
,
hValue
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPostWithHValue data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
catch
(
e
)
{
var
errorMsg
=
"error:"
+
e
.
stack
;
//日志记录
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"service/app.base.js/restPostWithHValueUrl"
,
content
:
errorMsg
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常->restPostWithHValueUrl"
,
});
return
system
.
getResult
(
null
,
errorMsg
);
}
}
async
execPostUrl
(
pobj
,
url
)
{
try
{
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
...
...
@@ -296,6 +322,21 @@ class AppServiceBase {
var
productItemInterfaceResult
=
await
this
.
restPostUrl
(
getProductInterfaceObj
,
getProductInterfaceUrl
);
return
productItemInterfaceResult
;
}
async
getConvertSemiangleStr
(
str
)
{
//去除空格及全角转半角
var
result
=
""
;
str
=
str
.
replace
(
/
\s
+/g
,
""
);
var
len
=
str
.
length
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
var
cCode
=
str
.
charCodeAt
(
i
);
//全角与半角相差(除空格外):65248(十进制)
cCode
=
(
cCode
>=
0xFF01
&&
cCode
<=
0xFF5E
)
?
(
cCode
-
65248
)
:
cCode
;
//处理空格
cCode
=
(
cCode
==
0x03000
)
?
0x0020
:
cCode
;
result
+=
String
.
fromCharCode
(
cCode
);
}
return
result
;
}
/*
返回20位业务订单号
prefix:业务前缀
...
...
center-channel/app/base/service/impl/utilsSve/utilsFgbusinesschanceSve.js
View file @
572c733c
...
...
@@ -53,6 +53,16 @@ class UtilsFgbusinesschancService extends AppServiceBase {
if
(
!
actionBody
.
companyName
)
{
return
system
.
getResult
(
null
,
"actionBody.companyName can not be empty,100290"
);
}
actionBody
.
companyName
=
await
this
.
getConvertSemiangleStr
(
actionBody
.
companyName
);
var
url
=
settings
.
entProfileUrl
()
+
"lable"
;
var
reqParam
=
{
company_name
:
actionBody
.
companyName
}
var
result
=
await
this
.
restPostWithHValueUrl
(
reqParam
,
url
);
if
(
result
.
code
!=
200
)
{
return
system
.
getResult
(
null
,
result
.
message
||
"req is error"
);
}
return
system
.
getResultSuccess
(
result
.
data
);
}
async
getRecommendProducts
(
pobj
,
actionBody
)
{
...
...
center-channel/app/base/utils/restClient.js
View file @
572c733c
...
...
@@ -11,8 +11,10 @@ class RestClient {
this
.
cmdPostPatternWithAK
=
"curl -k -H 'Content-type: application/json' -H 'AccessKey:{ak}' -H 'request-id:{requestId}' -d '{data}' {url}"
;
this
.
cmdPostWithHValue
=
"curl -k -H 'Content-type: application/json' -H 'ak:{ak}' -d '{data}' {url}"
;
this
.
cmdDownLoadFilePattern
=
"curl -G -o {fileName} {url}"
;
this
.
cmdPostPattern2
=
"curl -k -H 'Content-type: application/x-www-form-urlencoded'
-d '{data}' {url}"
;
this
.
cmdPostPattern2
=
"curl -k -H 'Content-type: application/x-www-form-urlencoded' -d '{data}' {url}"
;
// form-data形式post data参数类型 md5=2&data=1
this
.
cmdPostPattern5
=
"curl -k --data '{data}' {url}"
;
...
...
@@ -40,6 +42,12 @@ class RestClient {
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
ak
\}
/g
,
acck
).
replace
(
/
\{
requestId
\}
/g
,
requestId
);
return
cmd
;
}
FetchPostCmdWithHValue
(
subData
,
url
,
hValue
)
{
var
data
=
JSON
.
stringify
(
subData
);
var
cmd
=
this
.
cmdPostWithHValue
.
replace
(
/
\{
data
\}
/g
,
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
ak
\}
/g
,
hValue
);
return
cmd
;
}
FetchPostCmd2
(
subData
,
url
)
{
var
data
=
subData
;
var
cmd
=
this
.
cmdPostPattern2
.
replace
(
/
\{
data
\}
/g
,
...
...
@@ -88,7 +96,7 @@ class RestClient {
}
async
execPost
(
subData
,
url
)
{
let
cmd
=
this
.
FetchPostCmd
(
subData
,
url
);
console
.
log
(
cmd
,
"cmd............"
);
console
.
log
(
cmd
,
"cmd............"
);
var
result
=
await
this
.
exec
(
cmd
,
{
maxBuffer
:
10000
*
1024
});
...
...
@@ -106,6 +114,14 @@ class RestClient {
return
null
;
}
}
async
execPostWithHValue
(
subData
,
url
,
hValue
)
{
let
cmd
=
this
.
FetchPostCmdWithHValue
(
subData
,
url
,
hValue
);
console
.
log
(
cmd
,
"cmd............"
);
var
result
=
await
this
.
exec
(
cmd
,
{
maxBuffer
:
1024
*
1024
*
15
});
return
result
;
}
async
execPost2
(
subData
,
url
)
{
let
cmd
=
this
.
FetchPostCmd2
(
subData
,
url
);
console
.
log
(
cmd
);
...
...
center-channel/app/config/settings.js
View file @
572c733c
...
...
@@ -19,7 +19,14 @@ var settings = {
cacheprefix
:
"centerChannel"
,
usertimeout
:
3600
,
//单位秒
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
4012
,
port
:
process
.
env
.
NODE_PORT
||
4012
,
entProfileUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"https://entprofile.gongsibao.com/"
;
}
else
{
return
"https://entprofile.gongsibao.com/"
;
}
},
aliossjavaUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"http://192.168.2.109:8080/uploadfile"
;
...
...
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