USVT-126 针对微信的 API 调用,在拿到 Code 后我们需要在本地存储 Access Token,我顺便调用了用户的信息 API 获得用户的头像和昵称
This commit is contained in:
parent
7a2a1ea908
commit
5012d38027
|
@ -6,14 +6,12 @@ import lombok.Data;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created with IntelliJ IDEA.
|
* WeChat API Call State to get user information and access token
|
||||||
*
|
*
|
||||||
* @Author: XieYang
|
* @author YuCheng
|
||||||
* @Date: 2022/10/10/19:21
|
|
||||||
* @Description:
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
|
@ -21,30 +19,24 @@ import java.time.LocalDateTime;
|
||||||
@org.hibernate.annotations.Table(appliesTo = "wechat_call_state", comment = "WeChat Call State")
|
@org.hibernate.annotations.Table(appliesTo = "wechat_call_state", comment = "WeChat Call State")
|
||||||
public class WeChatCallState extends BaseEntity<Long> {
|
public class WeChatCallState extends BaseEntity<Long> {
|
||||||
|
|
||||||
/**
|
|
||||||
* User id
|
|
||||||
*/
|
|
||||||
@Column(name = "wechat_state", columnDefinition = "varchar(255) COMMENT 'wechat state'")
|
@Column(name = "wechat_state", columnDefinition = "varchar(255) COMMENT 'wechat state'")
|
||||||
private String weChatState;
|
private String weChatState;
|
||||||
|
|
||||||
/**
|
@Column(name = "wechat_code", columnDefinition = "varchar(255) COMMENT 'wechat code")
|
||||||
* User olc password
|
private String weChatCode;
|
||||||
*/
|
|
||||||
|
@Column(name = "wechat_access_token", columnDefinition = "varchar(255) COMMENT 'wechat access token")
|
||||||
|
private String weChatAccessToken;
|
||||||
|
|
||||||
@Column(name = "wechat_openid", columnDefinition = "varchar(255) COMMENT 'wechat openid'")
|
@Column(name = "wechat_openid", columnDefinition = "varchar(255) COMMENT 'wechat openid'")
|
||||||
private String weChatOpenId;
|
private String weChatOpenId;
|
||||||
|
|
||||||
/**
|
|
||||||
* User new password
|
|
||||||
*/
|
|
||||||
@Column(name = "wechat_unionid", columnDefinition = "varchar(255) COMMENT 'wechat unionid'")
|
@Column(name = "wechat_unionid", columnDefinition = "varchar(255) COMMENT 'wechat unionid'")
|
||||||
private String weChatUnionId;
|
private String weChatUnionId;
|
||||||
|
|
||||||
/**
|
@Column(name = "nickname", columnDefinition = "varchar(255) COMMENT 'wechat nickname'")
|
||||||
* User change password time
|
private String nickName;
|
||||||
*/
|
|
||||||
@Column(name = "date_call_state", columnDefinition = "DATETIME COMMENT 'User change password time'")
|
|
||||||
private LocalDateTime dateCallState;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "head_img_url", columnDefinition = "varchar(255) COMMENT 'wechat head image url'")
|
||||||
|
private String headImgURL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@ public class WeChatService {
|
||||||
log.debug("WeChat NickName - [{}]", weChatUser.getNickname());
|
log.debug("WeChat NickName - [{}]", weChatUser.getNickname());
|
||||||
WeChatCallState weChatCallState = new WeChatCallState();
|
WeChatCallState weChatCallState = new WeChatCallState();
|
||||||
weChatCallState.setWeChatState(weChatState);
|
weChatCallState.setWeChatState(weChatState);
|
||||||
|
weChatCallState.setWeChatCode(weChatCode);
|
||||||
|
weChatCallState.setWeChatAccessToken(accessToken);
|
||||||
weChatCallState.setWeChatOpenId(weChatUser.getOpenId());
|
weChatCallState.setWeChatOpenId(weChatUser.getOpenId());
|
||||||
weChatCallState.setWeChatUnionId(weChatUser.getUnionId());
|
weChatCallState.setWeChatUnionId(weChatUser.getUnionId());
|
||||||
weChatCallStateRepository.save(weChatCallState);
|
weChatCallStateRepository.save(weChatCallState);
|
||||||
|
|
Loading…
Reference in New Issue