All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.javaclub.base.domain.UserProfile Maven / Gradle / Ivy

package com.github.javaclub.base.domain;

import java.util.Map;

import com.github.javaclub.sword.core.Maps;
import com.github.javaclub.sword.core.Strings;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(description = "用户基本信息")
public class UserProfile {

    @ApiModelProperty("用户账号ID")
    private Long id;
    
    @ApiModelProperty("昵称")
    private String nickname;
    
    @ApiModelProperty("用户手机号")
    private String mobile;
    
    @ApiModelProperty("微信openId")
    private String openId;

    @ApiModelProperty("显示名称/姓名")
    private String name;

    @ApiModelProperty("用户头像地址")
    private String userAvatar;
    
    private Long extraId;
    private String extraName;
    
    @ApiModelProperty("用户其他资料信息")
    private Map extra = Maps.newHashMap(10);
    
    public UserProfile() {
    	
    }
    
    public UserProfile(Long id) {
    		this.id = id;
    }
    
    public UserProfile(Long id, String openId, String mobile) {
		this.id = id;
		this.openId = openId;
		this.mobile = mobile;
    }
    
    public UserProfile(Long id, String openId, String mobile, String name) {
		this.id = id;
		this.openId = openId;
		this.mobile = mobile;
		this.name = name;
    }
    
    public void setProfile(String key, Object data) {
    		if (null == extra) {
    			extra = Maps.newHashMap(10);
    		}
    		extra.put(key, data);
    }
    
    public  T getProfile(String key) {
    		if (null == extra || !extra.containsKey(key)) {
    			return null;
    		}
    		return (T) extra.get(key);
    }
    
    public String presentName() {
		return Strings.noneNull(getName(), getNickname(), String.valueOf(getId()));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy