package com.yeshi.buwan.util.factory.vo;
|
|
import com.yeshi.buwan.domain.user.LoginUser;
|
import com.yeshi.buwan.domain.user.LoginUserExtra;
|
import com.yeshi.buwan.domain.vip.UserVIPInfo;
|
import com.yeshi.buwan.videos.pptv.PPTVUtil;
|
import com.yeshi.buwan.util.StringUtil;
|
import com.yeshi.buwan.vo.client.user.UserInfoVO;
|
|
public class UserInfoVOFactory {
|
|
|
public static UserInfoVO create(LoginUser user, LoginUserExtra extra, UserVIPInfo vipInfo) {
|
UserInfoVO vo = new UserInfoVO();
|
vo.setId(user.getId());
|
vo.setPptvCode(PPTVUtil.getPPTVCode(extra.getPptvUid()));
|
vo.setQqNickName(extra.getQqNickName());
|
vo.setBirthday(extra.getBirthday());
|
vo.setEmail(getHiddenEmail(extra.getEmail()));
|
vo.setNickName(user.getName());
|
vo.setPhone(getHiddenPhone(user.getPhone()));
|
vo.setPortrait(user.getPortrait());
|
vo.setQqOpenId(getHiddenOpenId(extra.getQqOpenId()));
|
vo.setSex(extra.getSex());
|
vo.setSign(extra.getSign());
|
if (vipInfo != null && vipInfo.getExpireDate() != null)
|
vo.setVipExpireTime(vipInfo.getExpireDate().getTime());
|
vo.setWxName(extra.getWxNickName());
|
vo.setWxUnionId(getHiddenOpenId(extra.getWxUnionId()));
|
return vo;
|
}
|
|
|
private static String getHiddenPhone(String phone) {
|
if (StringUtil.isNullOrEmpty(phone)) {
|
return null;
|
}
|
if (phone.length() < 11) {
|
return phone;
|
}
|
return phone.substring(0, 3) + "****" + phone.substring(phone.length() - 4, phone.length());
|
}
|
|
private static String getHiddenOpenId(String openId) {
|
if (StringUtil.isNullOrEmpty(openId)) {
|
return null;
|
}
|
if (openId.length() < 11) {
|
return openId;
|
}
|
return openId.substring(0, 4) + "****" + openId.substring(openId.length() - 4, openId.length() - 4);
|
}
|
|
public static String getHiddenEmail(String email) {
|
if (StringUtil.isNullOrEmpty(email)) {
|
return null;
|
}
|
int index = email.indexOf("@");
|
if (index < 0)
|
return null;
|
|
String prefix = email.substring(0, index);
|
if (prefix.length() < 2)
|
return prefix.substring(0, 1) + "**" + email.substring(index, email.length());
|
return prefix.substring(0, 2) + "****" + email.substring(index, email.length());
|
}
|
|
|
}
|