<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="/static/login/JD_sass/JD1.css" /> <script src="/static/login/JD_js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script> <title>gulimall</title> </head> <body> <!--顶部logo--> <header> <a href="http://alatusmall.com"><img src="/static/login/JD_img/logo.jpg" /></a> <p>欢迎登录</p> <div class="top-1"> <img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_06.png" /><span>登录页面,调查问卷</span> </div> </header> <div class="top-2"> <div class="top-2a"> <img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_11.png" /> <p>依据《网络安全法》,为保障您的账户安全和正常使用,请尽快完成手机号验证!新版《<span>谷粒商城隐私政策</span>》已上线,将更有利于保护您的个人隐私。</p> </div> </div> <!--大图--> <div class="top-3"> <div class="img_1"> <img src="/static/login/JD_img/5731485aN1134b4f0.png" /> </div> <div id="sign"> <div class="si_top"> <p> <span>谷粒商城不会以任何理由要求您转账汇款,谨防诈骗。</span> </p> </div> <div class="si_cen"> <h2 class="act btn1">扫码登录</h2> <span>|</span> <h2 class="btn1">账户登录</h2> </div> <div class="si_bom tab"> <img src="/static/login/JD_img/show.png" class="bom_1" /> <a href="/static/login/#"><img src="/static/login/JD_img/phone-orange.png" class="bom_2" /></a> <h6>打开<span class="red">手机谷粒商城</span> 扫描二维码</h6> <p> <img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_15.png" /> <span><a href="/static/login/#">免输入</a></span> <img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_17.png" /> <span><a href="/static/login/#">更快</a></span> <img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_19.png" /> <span><a href="/static/login/#">更安全</a></span> </p> </div> <div class="si_bom1 tab" style="display: none;"> <div class="error"> <div></div> 请输入账户名和密码 </div> <form action="/login" method="post"> <div style="color: red" th:text="${errors!=null?(#maps.containsKey(errors,'msg')?errors.get('msg'):''):''}"></div> <ul> <li class="top_1"> <img src="/static/login/JD_img/user_03.png" class="err_img1" /> <input name="loginAccount" type="text" placeholder=" 邮箱/用户名/已验证手机" class="user" /> </li> <li> <img src="/static/login/JD_img/user_06.png" class="err_img2" /> <input name="password" type="password" placeholder=" 密码" class="password" /> </li> <li class="bri"> <a href="/static/login/">忘记密码</a> </li> <li class="ent"><button type="submit" class="btn2"><a class="a">登 录</a></button></li> </ul> </form> </div> <div class="si_out"> <ul> <li> <a href=""> <img style="width: 50px;height: 18px" src="/static/login/JD_img/weibo.png" /> </a> </li> <li class="f4"> | </li> <li> <a href=""> <img style="width: 18px;height: 18px" src="/static/login/JD_img/gitee.png" /> <span>码云</span> </a> </li> </ul> <h5 class="rig"> <img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_25.png" /> <span><a href="http://auth.alatusmall.com/reg.html">立即注册</a></span> </h5> </div> </div> </div> <!--底部--> <footer> <ul> <li><a href="/static/login/#">关于我们</a></li> <li class="little">|</li> <li><a href="/static/login/#">联系我们</a></li> <li class="little">|</li> <li><a href="/static/login/#">人才招聘</a></li> <li class="little">|</li> <li><a href="/static/login/#">商家入驻</a></li> <li class="little">|</li> <li><a href="/static/login/#">广告服务</a></li> <li class="little">|</li> <li><a href="/static/login/#">手机谷粒商城</a></li> <li class="little">|</li> <li><a href="/static/login/#">友情链接</a></li> <li class="little">|</li> <li><a href="/static/login/#">销售联盟</a></li> <li class="little">|</li> <li><a href="/static/login/#">谷粒商城社区</a></li> <li class="little">|</li> <li><a href="/static/login/#">谷粒商城公益</a></li> <li class="little">|</li> <li><a href="/static/login/#">English Site</a></li> </ul> <span>Copyright © 2004-2017 谷粒商城gulimall.com 版权所有</span> </footer> </body> <script type="text/javascript"> var alDiv = document.getElementsByClassName('tab'); var alBtn = document.getElementsByTagName('h2'); alDiv[0].style.display = 'block'; var act = alBtn[0] for (var i = 0; i < alBtn.length; i++) { alBtn[i].indent = i; alBtn[i].onclick = function() { act.className = ''; alDiv[act.indent].style.display = 'none'; this.className = 'act' alDiv[this.indent].style.display = 'block' act = this } } var btn2 = document.getElementsByClassName('btn2')[0]; var user = document.getElementsByClassName('user')[0]; var pass = document.getElementsByClassName('password')[0]; var err = document.getElementsByClassName('error')[0]; var err_img1 = document.getElementsByClassName('err_img1')[0]; var err_img2 = document.getElementsByClassName('err_img2')[0]; btn2.onclick = function() { if (user.value === '' || pass.value === '') { err.style.display = 'block'; user.style.border = '1px solid red'; pass.style.border = '1px solid red'; err_img1.src = 'JD_img/img11.png'; err_img2.src = 'JD_img/img22.png'; } user.onfocus = function() { err_img1.src = 'JD_img/grow1.png'; user.style.border = '1px solid #999'; } pass.onfocus = function() { err_img2.src = 'JD_img/grow2.png'; pass.style.border = '1px solid #999'; } user.onblur = function() { err_img1.src = 'JD_img/img11.png'; user.style.border = '1px solid red'; } pass.onblur = function() { err_img2.src = 'JD_img/img22.png'; pass.style.border = '1px solid red'; } } </script> </html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="/static/login/JD_sass/JD1.css" />
<script src="/static/login/JD_js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
<title>gulimall</title>
</head>
<body>
<!--顶部logo-->
<header>
<a href="http://alatusmall.com"><img src="/static/login/JD_img/logo.jpg" /></a>
<p>欢迎登录</p>
<div class="top-1">
<img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_06.png" /><span>登录页面,调查问卷</span>
</div>
</header><div class="top-2">
<div class="top-2a">
<img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_11.png" />
<p>依据《网络安全法》,为保障您的账户安全和正常使用,请尽快完成手机号验证!新版《<span>谷粒商城隐私政策</span>》已上线,将更有利于保护您的个人隐私。</p>
</div>
</div><!--大图-->
<div class="top-3">
<div class="img_1">
<img src="/static/login/JD_img/5731485aN1134b4f0.png" />
</div>
<div id="sign">
<div class="si_top">
<p>
<span>谷粒商城不会以任何理由要求您转账汇款,谨防诈骗。</span>
</p>
</div>
<div class="si_cen">
<h2 class="act btn1">扫码登录</h2>
<span>|</span>
<h2 class="btn1">账户登录</h2>
</div>
<div class="si_bom tab">
<img src="/static/login/JD_img/show.png" class="bom_1" />
<a href="/static/login/#"><img src="/static/login/JD_img/phone-orange.png" class="bom_2" /></a>
<h6>打开<span class="red">手机谷粒商城</span> 扫描二维码</h6>
<p>
<img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_15.png" />
<span><a href="/static/login/#">免输入</a></span>
<img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_17.png" />
<span><a href="/static/login/#">更快</a></span>
<img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_19.png" />
<span><a href="/static/login/#">更安全</a></span>
</p>
</div>
<div class="si_bom1 tab" style="display: none;">
<div class="error">
<div></div>
请输入账户名和密码
</div>
<form action="/login" method="post">
<div style="color: red" th:text="${errors!=null?(#maps.containsKey(errors,'msg')?errors.get('msg'):''):''}"></div>
<ul>
<li class="top_1">
<img src="/static/login/JD_img/user_03.png" class="err_img1" />
<input name="loginAccount" type="text" placeholder=" 邮箱/用户名/已验证手机" class="user" />
</li>
<li>
<img src="/static/login/JD_img/user_06.png" class="err_img2" />
<input name="password" type="password" placeholder=" 密码" class="password" />
</li>
<li class="bri">
<a href="/static/login/">忘记密码</a>
</li>
<li class="ent"><button type="submit" class="btn2"><a class="a">登 录</a></button></li>
</ul>
</form>
</div>
<div class="si_out">
<ul>
<li>
<a href="">
<img style="width: 50px;height: 18px" src="/static/login/JD_img/weibo.png" />
</a>
</li>
<li class="f4"> | </li>
<li>
<a href="">
<img style="width: 18px;height: 18px" src="/static/login/JD_img/gitee.png" />
<span>码云</span>
</a>
</li>
</ul>
<h5 class="rig">
<img src="/static/login/JD_img/4de5019d2404d347897dee637895d02b_25.png" />
<span><a href="http://auth.alatusmall.com/reg.html">立即注册</a></span>
</h5>
</div>
</div>
</div>
<!--底部-->
<footer>
<ul>
<li><a href="/static/login/#">关于我们</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">联系我们</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">人才招聘</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">商家入驻</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">广告服务</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">手机谷粒商城</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">友情链接</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">销售联盟</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">谷粒商城社区</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">谷粒商城公益</a></li>
<li class="little">|</li>
<li><a href="/static/login/#">English Site</a></li>
</ul>
<span>Copyright © 2004-2017 谷粒商城gulimall.com 版权所有</span>
</footer></body>
<script type="text/javascript">
var alDiv = document.getElementsByClassName('tab');
var alBtn = document.getElementsByTagName('h2');
alDiv[0].style.display = 'block';
var act = alBtn[0]
for (var i = 0; i < alBtn.length; i++) {
alBtn[i].indent = i;
alBtn[i].onclick = function() {
act.className = '';
alDiv[act.indent].style.display = 'none';
this.className = 'act'
alDiv[this.indent].style.display = 'block'
act = this
}
}var btn2 = document.getElementsByClassName('btn2')[0];
var user = document.getElementsByClassName('user')[0];
var pass = document.getElementsByClassName('password')[0];
var err = document.getElementsByClassName('error')[0];
var err_img1 = document.getElementsByClassName('err_img1')[0];
var err_img2 = document.getElementsByClassName('err_img2')[0];btn2.onclick = function() {
if (user.value === '' || pass.value === '') {
err.style.display = 'block';
user.style.border = '1px solid red';
pass.style.border = '1px solid red';
err_img1.src = 'JD_img/img11.png';
err_img2.src = 'JD_img/img22.png';
}
user.onfocus = function() {
err_img1.src = 'JD_img/grow1.png';
user.style.border = '1px solid #999';
}
pass.onfocus = function() {
err_img2.src = 'JD_img/grow2.png';
pass.style.border = '1px solid #999';
}
user.onblur = function() {
err_img1.src = 'JD_img/img11.png';
user.style.border = '1px solid red';
}
pass.onblur = function() {
err_img2.src = 'JD_img/img22.png';
pass.style.border = '1px solid red';
}
}
</script>
</html>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.Alatus.Mall</groupId> <artifactId>Mall</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.alatus</groupId> <artifactId>Mall-common</artifactId> <url>http://maven.apache.org</url> <properties> <java.version>1.8</java.version> <spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version> <spring-cloud.version>Hoxton.SR3</spring-cloud.version> </properties> <description>每一个微服务公共依赖,Bean,工具类</description> <dependencies> <!-- mybatis-Plus--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.1</version> <exclusions> <exclusion> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> </exclusion> </exclusions> </dependency> <!-- 提示配置信息--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <!-- lombok--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.6</version> </dependency> <!-- HTTP所需的依赖--> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.2.1</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util</artifactId> <version>9.3.7.v20160115</version> </dependency> <!-- 模板引擎--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!-- redisson--> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson</artifactId> <version>3.12.0</version> </dependency> <!-- redis--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <exclusions> <exclusion> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> </exclusion> </exclusions> </dependency> <!-- 换成jedis--> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency> <!-- spring-cache--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <!-- httpComponent--> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </dependency> <!-- commons-lang--> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <!-- jdbc--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.25</version> </dependency> <!-- servlet--> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0-alpha-1</version> <scope>provided</scope> </dependency> <!-- nacos配置中心--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <!-- nacos发现中心--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!-- openfiegn远程调用--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <exclusions> <exclusion> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> </exclusion> </exclusions> </dependency> <!-- 负载均衡--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-loadbalancer</artifactId> </dependency> <!-- spring-web--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring-cloud-alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <version>1.0.0</version> </project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.Alatus.Mall</groupId> <artifactId>Mall</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.alatus</groupId> <artifactId>Mall-common</artifactId> <url>http://maven.apache.org</url> <properties> <java.version>1.8</java.version> <spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version> <spring-cloud.version>Hoxton.SR3</spring-cloud.version> </properties> <description>每一个微服务公共依赖,Bean,工具类</description> <dependencies> <!-- mybatis-Plus--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.1</version> <exclusions> <exclusion> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> </exclusion> </exclusions> </dependency> <!-- 提示配置信息--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <!-- lombok--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.6</version> </dependency> <!-- HTTP所需的依赖--> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.2.1</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util</artifactId> <version>9.3.7.v20160115</version> </dependency> <!-- 模板引擎--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!-- redisson--> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson</artifactId> <version>3.12.0</version> </dependency> <!-- redis--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <exclusions> <exclusion> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> </exclusion> </exclusions> </dependency> <!-- 换成jedis--> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency> <!-- spring-cache--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <!-- httpComponent--> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </dependency> <!-- commons-lang--> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <!-- jdbc--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.25</version> </dependency> <!-- servlet--> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0-alpha-1</version> <scope>provided</scope> </dependency> <!-- nacos配置中心--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <!-- nacos发现中心--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!-- openfiegn远程调用--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <exclusions> <exclusion> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> </exclusion> </exclusions> </dependency> <!-- 负载均衡--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-loadbalancer</artifactId> </dependency> <!-- spring-web--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring-cloud-alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <version>1.0.0</version> </project>
/** * Copyright 2024 */ package com.alatus.mall.auth.vo; import lombok.Data; /** * Auto-generated: 2024-09-10 15:47:33 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ @Data public class WeiboSocialUser { private String access_token; private String remind_in; private long expires_in; private String uid; private String isRealName; }
/** * Copyright 2024 */ package com.alatus.mall.auth.vo; import lombok.Data; /** * Auto-generated: 2024-09-10 15:47:33 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ @Data public class WeiboSocialUser { private String access_token; private String remind_in; private long expires_in; private String uid; private String isRealName; }
/** * Copyright 2024 bejson.com */ package com.alatus.mall.auth.vo; import lombok.Data; /** * Auto-generated: 2024-09-10 15:50:12 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ @Data public class GiteeSocialUser { private String access_token; private String token_type; private long expires_in; private String refresh_token; private String scope; private long created_at; }
/** * Copyright 2024 bejson.com */ package com.alatus.mall.auth.vo; import lombok.Data; /** * Auto-generated: 2024-09-10 15:50:12 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ @Data public class GiteeSocialUser { private String access_token; private String token_type; private long expires_in; private String refresh_token; private String scope; private long created_at; }
package com.alatus.mall.auth.app; import com.alatus.common.utils.HttpUtils; import com.alatus.mall.auth.vo.GiteeSocialUser; import com.alatus.mall.auth.vo.WeiboSocialUser; import com.alibaba.fastjson.JSON; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; 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.RequestParam; import java.util.HashMap; @Controller public class OAuthController { @Value("${spring.oauth.properties.weibo.client_id}") private String weibo_client_id; @Value("${spring.oauth.properties.weibo.client_secret}") private String weibo_client_secret; @Value("${spring.oauth.properties.grant_type}") private String grant_type; @Value("${spring.oauth.properties.weibo.redirect_uri}") private String weibo_redirect_uri; @Value("${spring.oauth.properties.gitee.client_id}") private String gitee_client_id; @Value("${spring.oauth.properties.gitee.redirect_uri}") private String gitee_redirect_uri; @Value("${spring.oauth.properties.gitee.client_secret}") private String gitee_client_secret; @GetMapping("/oauth2.0/weibo/success") public String weiboLogin(@RequestParam("code") String code) throws Exception { // 根据这个code获取当前登录用户的第三方令牌 HashMap<String, String> queryBody = new HashMap<>(); queryBody.put("client_id",weibo_client_id); queryBody.put("client_secret",weibo_client_secret); queryBody.put("grant_type",grant_type); queryBody.put("redirect_uri",weibo_redirect_uri); queryBody.put("code",code); HttpResponse oauth = HttpUtils.doPost("https://api.weibo.com", "/oauth2/access_token", "post", new HashMap<>(), new HashMap<>(), queryBody); if(oauth.getStatusLine().getStatusCode()==200){ // 获取到了accessEntity String userJson = EntityUtils.toString(oauth.getEntity()); WeiboSocialUser weiboSocialUser = JSON.parseObject(userJson, WeiboSocialUser.class); return "redirect:http://alatusmall.com"; } else{ return "redirect:http://auth.alatusmall.com/login.html"; } } @GetMapping("/oauth2.0/gitee/success") public String gitLogin(@RequestParam("code") String code) throws Exception { // 根据这个code获取当前登录用户的第三方令牌 HashMap<String, String> queryBody = new HashMap<>(); queryBody.put("grant_type",grant_type); queryBody.put("code",code); queryBody.put("client_id",gitee_client_id); queryBody.put("redirect_uri",gitee_redirect_uri); queryBody.put("client_secret",gitee_client_secret); HttpResponse oauth = HttpUtils.doPost("https://gitee.com", "/oauth/token", "post", new HashMap<>(), new HashMap<>(), queryBody); if(oauth.getStatusLine().getStatusCode()==200){ // 获取到了accessEntity String userJson = EntityUtils.toString(oauth.getEntity()); GiteeSocialUser giteeSocialUser = JSON.parseObject(userJson, GiteeSocialUser.class); return "redirect:http://alatusmall.com"; } else{ return "redirect:http://auth.alatusmall.com/login.html"; } } }
package com.alatus.mall.auth.app; import com.alatus.common.utils.HttpUtils; import com.alatus.mall.auth.vo.GiteeSocialUser; import com.alatus.mall.auth.vo.WeiboSocialUser; import com.alibaba.fastjson.JSON; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; 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.RequestParam; import java.util.HashMap; @Controller public class OAuthController { @Value("${spring.oauth.properties.weibo.client_id}") private String weibo_client_id; @Value("${spring.oauth.properties.weibo.client_secret}") private String weibo_client_secret; @Value("${spring.oauth.properties.grant_type}") private String grant_type; @Value("${spring.oauth.properties.weibo.redirect_uri}") private String weibo_redirect_uri; @Value("${spring.oauth.properties.gitee.client_id}") private String gitee_client_id; @Value("${spring.oauth.properties.gitee.redirect_uri}") private String gitee_redirect_uri; @Value("${spring.oauth.properties.gitee.client_secret}") private String gitee_client_secret; @GetMapping("/oauth2.0/weibo/success") public String weiboLogin(@RequestParam("code") String code) throws Exception { // 根据这个code获取当前登录用户的第三方令牌 HashMap<String, String> queryBody = new HashMap<>(); queryBody.put("client_id",weibo_client_id); queryBody.put("client_secret",weibo_client_secret); queryBody.put("grant_type",grant_type); queryBody.put("redirect_uri",weibo_redirect_uri); queryBody.put("code",code); HttpResponse oauth = HttpUtils.doPost("https://api.weibo.com", "/oauth2/access_token", "post", new HashMap<>(), new HashMap<>(), queryBody); if(oauth.getStatusLine().getStatusCode()==200){ // 获取到了accessEntity String userJson = EntityUtils.toString(oauth.getEntity()); WeiboSocialUser weiboSocialUser = JSON.parseObject(userJson, WeiboSocialUser.class); return "redirect:http://alatusmall.com"; } else{ return "redirect:http://auth.alatusmall.com/login.html"; } } @GetMapping("/oauth2.0/gitee/success") public String gitLogin(@RequestParam("code") String code) throws Exception { // 根据这个code获取当前登录用户的第三方令牌 HashMap<String, String> queryBody = new HashMap<>(); queryBody.put("grant_type",grant_type); queryBody.put("code",code); queryBody.put("client_id",gitee_client_id); queryBody.put("redirect_uri",gitee_redirect_uri); queryBody.put("client_secret",gitee_client_secret); HttpResponse oauth = HttpUtils.doPost("https://gitee.com", "/oauth/token", "post", new HashMap<>(), new HashMap<>(), queryBody); if(oauth.getStatusLine().getStatusCode()==200){ // 获取到了accessEntity String userJson = EntityUtils.toString(oauth.getEntity()); GiteeSocialUser giteeSocialUser = JSON.parseObject(userJson, GiteeSocialUser.class); return "redirect:http://alatusmall.com"; } else{ return "redirect:http://auth.alatusmall.com/login.html"; } } }