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
82837cc4
Commit
82837cc4
authored
May 08, 2019
by
何娜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
taxh5 ip定位修复
parent
8e5a1516
Pipeline
#7185
passed with stage
in 9 seconds
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
partner.js
app/service/partner.js
+4
-4
scripts.js
app/service/scripts.js
+5
-4
No files found.
app/service/partner.js
View file @
82837cc4
...
@@ -17,7 +17,7 @@ class PartnerService extends Service {
...
@@ -17,7 +17,7 @@ class PartnerService extends Service {
try
{
try
{
return
JSON
.
parse
(
data
);
return
JSON
.
parse
(
data
);
}
catch
(
err
)
{
}
catch
(
err
)
{
ctx
.
logger
.
error
(
'【Scripts】fetch
Params
'
,
redisThemePrefix
+
appKey
,
'result:'
,
data
,
err
);
ctx
.
logger
.
error
(
'【Scripts】fetch
Theme
'
,
redisThemePrefix
+
appKey
,
'result:'
,
data
,
err
);
await
this
.
app
.
redis
.
del
(
redisThemePrefix
+
appKey
);
await
this
.
app
.
redis
.
del
(
redisThemePrefix
+
appKey
);
}
}
}
}
...
@@ -32,7 +32,7 @@ class PartnerService extends Service {
...
@@ -32,7 +32,7 @@ class PartnerService extends Service {
subject
:
'it'
subject
:
'it'
}
}
});
});
ctx
.
logger
.
info
(
`【Partner】 fetchTheme
${
host
+
fetchTheme
}
/
${
appKey
}
`
,
ret
.
data
);
ctx
.
logger
.
info
(
`【Partner】 fetchTheme
${
host
+
fetchTheme
}
/
${
appKey
}
`
,
JSON
.
stringify
(
ret
.
data
)
);
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
length
>
0
&&
ret
.
data
[
0
].
appKey
===
appKey
)
{
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
length
>
0
&&
ret
.
data
[
0
].
appKey
===
appKey
)
{
await
this
.
app
.
redis
.
set
(
redisThemePrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
[
0
]),
'EX'
,
300
);
await
this
.
app
.
redis
.
set
(
redisThemePrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
[
0
]),
'EX'
,
300
);
}
}
...
@@ -63,7 +63,7 @@ class PartnerService extends Service {
...
@@ -63,7 +63,7 @@ class PartnerService extends Service {
appKey
appKey
}
}
});
});
ctx
.
logger
.
info
(
`【Partner】 fetch
Theme
${
host
+
fetchInfo
}
?appKey=
${
appKey
}
`
,
ret
.
data
);
ctx
.
logger
.
info
(
`【Partner】 fetch
Info
${
host
+
fetchInfo
}
?appKey=
${
appKey
}
`
,
JSON
.
stringify
(
ret
.
data
)
);
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
length
>
0
&&
ret
.
data
[
0
].
appKey
===
appKey
)
{
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
length
>
0
&&
ret
.
data
[
0
].
appKey
===
appKey
)
{
await
this
.
app
.
redis
.
set
(
redisInfoPrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
[
0
]),
'EX'
,
300
);
await
this
.
app
.
redis
.
set
(
redisInfoPrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
[
0
]),
'EX'
,
300
);
}
}
...
@@ -91,7 +91,7 @@ class PartnerService extends Service {
...
@@ -91,7 +91,7 @@ class PartnerService extends Service {
dataType
:
'json'
,
dataType
:
'json'
,
method
:
'GET'
,
method
:
'GET'
,
});
});
ctx
.
logger
.
info
(
`【Partner】 fetch
Theme
${
url
}
`
,
JSON
.
stringify
(
ret
.
data
));
ctx
.
logger
.
info
(
`【Partner】 fetch
Scripts
${
url
}
`
,
JSON
.
stringify
(
ret
.
data
));
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
id
===
appKey
)
{
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
id
===
appKey
)
{
await
this
.
app
.
redis
.
set
(
redisScriptsPrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
),
'EX'
,
300
);
await
this
.
app
.
redis
.
set
(
redisScriptsPrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
),
'EX'
,
300
);
}
}
...
...
app/service/scripts.js
View file @
82837cc4
...
@@ -124,9 +124,10 @@ class ScriptsService extends Service {
...
@@ -124,9 +124,10 @@ class ScriptsService extends Service {
}
}
async
fetchCityFormIp
()
{
async
fetchCityFormIp
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
{
ip
}
=
ctx
.
request
;
let
{
ip
}
=
ctx
.
request
;
ctx
.
logger
.
info
(
ctx
.
request
);
ctx
.
logger
.
info
(
'【fetchCityFormIp】ip'
,
ip
);
const
url
=
`https://api.map.baidu.com/location/ip?ak=3TBenWOhPygtFFazaR5kSibU&ip=
${
ip
}
`
;
ip
=
ip
.
split
(
','
);
const
url
=
`https://api.map.baidu.com/location/ip?ak=3TBenWOhPygtFFazaR5kSibU&ip=
${
ip
[
0
]}
`
;
const
result
=
await
ctx
.
curl
(
url
,
{
const
result
=
await
ctx
.
curl
(
url
,
{
charset
:
'utf-8'
,
charset
:
'utf-8'
,
timeout
:
[
'30s'
,
'30s'
],
timeout
:
[
'30s'
,
'30s'
],
...
@@ -148,7 +149,7 @@ class ScriptsService extends Service {
...
@@ -148,7 +149,7 @@ class ScriptsService extends Service {
dataType
:
'json'
,
dataType
:
'json'
,
contentType
:
'json'
,
contentType
:
'json'
,
});
});
ctx
.
logger
.
info
(
`fetchScriptByCityName,
${
baseURL
+
fetchScriptByCityNameUrl
+
'?name='
+
name
}
`
,
'result:'
,
result
.
data
);
ctx
.
logger
.
info
(
`fetchScriptByCityName,
${
baseURL
+
fetchScriptByCityNameUrl
+
'?name='
+
name
}
`
,
'result:'
,
JSON
.
stringify
(
result
.
data
)
);
return
result
.
data
;
return
result
.
data
;
}
}
...
...
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