com.github.javaclub.base.convert.WechatConvertor Maven / Gradle / Ivy
/*
* @(#)WechatConvertor.java 2020-8-25
*
* Copyright (c) 2020. All Rights Reserved.
*
*/
package com.github.javaclub.base.convert;
import com.github.javaclub.base.domain.AppUserDO;
import com.github.javaclub.base.domain.UserProfile;
import com.github.javaclub.sword.spring.BeanCopierUtils;
import com.github.javaclub.wechat.model.MpUserInfo;
import com.github.javaclub.wechat.param.MpUserRequestParam;
import com.github.javaclub.wechat.param.WechatMPLoginParam;
/**
* WechatConvertor
*
* @author Gerald Chen
* @version $Id: WechatConvertor.java 2020-8-25 19:35:28 Exp $
*/
public class WechatConvertor {
public static WechatConvertor INTANCE = new WechatConvertor();
private WechatConvertor() {}
public WechatMPLoginParam from(MpUserRequestParam param) {
return BeanCopierUtils.copyProperties(param, WechatMPLoginParam.class);
}
public AppUserDO copy(MpUserInfo mpUserInfo) {
AppUserDO user = BeanCopierUtils.copyProperties(mpUserInfo, AppUserDO.class);
user.setNickname(mpUserInfo.getNickName());
user.setUserAvatar(mpUserInfo.getAvatarUrl());
user.setMobile(mpUserInfo.getPhoneNumber());
return user;
}
public UserProfile copy(AppUserDO appUser) {
UserProfile profile = BeanCopierUtils.copyProperties(appUser, UserProfile.class);
return profile;
}
}