package com.red.circle.order.app.dto.clientobject.pay;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.framework.dto.ClientObject;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 用户基本信息
 * </p>
 *
 * @author pengliang
 * @since 2019-11-08
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class WebSiteUseProfileCO extends ClientObject {

  private static final long serialVersionUID = 1L;

  /**
   * 用户id.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long id;

  /**
   * 用户头像.
   */
  private String userAvatar;

  /**
   * 用户昵称.
   */
  private String userNickname;

  /**
   * 用户账号.
   */
  private String account;

  /**
   * 归属平台.
   */
  private String sysOrigin;

  public static WebSiteUseProfileCO toWebSiteUseProfileCO(UserProfileDTO userProfile) {
    if (userProfile == null) {
      return null;
    }
    return new WebSiteUseProfileCO()
        .setId(userProfile.getId())
        .setUserAvatar(userProfile.getUserAvatar())
        .setUserNickname(userProfile.getUserNickname())
        .setAccount(userProfile.getAccount())
        .setSysOrigin(userProfile.getOriginSys());
  }
}
