Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
taxh5
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data_server
taxh5
Commits
d7eb204f
Commit
d7eb204f
authored
Mar 16, 2019
by
何娜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tax fix
parent
75360ca2
Pipeline
#4562
passed with stage
in 7 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
50 deletions
+128
-50
task.js
app/controller/task.js
+4
-9
application.js
app/extend/application.js
+85
-9
taskStatus.js
app/model/taskStatus.js
+1
-1
task.js
app/service/task.js
+21
-14
config.prod.js
config/config.prod.js
+17
-17
No files found.
app/controller/task.js
View file @
d7eb204f
...
@@ -54,14 +54,10 @@ class TaskController extends Controller {
...
@@ -54,14 +54,10 @@ class TaskController extends Controller {
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
ctx
.
validate
(
this
.
createRule
);
ctx
.
validate
(
this
.
createRule
);
const
{
scriptId
,
orderId
,
userId
}
=
ctx
.
request
.
body
;
const
{
scriptId
,
orderId
,
userId
}
=
ctx
.
request
.
body
;
ctx
.
logger
.
info
(
typeof
(
ctx
.
app
.
cityTypeLists
),
'cityTypeLists'
,
ctx
.
app
.
cityTypeLists
)
const
channelType
=
await
ctx
.
app
.
redis
.
get
(
scriptId
);
for
(
let
item
of
ctx
.
app
.
cityTypeLists
){
ctx
.
app
.
redis
.
set
(
scriptId
,
channelType
,
"EX"
,
3600
);
if
(
item
.
id
===
scriptId
){
const
taskId
=
await
service
.
task
.
create
({
scriptId
,
channelType
});
ctx
.
app
.
channelType
=
item
.
type
;
await
service
.
order
.
update
({
orderId
,
cityId
:
scriptId
,
taskId
,
userId
,
text1
:
channelType
});
}
}
const
taskId
=
await
service
.
task
.
create
(
scriptId
);
await
service
.
order
.
update
({
orderId
,
cityId
:
scriptId
,
taskId
,
userId
,
text1
:
ctx
.
app
.
channelType
});
await
service
.
cache
.
set
({
await
service
.
cache
.
set
({
key
:
taskId
,
key
:
taskId
,
value
:
{
status
:
'init'
,
note
:
{
message
:
'init'
}},
value
:
{
status
:
'init'
,
note
:
{
message
:
'init'
}},
...
@@ -186,7 +182,6 @@ class TaskController extends Controller {
...
@@ -186,7 +182,6 @@ class TaskController extends Controller {
// ctx.validate(this.cityConfigRule);
// ctx.validate(this.cityConfigRule);
// await service.signature.signatureCheck(ctx.request.body);
// await service.signature.signatureCheck(ctx.request.body);
const
result
=
await
service
.
task
.
getCityList
();
const
result
=
await
service
.
task
.
getCityList
();
console
.
log
(
'Type'
+
JSON
.
stringify
(
ctx
.
app
.
cityTypeLists
[
0
]))
ctx
.
success
({
ctx
.
success
({
code
:
0
,
code
:
0
,
data
:
result
data
:
result
...
...
app/extend/application.js
View file @
d7eb204f
'use strict'
;
'use strict'
;
const
REDIS_CACHE
=
Symbol
(
'Context#RedisCache'
);
const
NODE_CACHE
=
Symbol
(
'Context#NodeCache'
);
const
NODE_CACHE
=
Symbol
(
'Context#NodeCache'
);
const
NodeCache
=
require
(
'node-cache'
);
const
NodeCache
=
require
(
'node-cache'
);
...
@@ -10,7 +12,7 @@ class Cache {
...
@@ -10,7 +12,7 @@ class Cache {
this
.
name
=
'unknown-cache'
;
this
.
name
=
'unknown-cache'
;
}
}
async
val
(
key
,
next
,
ttl
)
{
async
val
(
key
,
next
,
ttl
)
{
// key存在取值,不存在存值
let
data
=
await
this
.
get
(
key
);
let
data
=
await
this
.
get
(
key
);
if
(
data
)
{
if
(
data
)
{
return
data
;
return
data
;
...
@@ -36,13 +38,85 @@ class Cache {
...
@@ -36,13 +38,85 @@ class Cache {
}
}
}
}
this
.
app
.
logger
.
info
(
`[cache](
${
+
new
Date
()
-
startTime
}
ms)
${
this
.
name
}
.
${
key
}
:
${
jsonText
}
`
);
this
.
app
.
logger
.
info
(
`[cache](
${
+
new
Date
()
-
startTime
}
ms)
${
this
.
name
}
.
${
key
}
:
${
jsonText
}
`
);
// this.cacheLog(startTime, key, jsonText);
return
ret
;
return
ret
;
}
}
async
set
(
key
,
value
,
ttl
=
60
)
{
async
set
(
key
,
value
,
ttl
=
60
)
{
return
await
this
.
_set
(
key
,
value
,
ttl
);
return
await
this
.
_set
(
key
,
value
,
ttl
);
}
}
async
del
(
key
){
return
await
this
.
_del
(
key
)
async
hget
(
key
)
{
const
startTime
=
+
new
Date
();
let
ret
;
if
(
!
this
.
hasOwnProperty
(
'_hget'
)
&&
this
.
hasOwnProperty
(
'_get'
))
{
ret
=
await
this
.
_get
(
key
);
return
ret
;
}
ret
=
await
this
.
_hget
(
key
);
this
.
chcheLog
(
startTime
,
key
,
ret
);
return
ret
;
}
async
hset
(
key
,
obj
,
ttl
=
60
)
{
if
(
!
this
.
hasOwnProperty
(
'_hset'
)
&&
this
.
hasOwnProperty
(
'_set'
))
{
return
await
this
.
_set
(
key
,
obj
,
ttl
);
}
return
await
this
.
_hset
(
key
,
obj
,
ttl
);
}
chcheLog
(
startTime
,
key
,
value
)
{
if
(
typeof
value
===
'object'
)
{
value
=
JSON
.
stringify
(
value
);
}
this
.
app
.
logger
.
info
(
`[cache](
${
+
new
Date
()
-
startTime
}
ms)
${
this
.
name
}
.
${
key
}
:
${
value
}
`
);
}
}
class
RedisCacheWrap
extends
Cache
{
constructor
(
app
,
redis
)
{
super
(
app
);
this
.
redis
=
redis
;
this
.
name
=
'redis-cache'
;
}
async
_get
(
key
)
{
const
{
redis
}
=
this
;
let
value
=
await
redis
.
get
(
key
);
if
(
value
===
null
)
{
value
=
undefined
;
}
if
(
value
)
{
value
=
JSON
.
parse
(
value
);
}
return
value
;
}
async
_set
(
key
,
value
,
ttl
)
{
const
{
redis
}
=
this
;
value
=
JSON
.
stringify
(
value
);
if
(
ttl
>
0
)
{
await
redis
.
set
(
key
,
value
,
'EX'
,
ttl
);
}
else
{
await
redis
.
set
(
key
,
value
);
}
}
async
_hget
(
key
)
{
const
{
redis
}
=
this
;
let
value
=
await
redis
.
hgetall
(
key
);
if
(
value
===
null
)
{
value
=
undefined
;
}
return
value
;
}
async
_hset
(
key
,
obj
,
ttl
)
{
const
{
redis
}
=
this
;
if
(
typeof
obj
!==
'object'
)
{
obj
=
JSON
.
parse
(
obj
);
}
if
(
ttl
>
0
)
{
await
redis
.
hmset
(
key
,
obj
);
}
else
{
await
redis
.
hmset
(
key
,
obj
);
}
}
}
}
}
...
@@ -65,18 +139,19 @@ class NodeCacheWrap extends Cache {
...
@@ -65,18 +139,19 @@ class NodeCacheWrap extends Cache {
cache
.
set
(
key
,
value
);
cache
.
set
(
key
,
value
);
}
}
}
}
async
_del
(
key
){
const
{
cache
}
=
this
;
cache
.
del
(
key
);
}
}
}
module
.
exports
=
{
module
.
exports
=
{
get
memcache
()
{
if
(
!
this
[
REDIS_CACHE
])
{
this
[
REDIS_CACHE
]
=
new
RedisCacheWrap
(
this
,
this
.
redis
);
}
return
this
[
REDIS_CACHE
];
},
get
cache
()
{
get
cache
()
{
if
(
!
this
[
NODE_CACHE
])
{
if
(
!
this
[
NODE_CACHE
])
{
this
[
NODE_CACHE
]
=
new
NodeCacheWrap
(
this
);
this
[
NODE_CACHE
]
=
new
NodeCacheWrap
(
this
);
}
}
return
this
[
NODE_CACHE
];
return
this
[
NODE_CACHE
];
},
},
};
};
\ No newline at end of file
app/model/taskStatus.js
View file @
d7eb204f
...
@@ -110,7 +110,7 @@ module.exports = app => {
...
@@ -110,7 +110,7 @@ module.exports = app => {
field
:
'text3'
,
field
:
'text3'
,
},
},
},
{
},
{
tableName
:
'
iith5
_status'
,
tableName
:
'
tax
_status'
,
// timestamps: false,
// timestamps: false,
});
});
...
...
app/service/task.js
View file @
d7eb204f
...
@@ -33,23 +33,22 @@ class TaskService extends Service {
...
@@ -33,23 +33,22 @@ class TaskService extends Service {
}
}
_checkSuccess
(
result
)
{
_checkSuccess
(
result
)
{
//
if (result.status !== 200) {
if
(
result
.
status
!==
200
)
{
//
const errorMsg = result.data && result.data.error_msg ? result.data.error_msg : 'unknown error';
const
errorMsg
=
result
.
data
&&
result
.
data
.
error_msg
?
result
.
data
.
error_msg
:
'unknown error'
;
//
this.ctx.throw(result.status, errorMsg);
this
.
ctx
.
throw
(
result
.
status
,
errorMsg
);
//
}
}
if
(
result
.
data
.
code
!==
0
)
{
if
(
result
.
data
.
code
!==
0
)
{
this
.
ctx
.
throw
(
400
,
{
message
:
result
.
data
.
msg
,
code
:
result
.
data
.
code
});
this
.
ctx
.
throw
(
400
,
{
message
:
result
.
data
.
msg
,
code
:
result
.
data
.
code
});
}
}
}
}
async
create
(
data
)
{
async
create
(
{
scriptId
,
channelType
}
)
{
const
{
createTaskUrl
,
ctx
}
=
this
;
const
{
createTaskUrl
,
ctx
}
=
this
;
const
result
=
await
this
.
_request
(
createTaskUrl
,
c
tx
.
app
.
c
hannelType
,
{
const
result
=
await
this
.
_request
(
createTaskUrl
,
channelType
,
{
method
:
'post'
,
method
:
'post'
,
data
:
{
cityId
:
data
},
data
:
{
cityId
:
scriptId
},
});
});
ctx
.
logger
.
info
(
`【Task】create
${
createTaskUrl
}
cityId:
${
data
}
result:`
,
JSON
.
stringify
(
result
.
data
));
ctx
.
logger
.
info
(
`【Task】create
${
createTaskUrl
}
cityId:
${
scriptId
}
channelType:
${
channelType
}
result:`
,
JSON
.
stringify
(
result
.
data
));
ctx
.
logger
.
info
(
'channelType'
,
ctx
.
app
.
channelType
);
this
.
_checkSuccess
(
result
);
this
.
_checkSuccess
(
result
);
return
result
.
data
.
data
.
taskId
;
return
result
.
data
.
data
.
taskId
;
}
}
...
@@ -132,18 +131,26 @@ class TaskService extends Service {
...
@@ -132,18 +131,26 @@ class TaskService extends Service {
state
:
city
.
state
,
state
:
city
.
state
,
queryParam
:
city
.
queryParam
queryParam
:
city
.
queryParam
});
});
cityTypeLists
.
push
({
// cityTypeLists.push({
// province: city.province,
// name: city.name,
// id: city.id,
// state: city.state,
// type: city.type,
// });
let
obj
=
{
province
:
city
.
province
,
province
:
city
.
province
,
name
:
city
.
name
,
name
:
city
.
name
,
id
:
city
.
id
,
id
:
city
.
id
,
state
:
city
.
state
,
state
:
city
.
state
,
type
:
city
.
type
,
type
:
city
.
type
});
}
ctx
.
app
.
redis
.
set
(
city
.
id
,
city
.
type
,
"EX"
,
3600
)
});
});
cityLists
.
push
(
newProv
);
cityLists
.
push
(
newProv
);
});
});
ctx
.
app
.
cityTypeLists
=
cityTypeLists
;
// await ctx.app.redis.set('cityTypeLists', cityTypeLists, "EX", 3600)
;
ctx
.
logger
.
info
(
'-------------'
,
JSON
.
stringify
(
ctx
.
app
.
cityTypeLists
))
// ctx.logger.info(ctx.app.redis.get(1
))
return
cityLists
;
return
cityLists
;
}
}
}
}
...
...
config/config.prod.js
View file @
d7eb204f
...
@@ -30,7 +30,7 @@ module.exports = () => {
...
@@ -30,7 +30,7 @@ module.exports = () => {
config
.
partnerAPI
=
{
config
.
partnerAPI
=
{
host
:
process
.
env
.
PARTNERAPI_HOST
,
host
:
process
.
env
.
PARTNERAPI_HOST
,
fetchTheme
:
'/chaos/theme'
,
fetchTheme
:
'/chaos/
partners/
theme'
,
fetchScripts
:
'/chaos/partners/scripts'
,
fetchScripts
:
'/chaos/partners/scripts'
,
fetchAgreements
:
'/chaos/agreements'
,
fetchAgreements
:
'/chaos/agreements'
,
redisThemePrefix
:
'URANUS.HF.PARNTERS.THEME'
,
redisThemePrefix
:
'URANUS.HF.PARNTERS.THEME'
,
...
@@ -42,17 +42,17 @@ module.exports = () => {
...
@@ -42,17 +42,17 @@ module.exports = () => {
config
.
scriptsAPI
=
{
config
.
scriptsAPI
=
{
host
:
'https://dev-nginx.jianbing.com/zeus-api/v1'
,
host
:
'https://dev-nginx.jianbing.com/zeus-api/v1'
,
fetchScriptsUrl
:
'/chaos/
hf
/two_dimension_array/queries'
,
fetchScriptsUrl
:
'/chaos/
it
/two_dimension_array/queries'
,
fetchOneScriptUrl
:
'/chaos/
hf
/two_dimension_array/info'
,
fetchOneScriptUrl
:
'/chaos/
it
/two_dimension_array/info'
,
fetchParamsInfoUrl
:
'/chaos/
hf
/login_param_map'
,
fetchParamsInfoUrl
:
'/chaos/
it
/login_param_map'
,
fetchQueryButtonUrl
:
'/chaos/
hf
/query_button'
,
fetchQueryButtonUrl
:
'/chaos/
it
/query_button'
,
fetchHelpUrl
:
'/chaos/
hf
/help'
,
fetchHelpUrl
:
'/chaos/
it
/help'
,
fetchNoticeUrl
:
'/chaos/
hf
/notice'
,
fetchNoticeUrl
:
'/chaos/
it
/notice'
,
fetchHubSeriptsUrl
:
'/chaos/
hf
/hubs'
,
fetchHubSeriptsUrl
:
'/chaos/
it
/hubs'
,
fetchScriptByCityNameUrl
:
'/chaos/
hf
/city_scripts'
,
fetchScriptByCityNameUrl
:
'/chaos/
it
/city_scripts'
,
redisScriptsKey
:
'
DATA_SERVER_SHEBAO
.SCRIPTS'
,
redisScriptsKey
:
'
URANUS.IT
.SCRIPTS'
,
redisParamsKey
:
'
DATA_SERVER_SHEBAO
.PARAMS'
,
redisParamsKey
:
'
URANUS.IT
.PARAMS'
,
redisScriptListKey
:
'
DATA_SERVER_SHEBAO
.SCRIPTLIST'
,
redisScriptListKey
:
'
URANUS.IT
.SCRIPTLIST'
,
};
};
config
.
storageAPI
=
{
config
.
storageAPI
=
{
...
@@ -79,11 +79,11 @@ module.exports = () => {
...
@@ -79,11 +79,11 @@ module.exports = () => {
};
};
config
.
lockKeys
=
{
config
.
lockKeys
=
{
fecthHub
:
'
NEWSB.HF
.HUBS.LOCK'
,
fecthHub
:
'
URANUS.IT
.HUBS.LOCK'
,
fecteToken
:
'
NEWSB.HF
.TOKEN.LOCK'
,
fecteToken
:
'
URANUS.IT
.TOKEN.LOCK'
,
token
:
'
NEWSB.HF
.TOKEN'
,
token
:
'
URANUS.IT
.TOKEN'
,
fecthParnters
:
'
NEWSB
.PARNTERS.LOCK'
,
fecthParnters
:
'
URANUS
.PARNTERS.LOCK'
,
taskPrefix
:
'
NEWSB
.TASK'
,
taskPrefix
:
'
URANUS
.TASK'
,
};
};
config
.
sequelize
=
{
config
.
sequelize
=
{
...
...
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