|
@@ -3,6 +3,7 @@ package com.cyksj.web.controller.user;
|
|
|
import cn.hutool.core.codec.Base64;
|
|
import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
import com.cyksj.common.EnvCommonService;
|
|
@@ -22,6 +23,7 @@ import com.cyksj.model.dto.JsSdkTicket;
|
|
|
import com.cyksj.model.entity.PhoneCode;
|
|
import com.cyksj.model.entity.PhoneCode;
|
|
|
import com.cyksj.model.entity.User;
|
|
import com.cyksj.model.entity.User;
|
|
|
import com.cyksj.model.request.LoginReq;
|
|
import com.cyksj.model.request.LoginReq;
|
|
|
|
|
+import com.cyksj.model.response.GoogleLoginRep;
|
|
|
import com.cyksj.model.response.UserAuthLoginResp;
|
|
import com.cyksj.model.response.UserAuthLoginResp;
|
|
|
import com.cyksj.model.response.WxGzhQrCodeTicketRep;
|
|
import com.cyksj.model.response.WxGzhQrCodeTicketRep;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
@@ -42,6 +44,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.Cookie;
|
|
import javax.servlet.http.Cookie;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -431,4 +435,20 @@ public class AuthorizationController {
|
|
|
log.info("微信授权转跳.url: {}", url);
|
|
log.info("微信授权转跳.url: {}", url);
|
|
|
response.sendRedirect(url.contains("?") ? url + "&t=" + StpUserUtil.getTokenValue() : url + "?t=" + StpUserUtil.getTokenValue());
|
|
response.sendRedirect(url.contains("?") ? url + "&t=" + StpUserUtil.getTokenValue() : url + "?t=" + StpUserUtil.getTokenValue());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/google/login")
|
|
|
|
|
+ public Result<UserAuthLoginResp> googleLogin(LoginReq loginReq,String credential) throws Exception {
|
|
|
|
|
+ log.info("google loginReq:{},credential:{}", loginReq, credential);
|
|
|
|
|
+ String result = HttpUtil.post("https://yinhedvd.com/8083/api2/auth/google/login/inner?credential=" + credential, new HashMap<>());
|
|
|
|
|
+ log.info("google result:{}",result);
|
|
|
|
|
+ GoogleLoginRep googleLoginRep = Jsons.parseObject(Jsons.toMap(result).get("data"), GoogleLoginRep.class);
|
|
|
|
|
+ loginReq.setType(3);
|
|
|
|
|
+ loginReq.setEmail(googleLoginRep.getEmail());
|
|
|
|
|
+ loginReq.setSubject(googleLoginRep.getSubject());
|
|
|
|
|
+ User user = userService.webLogin(loginReq);
|
|
|
|
|
+ //写回登陆信息
|
|
|
|
|
+ StpUserUtil.login(user.getId());
|
|
|
|
|
+ UserAuthLoginResp loginPhoneRep = new UserAuthLoginResp(StpUserUtil.getTokenValue(), user.getShowId(), user.getNickname(), user.getHeadimgurl());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(loginPhoneRep);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|