一:前期準(zhǔn)備
要想實(shí)現(xiàn)微信登陸,首先必須注冊(cè)開發(fā)者賬號(hào)。
- 登錄微信開放平臺(tái),添加移動(dòng)應(yīng)用并提交審核,審核通過后可獲取應(yīng)用ID(AppID),AppSecret等信息
- 在應(yīng)用詳情中
申請(qǐng)開通
微信登錄功能,根據(jù)頁面提示填寫資料,提交審核 - 申請(qǐng)審核通過后即可打包使用微信授權(quán)登錄功能
二:實(shí)現(xiàn)思路
1.app端請(qǐng)求調(diào)用微信登陸,用戶登陸授權(quán)之后會(huì)返回一個(gè)code,通過這個(gè)code加上appid和????????appSecret和可以得到access_token和openid等信息,通過access_token和openid 我們就可以去查詢到用戶基本登陸信息了。
?三:具體實(shí)現(xiàn)
1.配置
在Hbulidx工具里打開uniapp項(xiàng)目,找到
manifest.json文件,在“App模塊配置”項(xiàng)的“OAuth(登錄鑒權(quán))”下,勾選“微信登錄”:?
- appid
微信開放平臺(tái)申請(qǐng)應(yīng)用的AppID值 - appSecret(HBuilderX3.4.18+ 不再提供此參數(shù)的可視化配置,詳見配置參數(shù)安全性問題)
微信開放平臺(tái)申請(qǐng)應(yīng)用的AppSecret值 - UniversalLinks
iOS平臺(tái)通用鏈接,必須與微信開放平臺(tái)配置的一致,推薦使用一鍵生成iOS通用鏈接
?2.前端代碼
<template>
<view class="content">
<view class="text-area">
<button @click="wxlogin">微信登陸</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
wxlogin() {
uni.login({
provider: 'weixin', //使用微信登錄
// onlyAuthorize: true,
success: function (loginRes) {
console.log(loginRes.authResult);
console.log("loginRes.authResult.accessToken="+loginRes.authResult.access_token)
uni.request({
url: 'http://192.168.1.9:8085/wx/login', //僅為示例,并非真實(shí)接口地址。
method:'GET',
data: {
accessToken:loginRes.authResult.access_token,
openid:loginRes.authResult.openid,
},
});
},
})
}
},
}
</script>
<style>
</style>
這里就簡單展示一下,效果圖:
點(diǎn)擊登陸后就會(huì)自動(dòng)跳轉(zhuǎn)到微信登陸授權(quán)頁面了。
3.后端代碼
1.WechatTokenEntity類
package com.jdzh.enterprise.wxlogin;
/**
* 描述: 憑證 </br>
* 發(fā)布版本:V1.0 </br>
*/
public class WechatTokenEntity {
/**
* 接口訪問憑證?
*/
private String accessToken;
/**
* 接口訪問憑證?,刷新
*/
private String refreshToken;
/**
* 憑證有效期單位:second
*/
private int expiresIn;
/**
* 授權(quán)用戶唯一標(biāo)識(shí)
*/
private String openid;
/**
* 微信用戶唯一標(biāo)識(shí)
*/
private String unionId;
public String getOpenid() {
return openid;
}
public void setOpenid(String openid) {
this.openid = openid;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public int getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(int expiresIn) {
this.expiresIn = expiresIn;
}
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
}
2.WechatTrustManager類
package com.jdzh.enterprise.wxlogin;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
/**
* 描述:信任管理器 </br>
* 發(fā)布版本:V1.0 </br>
*/
/*
* 證書管理器的作用是讓它新人我們指定的證書,
* 此類中的代碼意味著信任所有的證書,不管是不是權(quán)威機(jī)構(gòu)頒發(fā)的。
*/
public class WechatTrustManager implements X509TrustManager {
// 檢查客戶端證書
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
// 檢查服務(wù)器端證書
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
// 返回受信任的X509證書數(shù)組
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
3.WechatUserEntity
package com.jdzh.enterprise.wxlogin;
import java.io.Serializable;
/**
* 用戶管理InfoVO
*
* @author es
* @email es@126.com
*/
public class WechatUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用戶的標(biāo)識(shí)
*/
private String openId;
/**
* 關(guān)注狀態(tài)(1是關(guān)注,0是未關(guān)注),未關(guān)注時(shí)獲取不到其余信息
*/
private int subscribe;
/**
* 用戶關(guān)注時(shí)間,為時(shí)間戳。如果用戶曾多次關(guān)注,則取最后關(guān)注時(shí)間
*/
private String subscribeTime;
/**
* 昵稱
*/
private String nickname;
/**
* 用戶的性別(1是男性,2是女性,0是未知)
*/
private int sex;
/**
* 用戶所在國家
*/
private String country;
/**
* 用戶所在省份
*/
private String province;
/**
* 用戶所在城市
*/
private String city;
/**
* 用戶的語言,簡體中文為zh_CN
*/
private String language;
/**
* 用戶頭像
*/
private String headImgUrl;
/**
* 用戶特權(quán)信息
*/
private String PrivilegeList;
/**
* 微信授權(quán)用戶唯一標(biāo)識(shí)
*/
private String unionId;
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public int getSubscribe() {
return subscribe;
}
public void setSubscribe(int subscribe) {
this.subscribe = subscribe;
}
public String getSubscribeTime() {
return subscribeTime;
}
public void setSubscribeTime(String subscribeTime) {
this.subscribeTime = subscribeTime;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl;
}
public String getPrivilegeList() {
return PrivilegeList;
}
public void setPrivilegeList(String privilegeList) {
PrivilegeList = privilegeList;
}
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId;
}
}
4.WechatUtils
package com.jdzh.enterprise.wxlogin;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class WechatUtils {
private final static Logger log = LoggerFactory.getLogger(WechatUtils.class);
private final static String appid = "appid"; //憑證
private final static String appsecret = "appsecret"; //憑證密鑰
// 憑證獲?。℅ET)
public final static String tokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
//userinfo
public final static String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN";
/**
* 獲取接口訪問憑證
*
* @param code app授權(quán)后傳回
* @return
*/
public static WechatTokenEntity getToken(String code) {
WechatTokenEntity token = new WechatTokenEntity();
// long now = new Date().getTime();
// if (tokenTime != 0 && now - tokenTime < 7000000) {//token有效時(shí)間 7e6 毫秒
// return token;
// }
String requestUrl = tokenUrl.replace("APPID", appid).replace("SECRET", appsecret).replace("CODE", code);
// 發(fā)起GET請(qǐng)求獲取憑證
JSONObject jsonObject = httpsRequest(requestUrl, "GET", null);
if (null != jsonObject) {
try {
token.setUnionId(jsonObject.getString("unionid"));
token.setOpenid(jsonObject.getString("openid"));
token.setAccessToken(jsonObject.getString("access_token"));
token.setRefreshToken(jsonObject.getString("refresh_token"));
token.setExpiresIn(jsonObject.getInt("expires_in"));
} catch (JSONException e) {
token = null;
// 獲取token失敗
log.error("獲取token失敗 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
}
}
return token;
}
public static void main(String args[]) {
// 獲取接口訪問憑證
// 我這里是直接從前端傳入accessToken,openid,所以可以直接拿到,下面是通過code生成
String accessToken = getToken("code").getAccessToken();
String openid = getToken("code").getOpenid();
// /**
// * 獲取用戶信息
// */
WechatUserEntity user = getUserInfo(accessToken, openid);
//做這個(gè)測試的時(shí)候可以先關(guān)注,或者取消關(guān)注,控制臺(tái)會(huì)打印出來此用戶的openid
System.out.println("OpenID:" + user.getOpenId());
System.out.println("關(guān)注狀態(tài):" + user.getSubscribe());
System.out.println("關(guān)注時(shí)間:" + user.getSubscribeTime());
System.out.println("昵稱:" + user.getNickname());
System.out.println("性別:" + user.getSex());
System.out.println("國家:" + user.getCountry());
System.out.println("省份:" + user.getProvince());
System.out.println("城市:" + user.getCity());
System.out.println("語言:" + user.getLanguage());
System.out.println("頭像:" + user.getHeadImgUrl());
getToken("02315v0w35TA603fsF0w3Q0fov415v0B");
}
/**
* 獲取用戶信息
*
* @param accessToken 接口訪問憑證
* @param openId 用戶標(biāo)識(shí)
* @return WeixinUserInfo
*/
public static WechatUserEntity getUserInfo(String accessToken, String openId) {
WechatUserEntity wechatUserEntity = null;
// 拼接請(qǐng)求地址
String requestUrl = userInfoUrl.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openId);
// 獲取用戶信息
JSONObject jsonObject = httpsRequest(requestUrl, "GET", null);
if (null != jsonObject) {
try {
wechatUserEntity = new WechatUserEntity();
// 用戶的標(biāo)識(shí)
wechatUserEntity.setOpenId(jsonObject.getString("openid"));
wechatUserEntity.setUnionId(jsonObject.getString("unionid"));
// 關(guān)注狀態(tài)(1是關(guān)注,0是未關(guān)注),未關(guān)注時(shí)獲取不到其余信息
// wechatUserEntity.setSubscribe(jsonObject.getInt("subscribe"));
// 用戶關(guān)注時(shí)間
// wechatUserEntity.setSubscribeTime(jsonObject.getString("subscribe_time"));
// 昵稱
wechatUserEntity.setNickname(jsonObject.getString("nickname"));
// 用戶的性別(1是男性,2是女性,0是未知)
// wechatUserEntity.setSex(jsonObject.getInt("sex"));
// 用戶所在國家
// wechatUserEntity.setCountry(jsonObject.getString("country"));
// 用戶所在省份
// wechatUserEntity.setProvince(jsonObject.getString("province"));
// 用戶所在城市
// wechatUserEntity.setCity(jsonObject.getString("city"));
// 用戶的語言,簡體中文為zh_CN
wechatUserEntity.setLanguage(jsonObject.getString("language"));
// 用戶頭像
wechatUserEntity.setHeadImgUrl(jsonObject.getString("headimgurl"));
} catch (Exception e) {
int errorCode = jsonObject.getInt("errcode");
String errorMsg = jsonObject.getString("errmsg");
// System.err.printf("獲取用戶信息失敗 errcode:{} errmsg:{}", errorCode, errorMsg);
}
}
return wechatUserEntity;
}
/**
* 發(fā)送https請(qǐng)求
*
* @param requestUrl 請(qǐng)求地址
* @param requestMethod 請(qǐng)求方式(GET、POST)
* @param outputStr 提交的數(shù)據(jù)
* @return JSONObject(通過JSONObject.get ( key)的方式獲取json對(duì)象的屬性值)
*/
public static JSONObject httpsRequest(String requestUrl, String requestMethod, String outputStr) {
JSONObject jsonObject = null;
try {
// 創(chuàng)建SSLContext對(duì)象,并使用我們指定的信任管理器初始化
TrustManager[] tm = {new WechatTrustManager()};
SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
sslContext.init(null, tm, new java.security.SecureRandom());
// 從上述SSLContext對(duì)象中得到SSLSocketFactory對(duì)象
SSLSocketFactory ssf = sslContext.getSocketFactory();
URL url = new URL(requestUrl);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(ssf);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
// 設(shè)置請(qǐng)求方式(GET/POST)
conn.setRequestMethod(requestMethod);
// 當(dāng)outputStr不為null時(shí)向輸出流寫數(shù)據(jù)
if (null != outputStr) {
OutputStream outputStream = conn.getOutputStream();
// 注意編碼格式
outputStream.write(outputStr.getBytes(StandardCharsets.UTF_8));
outputStream.close();
}
// 從輸入流讀取返回內(nèi)容
InputStream inputStream = conn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String str = null;
StringBuilder stringBuilder = new StringBuilder();
while ((str = bufferedReader.readLine()) != null) {
stringBuilder.append(str);
}
// 釋放資源
bufferedReader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
conn.disconnect();
jsonObject = JSONObject.fromObject(stringBuilder.toString());
} catch (ConnectException ce) {
System.err.printf("連接超時(shí):{}", ce);
} catch (Exception e) {
System.err.printf("https請(qǐng)求異常:{}", e);
}
return jsonObject;
}
}
調(diào)用main方法就可以得到我們要的用戶信息了。
至于controller層怎么寫,大家可以參考一下我的
package com.jdzh.enterprise.wxlogin;
import com.jdzh.enterprise.framework.entity.RespBean;
import com.jdzh.enterprise.framework.entity.User;
import com.jdzh.enterprise.framework.service.IUserService;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
@RestController
@RequestMapping("/wx")
public class WxLoginController {
@Autowired
IUserService iUserService;
private final static Logger log = LoggerFactory.getLogger(WechatUtils.class);
private final static String appid = "appid "; //憑證
private final static String appsecret = "appsecret "; //憑證密鑰
// 憑證獲?。℅ET)
public final static String tokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
//userinfo
public final static String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN";
@GetMapping("/login")
public RespBean login(String accessToken, String openid) {
// System.out.println("code = " + code);
// // 獲取接口訪問憑證
// String accessToken = getToken(code).getAccessToken();
// String openid = getToken(code).getOpenid();
System.out.println("accessToken = " + accessToken);
System.out.println("openid = " + openid);
/**
* 獲取用戶信息
*/
WechatUserEntity wechatUserEntity = getUserInfo(accessToken, openid);
// System.out.println("關(guān)注狀態(tài):" + wechatUserEntity.getSubscribe());
// System.out.println("關(guān)注時(shí)間:" + wechatUserEntity.getSubscribeTime());
System.out.println("昵稱:" + wechatUserEntity.getNickname());
// System.out.println("性別:" + wechatUserEntity.getSex());
// System.out.println("國家:" + wechatUserEntity.getCountry());
// System.out.println("省份:" + wechatUserEntity.getProvince());
// System.out.println("城市:" + wechatUserEntity.getCity());
// System.out.println("語言:" + wechatUserEntity.getLanguage());
System.out.println("頭像:" + wechatUserEntity.getHeadImgUrl());
String nickname = wechatUserEntity.getNickname();
if(wechatUserEntity!=null){
//將用戶信息存在數(shù)據(jù)庫中
User user = new User();
user.setOpenid(openid);
user.setNickname(nickname);
user.setIsVip(0);
//查詢openId是否存在
User user1 = iUserService.findByOpenId(openid);
if(user1==null){
//如果不存在,則添加
iUserService.save(user);
}else{
System.out.println("用戶信息已存在");
}
return RespBean.ok("登陸成功",wechatUserEntity);
}else{
return RespBean.error("登陸失敗",wechatUserEntity);
}
}
/**
* 獲取用戶信息
*
* @param accessToken 接口訪問憑證
* @param openid 用戶標(biāo)識(shí)
* @return WeixinUserInfo
*/
public static WechatUserEntity getUserInfo(String accessToken, String openid) {
WechatUserEntity wechatUserEntity = null;
// 拼接請(qǐng)求地址
String requestUrl = userInfoUrl.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openid);
// 獲取用戶信息
JSONObject jsonObject = httpsRequest(requestUrl, "GET", null);
if (null != jsonObject) {
try {
wechatUserEntity = new WechatUserEntity();
// 用戶的標(biāo)識(shí)
wechatUserEntity.setOpenId(jsonObject.getString("openid"));
wechatUserEntity.setUnionId(jsonObject.getString("unionid"));
// 關(guān)注狀態(tài)(1是關(guān)注,0是未關(guān)注),未關(guān)注時(shí)獲取不到其余信息
// wechatUserEntity.setSubscribe(jsonObject.getInt("subscribe"));
// 用戶關(guān)注時(shí)間
// wechatUserEntity.setSubscribeTime(jsonObject.getString("subscribe_time"));
// 昵稱
wechatUserEntity.setNickname(jsonObject.getString("nickname"));
// 用戶的性別(1是男性,2是女性,0是未知)
// wechatUserEntity.setSex(jsonObject.getInt("sex"));
// 用戶所在國家
// wechatUserEntity.setCountry(jsonObject.getString("country"));
// 用戶所在省份
// wechatUserEntity.setProvince(jsonObject.getString("province"));
// 用戶所在城市
// wechatUserEntity.setCity(jsonObject.getString("city"));
// 用戶的語言,簡體中文為zh_CN
// wechatUserEntity.setLanguage(jsonObject.getString("language"));
// 用戶頭像
wechatUserEntity.setHeadImgUrl(jsonObject.getString("headimgurl"));
} catch (Exception e) {
int errorCode = jsonObject.getInt("errcode");
String errorMsg = jsonObject.getString("errmsg");
System.err.printf("獲取用戶信息失敗 errcode:{} errmsg:{}", errorCode, errorMsg);
}
}
return wechatUserEntity;
}
/**
* 發(fā)送https請(qǐng)求
*
* @param requestUrl 請(qǐng)求地址
* @param requestMethod 請(qǐng)求方式(GET、POST)
* @param outputStr 提交的數(shù)據(jù)
* @return JSONObject(通過JSONObject.get ( key)的方式獲取json對(duì)象的屬性值)
*/
public static JSONObject httpsRequest(String requestUrl, String requestMethod, String outputStr) {
JSONObject jsonObject = null;
try {
// 創(chuàng)建SSLContext對(duì)象,并使用我們指定的信任管理器初始化
TrustManager[] tm = {new WechatTrustManager()};
SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
sslContext.init(null, tm, new java.security.SecureRandom());
// 從上述SSLContext對(duì)象中得到SSLSocketFactory對(duì)象
SSLSocketFactory ssf = sslContext.getSocketFactory();
URL url = new URL(requestUrl);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(ssf);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
// 設(shè)置請(qǐng)求方式(GET/POST)
conn.setRequestMethod(requestMethod);
// 當(dāng)outputStr不為null時(shí)向輸出流寫數(shù)據(jù)
if (null != outputStr) {
OutputStream outputStream = conn.getOutputStream();
// 注意編碼格式
outputStream.write(outputStr.getBytes(StandardCharsets.UTF_8));
outputStream.close();
}
// 從輸入流讀取返回內(nèi)容
InputStream inputStream = conn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String str = null;
StringBuilder stringBuilder = new StringBuilder();
while ((str = bufferedReader.readLine()) != null) {
stringBuilder.append(str);
}
// 釋放資源
bufferedReader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
conn.disconnect();
jsonObject = JSONObject.fromObject(stringBuilder.toString());
} catch (ConnectException ce) {
System.err.printf("連接超時(shí):{}", ce);
} catch (Exception e) {
System.err.printf("https請(qǐng)求異常:{}", e);
}
return jsonObject;
}
}
User類
package com.jdzh.enterprise.framework.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.io.Serializable;
import java.util.Collection;
@TableName("user")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable , UserDetails {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 手機(jī)號(hào)
*/
@TableField("phone")
private String username;
/**
* 密碼
*/
private String password;
/**
* openid
*/
private String openid;
/**
* 微信用戶名
*/
private String nickname;
/**
* 角色身份
*/
@TableField("roleType")
private Integer roleType;
/**
* 是否是vip
*/
private Integer isVip;
/**
* vip截止日期
*/
private String endTime;
public Integer getIsVip() {
return isVip;
}
public void setIsVip(Integer isVip) {
this.isVip = isVip;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
@Override
public String getUsername() {
return username;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
@Override
public String getPassword() {
return password;
}
}
RespBean
package com.jdzh.enterprise.framework.entity;
public class RespBean {
private Integer status;
private String msg;
private Object data;
public static RespBean ok(String msg,Object data){
return new RespBean(200,msg,data);
}
public static RespBean ok(String msg){
return new RespBean(200,msg,null);
}
public static RespBean error(String msg,Object data){
return new RespBean(500,msg,data);
}
public static RespBean error(String msg){
return new RespBean(500,msg,null);
}
public RespBean() {
}
public RespBean(Integer status, String msg, Object data) {
this.status = status;
this.msg = msg;
this.data = data;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
數(shù)據(jù)庫設(shè)計(jì)
小伙伴們可以根據(jù)自己的需求設(shè)計(jì)數(shù)據(jù)庫表哦?文章來源:http://www.zghlxwxcb.cn/news/detail-502363.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-502363.html
到了這里,關(guān)于uni-app +java小程序端對(duì)接微信登陸的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!