Commit 49233d86 authored by 郝增润's avatar 郝增润

一级域名首页获取

parent 97d0e348
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
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 "";
}
}
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 "";
}
}
......@@ -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<>();
......
......@@ -233,7 +233,6 @@ public class TaobaoController {
return uid;
}
/**
* 发放优惠券
*/
......
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
......@@ -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>
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment