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
28700514
Commit
28700514
authored
Oct 29, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
35a3df97
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
41 deletions
+52
-41
center-channel/app/base/api/impl/nmaction/name.js
+35
-38
center-channel/app/base/api/web.base.js
+16
-2
center-channel/app/config/settings.js
+1
-1
No files found.
center-channel/app/base/api/impl/nmaction/name.js
View file @
28700514
var
WEBBase
=
require
(
"../../web.base"
);
var
WEBBase
=
require
(
"../../web.base"
);
var
system
=
require
(
"../../../system"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
NameAPI
extends
WEBBase
{
class
NameAPI
extends
WEBBase
{
constructor
()
{
constructor
()
{
super
();
super
();
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
...
@@ -29,17 +29,17 @@ class NameAPI extends WEBBase{
...
@@ -29,17 +29,17 @@ class NameAPI extends WEBBase{
opResult
=
await
this
.
getCache
();
opResult
=
await
this
.
getCache
();
break
;
break
;
case
"getPreference"
:
//偏好
case
"getPreference"
:
//偏好
opResult
=
await
this
.
getPreference
();
opResult
=
await
this
.
getPreference
();
break
;
break
;
case
"createName"
:
//起名
case
"createName"
:
//起名
opResult
=
await
this
.
addOrderDelivery
(
pobj
,
pobj
.
actionBody
);
opResult
=
await
this
.
addOrderDelivery
(
pobj
,
pobj
.
actionBody
);
break
;
break
;
case
"getNameDetail"
:
//详情
case
"getNameDetail"
:
//详情
opResult
=
await
this
.
getNameDetail
(
pobj
);
opResult
=
await
this
.
getNameDetail
(
pobj
);
break
;
break
;
case
"getNames"
:
//详情
case
"getNames"
:
//详情
opResult
=
await
this
.
getNames
(
pobj
,
pobj
.
actionBody
);
opResult
=
await
this
.
getNames
(
req
,
pobj
.
actionBody
);
break
;
break
;
default
:
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
break
;
...
@@ -51,7 +51,7 @@ class NameAPI extends WEBBase{
...
@@ -51,7 +51,7 @@ class NameAPI extends WEBBase{
* 获取行业类别数据 後期可提出為一個service文件
* 获取行业类别数据 後期可提出為一個service文件
* @returns {Promise<{}>}
* @returns {Promise<{}>}
*/
*/
async
getCache
(){
async
getCache
()
{
let
cacheResult
=
{};
let
cacheResult
=
{};
cacheResult
.
cache
=
cacheJson
cacheResult
.
cache
=
cacheJson
return
system
.
getResult
(
cacheResult
);
return
system
.
getResult
(
cacheResult
);
...
@@ -61,17 +61,17 @@ class NameAPI extends WEBBase{
...
@@ -61,17 +61,17 @@ class NameAPI extends WEBBase{
* 获取偏好信息 後期可提出為一個service文件
* 获取偏好信息 後期可提出為一個service文件
* @returns {Promise<{}>}
* @returns {Promise<{}>}
*/
*/
async
getPreference
(){
async
getPreference
()
{
let
preResult
=
{};
let
preResult
=
{};
const
key
=
'qmbpreference'
;
const
key
=
'qmbpreference'
;
let
result
=
await
this
.
redisClient
.
get
(
key
)
let
result
=
await
this
.
redisClient
.
get
(
key
)
if
(
result
)
{
if
(
result
)
{
preResult
.
preference
=
JSON
.
parse
(
result
);
preResult
.
preference
=
JSON
.
parse
(
result
);
return
system
.
getResult
(
preResult
);
return
system
.
getResult
(
preResult
);
}
else
{
}
else
{
const
data
=
await
this
.
restPostUrl
({},
this
.
centerCacheUrl
+
"preference_select"
);
const
data
=
await
this
.
restPostUrl
({},
this
.
centerCacheUrl
+
"preference_select"
);
if
(
data
.
code
==
200
)
{
if
(
data
.
code
==
200
)
{
await
this
.
redisClient
.
set
(
key
,
JSON
.
stringify
(
data
.
data
),
2
*
3600
)
await
this
.
redisClient
.
set
(
key
,
JSON
.
stringify
(
data
.
data
),
2
*
3600
)
preResult
.
preference
=
data
.
data
preResult
.
preference
=
data
.
data
return
system
.
getResult
(
preResult
);
return
system
.
getResult
(
preResult
);
}
}
...
@@ -84,7 +84,7 @@ class NameAPI extends WEBBase{
...
@@ -84,7 +84,7 @@ class NameAPI extends WEBBase{
* @param actionBody
* @param actionBody
* @returns {Promise<{msg: string, data: (*|null), bizmsg: *, status: number}|{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>}
* @returns {Promise<{msg: string, data: (*|null), bizmsg: *, status: number}|{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>}
*/
*/
async
addOrderDelivery
(
pobj
,
actionBody
)
{
async
addOrderDelivery
(
pobj
,
actionBody
)
{
if
(
!
actionBody
.
orderId
)
{
if
(
!
actionBody
.
orderId
)
{
return
system
.
getResult
(
null
,
"orderId参数不能为空"
);
return
system
.
getResult
(
null
,
"orderId参数不能为空"
);
}
}
...
@@ -106,46 +106,43 @@ class NameAPI extends WEBBase{
...
@@ -106,46 +106,43 @@ class NameAPI extends WEBBase{
if
(
!
actionBody
.
preference
)
{
if
(
!
actionBody
.
preference
)
{
return
system
.
getResult
(
null
,
"preference参数不能为空"
);
return
system
.
getResult
(
null
,
"preference参数不能为空"
);
}
}
await
this
.
redisClient
.
set
(
"ch"
+
JSON
.
stringify
(
actionBody
.
orderId
),
JSON
.
stringify
(
actionBody
));
await
this
.
redisClient
.
set
(
"ch"
+
JSON
.
stringify
(
actionBody
.
orderId
),
JSON
.
stringify
(
actionBody
));
return
system
.
getResultSuccess
();
return
system
.
getResultSuccess
();
}
}
//获取取名结果,并保存到数据库
//获取取名结果,并保存到数据库
async
getNameDetail
(
pobj
){
async
getNameDetail
(
pobj
)
{
pobj
.
actionType
=
'getOrderDeliveryInfo'
;
pobj
.
actionType
=
'getOrderDeliveryInfo'
;
const
opResult
=
await
this
.
utilsOrderSve
.
getOrderDeliveryInfo
(
pobj
,
pobj
.
actionBody
);
const
opResult
=
await
this
.
utilsOrderSve
.
getOrderDeliveryInfo
(
pobj
,
pobj
.
actionBody
);
if
(
opResult
.
status
!=
0
)
{
if
(
opResult
.
status
!=
0
)
{
return
system
.
getResult
(
null
,
opResult
.
msg
);
return
system
.
getResult
(
null
,
opResult
.
msg
);
}
}
if
(
opResult
.
data
.
hasOwnProperty
(
'result_name'
))
{
if
(
opResult
.
data
.
hasOwnProperty
(
'result_name'
))
{
return
system
.
getResult
(
opResult
.
data
,
'操作成功'
);
return
system
.
getResult
(
opResult
.
data
,
'操作成功'
);
}
}
let
actionBody
=
await
this
.
redisClient
.
get
(
'ch'
+
JSON
.
stringify
(
pobj
.
actionBody
.
orderNo
));
let
actionBody
=
await
this
.
redisClient
.
get
(
'ch'
+
JSON
.
stringify
(
pobj
.
actionBody
.
orderNo
));
if
(
!
actionBody
)
{
if
(
!
actionBody
)
{
return
system
.
getResult
(
null
)
return
system
.
getResult
(
null
)
}
}
let
nameResult
=
await
this
.
restPostUrl
(
JSON
.
parse
(
actionBody
),
this
.
centerCacheUrl
+
"treasure_name"
);
let
nameResult
=
await
this
.
restPostUrl
(
JSON
.
parse
(
actionBody
),
this
.
centerCacheUrl
+
"treasure_name"
);
if
(
nameResult
.
code
==
200
)
{
if
(
nameResult
.
code
==
200
)
{
pobj
.
actionType
=
'addOrderDelivery'
;
pobj
.
actionType
=
'addOrderDelivery'
;
pobj
.
actionBody
=
nameResult
.
data
;
pobj
.
actionBody
=
nameResult
.
data
;
//取名结果存储
//取名结果存储
let
result
=
await
this
.
restPostUrl
(
pobj
,
this
.
centerOrderUrl
+
"action/nameOrder/springBoard"
);
let
result
=
await
this
.
restPostUrl
(
pobj
,
this
.
centerOrderUrl
+
"action/nameOrder/springBoard"
);
return
system
.
getResult
(
nameResult
.
data
,
"操作成功"
);
return
system
.
getResult
(
nameResult
.
data
,
"操作成功"
);
}
}
return
system
.
getResult
(
null
,
'try again'
);
return
system
.
getResult
(
null
,
'try again'
);
}
}
async
getNames
(
pobj
,
actionBody
){
async
getNames
(
req
,
actionBody
)
{
let
rtn
=
await
this
.
restClient
.
execPost
(
actionBody
,
this
.
aliGetNamesjavaUrl
);
const
result
=
await
this
.
execPostByTimeOut
(
req
,
actionBody
,
this
.
aliGetNamesjavaUrl
);
if
(
!
rtn
.
stdout
)
{
if
(
result
.
status
!=
0
)
{
return
system
.
getResultFail
();
return
result
;
}
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
const
tmpData
=
result
.
data
?
result
.
data
.
companyName
:
[];
if
(
result
)
{
return
system
.
getResultSuccess
(
tmpData
);
return
system
.
getResultSuccess
(
result
);
}
return
system
.
getResultFail
(
result
);
}
}
}
}
...
@@ -153,7 +150,7 @@ const cacheJson = {
...
@@ -153,7 +150,7 @@ const cacheJson = {
"科技类"
:
[
"网络科技"
,
"电子商务"
,
"信息技术"
,
"游戏"
,
"电子"
,
"软件"
,
"新材料"
,
"生物科技"
,
"教育科技"
,
"环保科技"
,
"信息科技"
],
"科技类"
:
[
"网络科技"
,
"电子商务"
,
"信息技术"
,
"游戏"
,
"电子"
,
"软件"
,
"新材料"
,
"生物科技"
,
"教育科技"
,
"环保科技"
,
"信息科技"
],
"许可类"
:
[
"投资管理"
,
"金融"
,
"资产"
,
"商业保理"
,
"融资租赁"
,
"医疗器械"
,
"人力资源"
,
"食品"
,
"劳务派遣"
],
"许可类"
:
[
"投资管理"
,
"金融"
,
"资产"
,
"商业保理"
,
"融资租赁"
,
"医疗器械"
,
"人力资源"
,
"食品"
,
"劳务派遣"
],
"服务类"
:
[
"广告"
,
"文化传媒"
,
"建筑装潢"
,
"设计"
,
"美容美发"
,
"房地产中介"
,
"物业管理"
,
"商务咨询"
,
"企业管理"
],
"服务类"
:
[
"广告"
,
"文化传媒"
,
"建筑装潢"
,
"设计"
,
"美容美发"
,
"房地产中介"
,
"物业管理"
,
"商务咨询"
,
"企业管理"
],
"其他"
:
[
"贸易"
,
"实业"
,
"制造"
,
"服饰"
,
"化妆品"
,
"工程"
,
"农业"
,
"餐饮管理"
,
"物流"
],
"其他"
:
[
"贸易"
,
"实业"
,
"制造"
,
"服饰"
,
"化妆品"
,
"工程"
,
"农业"
,
"餐饮管理"
,
"物流"
],
}
}
...
...
center-channel/app/base/api/web.base.js
View file @
28700514
...
@@ -5,6 +5,7 @@ const md5 = require("MD5");
...
@@ -5,6 +5,7 @@ const md5 = require("MD5");
class
WEBBase
{
class
WEBBase
{
constructor
()
{
constructor
()
{
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
execClientNew
=
system
.
getObject
(
"util.execClientNew"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
toolSve
=
system
.
getObject
(
"service.trademark.toolSve"
);
this
.
toolSve
=
system
.
getObject
(
"service.trademark.toolSve"
);
...
@@ -68,10 +69,23 @@ class WEBBase {
...
@@ -68,10 +69,23 @@ class WEBBase {
async
restPostUrl
(
pobj
,
url
)
{
async
restPostUrl
(
pobj
,
url
)
{
var
rtn
=
await
this
.
restClient
.
execPost
(
pobj
,
url
);
var
rtn
=
await
this
.
restClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost data is empty"
);
return
system
.
getResult
(
null
,
"restPost data is empty"
);
}
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
return
result
;
}
}
/**
* 带超时时间的post请求
* @param {*} req 请求信息
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间
*/
async
execPostByTimeOut
(
req
,
params
,
url
,
ContentType
,
headData
,
timeOut
=
60
)
{
const
result
=
await
this
.
execClientNew
.
execPostTimeOutByBusiness
(
'sve.base'
,
params
,
url
,
ContentType
,
headData
,
timeOut
,
req
);
return
result
;
}
}
}
module
.
exports
=
WEBBase
;
module
.
exports
=
WEBBase
;
center-channel/app/config/settings.js
View file @
28700514
...
@@ -60,7 +60,7 @@ var settings = {
...
@@ -60,7 +60,7 @@ var settings = {
},
},
aliGetNamesjavaUrl
:
function
()
{
aliGetNamesjavaUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
if
(
this
.
env
==
"dev"
)
{
return
"
192.168.210.240
:80/getNames"
;
return
"
http://localhost
:80/getNames"
;
}
else
{
}
else
{
return
"http://aliossjava-service/getNames"
;
return
"http://aliossjava-service/getNames"
;
}
}
...
...
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