feat:添加微信认证登陆

This commit is contained in:
haoxr 2020-10-09 01:00:01 +08:00
parent 51ae6be207
commit c20d27672a
4 changed files with 51 additions and 7 deletions

View File

@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ylmall-ums</artifactId>
<artifactId>mall-ums</artifactId>
<groupId>com.youlai</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ylmall-ums-api</artifactId>
<artifactId>mall-ums-api</artifactId>
<dependencies>
<dependency>

View File

@ -0,0 +1,34 @@
package com.youlai.mall.ums.api.entity;
import lombok.Data;
import java.time.LocalDate;
@Data
public class UmsMember {
private Long id;
private String username;
private String password;
private Integer gender;
private String nickname;
private String mobile;
private LocalDate birthday;
private String avatar;
private String openid;
private String sessionKey;
}

View File

@ -9,11 +9,11 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ylmall-ums</artifactId>
<artifactId>mall-ums</artifactId>
<packaging>pom</packaging>
<modules>
<module>ylmall-ums-api</module>
<module>ylmall-ums-biz</module>
<module>mall-ums-api</module>
<module>mall-ums-biz</module>
</modules>
<properties>

View File

@ -2,6 +2,8 @@ package com.youlai.auth.controller;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.youlai.auth.domain.WxLoginInfo;
import com.youlai.common.core.result.Result;
import lombok.AllArgsConstructor;
@ -26,11 +28,19 @@ public class WxAuthController {
return Result.error();
}
WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(code);
if(session==null){
if (session == null) {
return Result.error();
}
String openid = session.getOpenid();
String secretKey = session.getSessionKey();
String sessionKey = session.getSessionKey();
// 用户信息
WxMaUserInfo userInfo = wxService.getUserService().getUserInfo(sessionKey, wxLoginInfo.getEncryptedData(), wxLoginInfo.getIv());
// 手机号码信息
WxMaPhoneNumberInfo phoneNumberInfo = wxService.getUserService().getPhoneNoInfo(sessionKey, wxLoginInfo.getEncryptedData(), wxLoginInfo.getIv());
return Result.success();
}