Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jd-activity
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
曾水平
jd-activity
Commits
49233d86
Commit
49233d86
authored
Dec 25, 2021
by
郝增润
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一级域名首页获取
parent
97d0e348
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
7 deletions
+160
-7
EncodingUtil.java
...va/cn/com/duiba/jdactivity/common/utils/EncodingUtil.java
+74
-0
HtmlController.java
...va/cn/com/duiba/jdactivity/controller/HtmlController.java
+50
-0
IndexController.java
...a/cn/com/duiba/jdactivity/controller/IndexController.java
+24
-0
Open2DuibaController.java
...com/duiba/jdactivity/controller/Open2DuibaController.java
+8
-1
TaobaoController.java
.../cn/com/duiba/jdactivity/controller/TaobaoController.java
+0
-1
application.properties
src/main/resources/application.properties
+3
-1
autologin.html
src/main/resources/templates/autologin.html
+0
-4
autologin2.html
src/main/resources/templates/autologin2.html
+1
-0
No files found.
src/main/java/cn/com/duiba/jdactivity/common/utils/EncodingUtil.java
0 → 100644
View file @
49233d86
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
/**
* Utility class for JavaScript compatible UTF-8 encoding and decoding.
*
* @see http://stackoverflow.com/questions/607176/java-equivalent-to-javascripts-encodeuricomponent-that-produces-identical-output
* @author John Topley
*/
public
class
EncodingUtil
{
/**
* Decodes the passed UTF-8 String using an algorithm that's compatible with
* JavaScript's <code>decodeURIComponent</code> function. Returns
* <code>null</code> if the String is <code>null</code>.
*
* @param s The UTF-8 encoded String to be decoded
* @return the decoded String
*/
public
static
String
decodeURIComponent
(
String
s
)
{
if
(
s
==
null
)
{
return
null
;
}
String
result
=
null
;
try
{
result
=
URLDecoder
.
decode
(
s
,
"UTF-8"
);
}
// This exception should never occur.
catch
(
UnsupportedEncodingException
e
)
{
result
=
s
;
}
return
result
;
}
/**
* Encodes the passed String as UTF-8 using an algorithm that's compatible
* with JavaScript's <code>encodeURIComponent</code> function. Returns
* <code>null</code> if the String is <code>null</code>.
*
* @param s The String to be encoded
* @return the encoded String
*/
public
static
String
encodeURIComponent
(
String
s
)
{
String
result
=
null
;
try
{
result
=
URLEncoder
.
encode
(
s
,
"UTF-8"
)
.
replaceAll
(
"\\+"
,
"%20"
)
.
replaceAll
(
"\\%21"
,
"!"
)
.
replaceAll
(
"\\%27"
,
"'"
)
.
replaceAll
(
"\\%28"
,
"("
)
.
replaceAll
(
"\\%29"
,
")"
)
.
replaceAll
(
"\\%7E"
,
"~"
);
}
// This exception should never occur.
catch
(
UnsupportedEncodingException
e
)
{
result
=
s
;
}
return
result
;
}
/**
* Private constructor to prevent this class from being instantiated.
*/
private
EncodingUtil
()
{
super
();
}
}
\ No newline at end of file
src/main/java/cn/com/duiba/jdactivity/controller/HtmlController.java
0 → 100644
View file @
49233d86
package
cn
.
com
.
duiba
.
jdactivity
.
controller
;
import
cn.com.duiba.jdactivity.common.utils.HttpClientUtil
;
import
com.alibaba.fastjson.JSON
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Optional
;
/**
* @author zsp (zengshuiping@duiba.com.cn)
* @date 2021/5/18 12:51
*/
@Controller
@RequestMapping
(
"/jd"
)
public
class
HtmlController
{
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
HtmlController
.
class
);
@Resource
private
HttpClientUtil
httpClientUtil
;
@Value
(
"${serverless.request.html.url}"
)
private
String
serverlessDomain
;
@RequestMapping
(
value
=
"/{projectId}/index.html"
)
@ResponseBody
public
String
index
(
@PathVariable
String
projectId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
response
.
setHeader
(
"Content-Type"
,
"text/html;charset=UTF-8"
);
String
html
=
httpClientUtil
.
sendGet
(
serverlessDomain
+
"/tbjd/"
+
projectId
+
"/c/test/index.html"
);
return
html
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
LOGGER
.
info
(
"获取index页报错,result={}"
,
e
);
}
return
""
;
}
}
src/main/java/cn/com/duiba/jdactivity/controller/IndexController.java
View file @
49233d86
package
cn
.
com
.
duiba
.
jdactivity
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Optional
;
/**
* @author zsp (zengshuiping@duiba.com.cn)
* @date 2021/5/18 12:51
...
...
@@ -12,6 +21,7 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping
(
"/"
)
public
class
IndexController
{
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
IndexController
.
class
);
@GetMapping
(
"/autologin"
)
public
ModelAndView
autologin
()
{
...
...
@@ -47,4 +57,18 @@ public class IndexController {
modelAndView
.
setViewName
(
"jdfission"
);
return
modelAndView
;
}
@RequestMapping
(
value
=
"/{projectId}/index.html"
)
@ResponseBody
public
String
index
(
@PathVariable
String
projectId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
response
.
setHeader
(
"Content-Type"
,
"text/html;charset=UTF-8"
);
String
html
=
""
;
return
html
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
LOGGER
.
info
(
"获取index页报错,result={}"
,
e
);
}
return
""
;
}
}
src/main/java/cn/com/duiba/jdactivity/controller/Open2DuibaController.java
View file @
49233d86
...
...
@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -233,12 +234,18 @@ public class Open2DuibaController {
/**
* 生成免登url
*/
private
String
autologin
(
DuibaAppEnum
duibaApp
,
String
uid
,
String
nickName
,
String
avatar
,
String
redirectUrl
,
String
env
,
String
credits
)
{
private
String
autologin
(
DuibaAppEnum
duibaApp
,
String
uid
,
String
nickName
,
String
avatar
,
String
redirectUrl
,
String
env
,
String
credits
)
throws
UnsupportedEncodingException
{
if
(
env
!=
null
&&
env
.
equals
(
"taobao"
))
{
LOGGER
.
info
(
"taobaourl,avatar={},nickname={},uid={},url={}"
,
avatar
,
nickName
,
uid
,
redirectUrl
+
"&avatar="
+
avatar
+
"&nickname="
+
nickName
+
"&uid="
+
uid
);
LOGGER
.
info
(
"redirectUrl={}"
,
redirectUrl
);
return
redirectUrl
+
"&avatar="
+
avatar
+
"&nickname="
+
nickName
+
"&uid="
+
uid
;
}
if
(
env
!=
null
&&
env
.
equals
(
"taobaoshare"
))
{
LOGGER
.
info
(
"taobaourl,avatar={},nickname={},uid={},url={}"
,
avatar
,
nickName
,
uid
,
redirectUrl
+
"&avatar="
+
avatar
+
"&nickname="
+
nickName
+
"&uid="
+
uid
);
LOGGER
.
info
(
"redirectUrl={}"
,
redirectUrl
);
return
URLDecoder
.
decode
(
redirectUrl
,
"UTF-8"
)
+
"&avatar="
+
avatar
+
"&nickname="
+
nickName
+
"&uid="
+
uid
;
}
CreditTool
tool
=
new
CreditTool
(
duibaApp
.
getAppKey
(),
duibaApp
.
getAppSecret
());
Map
<
String
,
String
>
params
=
new
HashMap
<>();
...
...
src/main/java/cn/com/duiba/jdactivity/controller/TaobaoController.java
View file @
49233d86
...
...
@@ -233,7 +233,6 @@ public class TaobaoController {
return
uid
;
}
/**
* 发放优惠券
*/
...
...
src/main/resources/application.properties
View file @
49233d86
spring.application.name
=
jd-activity
spring.profiles.active
=
prod
spring.profiles.active
=
dev
# 先排除一些autoconfigure
spring.autoconfigure.exclude
=
# tomcat
...
...
@@ -35,3 +35,5 @@ spring.datasource.tomcat.max-age=1800000
server.shutdown
=
graceful
spring.lifecycle.timeout-per-shutdown-phase
=
30s
serverless.request.html.url
=
http://yun.duiba.com.cn
src/main/resources/templates/autologin.html
View file @
49233d86
...
...
@@ -18,13 +18,11 @@
<script>
// new VConsole();
</script>
<style>
.box
{
width
:
100%
;
height
:
100vh
;
}
.box
>
div
{
width
:
100%
;
height
:
30px
;
...
...
@@ -35,10 +33,8 @@
}
</style>
</head>
<body>
<div
class=
"box"
>
<!-- <div onclick="openLoginPanel()">唤起登录面板</div> -->
<!-- <div onclick="jumpToPage()">跳转</div> -->
</div>
...
...
src/main/resources/templates/autologin2.html
View file @
49233d86
...
...
@@ -98,6 +98,7 @@
function
autoLogin
(
token
)
{
var
redirect
=
getUrlParam
(
"redirect"
);
alert
(
redirect
)
var
env
=
getUrlParam
(
"env"
);
var
shopId
=
getUrlParam
(
"shopId"
);
var
venderId
=
getUrlParam
(
"venderId"
);
...
...
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