Commit d387b71c authored by 唐峰's avatar 唐峰

用户信息查询,增加微信头像和昵称信息

parent d1b66469
...@@ -42,10 +42,14 @@ public class UserBean { ...@@ -42,10 +42,14 @@ public class UserBean {
private String openId; private String openId;
private String appId; private String appId;
private String unionId; private String unionId;
//昵称
private String nickName;
//头像
private String photo;
} }
@Data @Data
public static class UserAttachedInfo{ public static class UserAttachedInfo {
private Gender gender; private Gender gender;
...@@ -63,7 +67,7 @@ public class UserBean { ...@@ -63,7 +67,7 @@ public class UserBean {
} }
public static UserBean from(User user, List<WechatUserInfo> wechatUserInfoList,UserInfoEntity userInfoEntity) { public static UserBean from(User user, List<WechatUserInfo> wechatUserInfoList, UserInfoEntity userInfoEntity) {
UserBean userBean = new UserBean(); UserBean userBean = new UserBean();
userBean.setUserId(user.getId()); userBean.setUserId(user.getId());
userBean.setPhoneNo(user.getPhoneNo()); userBean.setPhoneNo(user.getPhoneNo());
...@@ -74,8 +78,10 @@ public class UserBean { ...@@ -74,8 +78,10 @@ public class UserBean {
userBean.setCreatedAt(user.getCreatedAt()); userBean.setCreatedAt(user.getCreatedAt());
if (CollectionUtils.isNotEmpty(wechatUserInfoList)) { if (CollectionUtils.isNotEmpty(wechatUserInfoList)) {
List<Wechat> wcList = Lists.newArrayList(); List<Wechat> wcList = Lists.newArrayList();
wechatUserInfoList.stream().forEach(wechatUserInfo->{ wechatUserInfoList.stream().forEach(wechatUserInfo -> {
Wechat build = Wechat.builder() Wechat build = Wechat.builder()
.nickName(wechatUserInfo.getNickName())
.photo(wechatUserInfo.getHeadImgUrl())
.openId(wechatUserInfo.getOpenId()) .openId(wechatUserInfo.getOpenId())
.unionId(wechatUserInfo.getUnionId()) .unionId(wechatUserInfo.getUnionId())
.appId(wechatUserInfo.getAppId()).build(); .appId(wechatUserInfo.getAppId()).build();
...@@ -86,13 +92,13 @@ public class UserBean { ...@@ -86,13 +92,13 @@ public class UserBean {
} }
if (userInfoEntity != null) { if (userInfoEntity != null) {
UserAttachedInfo info = new UserAttachedInfo(); UserAttachedInfo info = new UserAttachedInfo();
BeanUtils.copyProperties(userInfoEntity,info); BeanUtils.copyProperties(userInfoEntity, info);
userBean.setUserAttachedInfo(info); userBean.setUserAttachedInfo(info);
} }
return userBean; return userBean;
} }
public static List<UserBean> from(List<User> userList, List<WechatUserInfo> wechatUserInfoList,List<UserInfoEntity> userInfoEntityList) { public static List<UserBean> from(List<User> userList, List<WechatUserInfo> wechatUserInfoList, List<UserInfoEntity> userInfoEntityList) {
Map<Long, UserInfoEntity> userIdEntityMap = Maps.newHashMap(); Map<Long, UserInfoEntity> userIdEntityMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(userInfoEntityList)) { if (CollectionUtils.isNotEmpty(userInfoEntityList)) {
...@@ -115,7 +121,7 @@ public class UserBean { ...@@ -115,7 +121,7 @@ public class UserBean {
UserInfoEntity userInfoEntity = userIdEntityMap.get(user.getId()); UserInfoEntity userInfoEntity = userIdEntityMap.get(user.getId());
if (userInfoEntity != null) { if (userInfoEntity != null) {
UserAttachedInfo info = new UserAttachedInfo(); UserAttachedInfo info = new UserAttachedInfo();
BeanUtils.copyProperties(userInfoEntity,info); BeanUtils.copyProperties(userInfoEntity, info);
userBean.setUserAttachedInfo(info); userBean.setUserAttachedInfo(info);
} }
...@@ -126,6 +132,8 @@ public class UserBean { ...@@ -126,6 +132,8 @@ public class UserBean {
if (optionalWechatUserInfo.isPresent()) { if (optionalWechatUserInfo.isPresent()) {
WechatUserInfo wechatUserInfo = optionalWechatUserInfo.get(); WechatUserInfo wechatUserInfo = optionalWechatUserInfo.get();
userBean.setWechatList(Collections.singletonList(Wechat.builder() userBean.setWechatList(Collections.singletonList(Wechat.builder()
.nickName(wechatUserInfo.getNickName())
.photo(wechatUserInfo.getHeadImgUrl())
.openId(wechatUserInfo.getOpenId()) .openId(wechatUserInfo.getOpenId())
.unionId(wechatUserInfo.getUnionId()) .unionId(wechatUserInfo.getUnionId())
.appId(wechatUserInfo.getAppId()).build())); .appId(wechatUserInfo.getAppId()).build()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment