|
@@ -26,7 +26,8 @@ import java.net.URLEncoder;
|
|
@RequestMapping("/open/jd")
|
|
@RequestMapping("/open/jd")
|
|
public class JdApiController {
|
|
public class JdApiController {
|
|
|
|
|
|
- private static String DOMAIN = "http://127.0.0.1:80";
|
|
|
|
|
|
+ private static final String DOMAIN = "http://127.0.0.1:80";
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private JdApiService jdApiService;
|
|
private JdApiService jdApiService;
|
|
|
|
|
|
@@ -39,28 +40,22 @@ public class JdApiController {
|
|
String msg = "";
|
|
String msg = "";
|
|
if (StrUtil.isBlank(code) || StrUtil.isBlank(state)) {
|
|
if (StrUtil.isBlank(code) || StrUtil.isBlank(state)) {
|
|
msg = "参数错误";
|
|
msg = "参数错误";
|
|
-// response.sendError(HttpStatus.HTTP_BAD_REQUEST, "参数错误");
|
|
|
|
-// return;
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
//获取token并且入库
|
|
//获取token并且入库
|
|
try {
|
|
try {
|
|
jdApiService.getAccessTokenByCode(code);
|
|
jdApiService.getAccessTokenByCode(code);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("京东获取token异常", e);
|
|
log.error("京东获取token异常", e);
|
|
msg = "京东获取token异常";
|
|
msg = "京东获取token异常";
|
|
-// response.sendError(HttpStatus.HTTP_INTERNAL_ERROR, e.getMessage());
|
|
|
|
-// return;
|
|
|
|
}
|
|
}
|
|
response.sendRedirect(DOMAIN + "/callback.html?msg=" + URLEncoder.encode(msg));
|
|
response.sendRedirect(DOMAIN + "/callback.html?msg=" + URLEncoder.encode(msg));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@RequestMapping("/build2LoginUrl")
|
|
@RequestMapping("/build2LoginUrl")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String build2LoginUrl() {
|
|
public String build2LoginUrl() {
|
|
- String url = jdApiService.build2LoginUrl();
|
|
|
|
-// String url = DOMAIN + "/testLogin.html?"+ IdUtil.getSnowflakeNextIdStr();
|
|
|
|
- return url;
|
|
|
|
|
|
+ return jdApiService.build2LoginUrl();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|