|
@@ -228,6 +228,34 @@ public class SysAccountMultilevelController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/wechatLogin2")
|
|
|
+ public String wechatLogin2(@RequestParam(name = "js_code")String js_code){
|
|
|
+ String URL = "https://api.weixin.qq.com/sns/jscode2session";
|
|
|
+ String appid = "wx135afbc98e976019";
|
|
|
+ String secret = "d22f323303373cbc0677634fbc2abbbf";
|
|
|
+ String grant_type = "authorization_code";
|
|
|
+
|
|
|
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(URL)
|
|
|
+ .queryParam("appid", appid)
|
|
|
+ .queryParam("secret", secret)
|
|
|
+ .queryParam("grant_type", grant_type)
|
|
|
+ .queryParam("js_code", js_code);
|
|
|
+
|
|
|
+ String urlWithParams = builder.toUriString();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String forObject = restTemplate.getForObject(urlWithParams, String.class);
|
|
|
+ System.out.println(forObject);
|
|
|
+ return forObject;
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 处理异常,例如记录日志、返回错误信息等
|
|
|
+ e.printStackTrace();
|
|
|
+ // 根据需要返回错误信息或处理逻辑
|
|
|
+ System.out.println(e.getMessage());
|
|
|
+ return "Error occurred: " + e.getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/saveWechat")
|
|
|
public Result saveWechat(HttpServletRequest request,@RequestBody Map<String,String> map){
|
|
|
String wechatId = map.get("wechatId");
|