package com.gear.customer.swx.controller; import com.alibaba.fastjson2.JSONObject; import com.gear.common.exception.CustomerException; import com.gear.common.utils.http.HttpUtils; import com.gear.common.vo.Result; import com.gear.customer.swx.biz.SwxBizUserLogin; import com.gear.customer.swx.utils.GoogleTokenDto; import com.gear.customer.swx.vo.request.SendCodeVo; import com.gear.customer.swx.vo.request.SwxUserLoginVo; import com.gear.customer.swx.vo.request.SwxUserRegisterVo; import com.gear.customer.swx.vo.response.SwxUserInfoVo; import com.google.api.client.auth.oauth2.TokenResponse; import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.gson.GsonFactory; import org.apache.http.client.utils.HttpClientUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.converter.json.GsonFactoryBean; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.*; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClient; import reactor.netty.transport.ProxyProvider; import java.io.IOException; import java.security.GeneralSecurityException; import java.util.Arrays; import java.util.Collections; @RestController @RequestMapping("/swx/customer/login") public class SwxUserLoginController { @Autowired private SwxBizUserLogin swxBizUserLogin; @PostMapping("/register") public Result register(@RequestBody SwxUserRegisterVo swxUserRegisterVo){ try { return Result.OK(swxBizUserLogin.register(swxUserRegisterVo)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } @GetMapping("/checkUserNameOrPhone") public Result checkUserNameOrPhone(@RequestParam("type")Integer type,@RequestParam("value")String value){ return Result.OK(swxBizUserLogin.checkUserNameOrPhone(type,value)); } @PostMapping("/login") public Result login(@RequestBody SwxUserLoginVo vo){ try { return Result.OK(swxBizUserLogin.login(vo)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } @PostMapping("/sendCode") public Result sendCode(@RequestBody SendCodeVo vo){ try { return Result.OK(swxBizUserLogin.sendCode(vo)); }catch (CustomerException e){ return Result.error(e.getMessage()); } catch (IOException e) { return Result.error(e.getMessage()); } } @PostMapping("/loginByGoogle") public Result loginByGoogle(@RequestBody SwxUserRegisterVo swxUserRegisterVo){ try { return Result.OK(swxBizUserLogin.loginByGoogle(swxUserRegisterVo)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } }