package com.huimv.admin.domain.primary;

import com.huimv.admin.EntityBase;
import com.huimv.admin.converter.KeyValueStringConverter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * Member信息表
 * @author guojian
 */
@Entity(name="member_info")
@Inheritance(strategy = InheritanceType.JOINED)
@DynamicInsert(true)
@DynamicUpdate(true)
public class MemberInfo extends EntityBase implements Serializable {

	//序列化
	private static final long serialVersionUID = 4728322620872694328L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    //默认 0-man 1-woman
	@Column(name = "gender")
    private Integer gender = 0;

	@Column(name = "nickname")
    private String nickname;

	@Column(name = "avatar_url")
	private String avatarUrl;

	@Column(name = "remark")
	private String remark;

	@Column(name = "address")
	private String address;

	@Column(name = "job")
	private String job;

	@Column(name = "user_id")
	private Long userId;

	@Column(name = "mobile")
	private String mobile;
	
	@Column(columnDefinition="TEXT")
	@Convert(converter = KeyValueStringConverter.class)
	private Map<String, Object> data;

	@Column(name = "enabled")
	private Boolean enabled;

    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
    private Date updated;

    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", updatable = false)
    private Date created;

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Map<String, Object> getData() {
		return data;
	}

	public void setData(Map<String, Object> data) {
		this.data = data;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}


	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	@Override
	public String toString() {
		return "MemberInfo{" +
				"id=" + id +
				", gender=" + gender +
				", nickname='" + nickname + '\'' +
				", avatarUrl='" + avatarUrl + '\'' +
				", remark='" + remark + '\'' +
				", address='" + address + '\'' +
				", job='" + job + '\'' +
				", userId=" + userId +
				", mobile='" + mobile + '\'' +
				", data=" + data +
				", enabled=" + enabled +
				", updated=" + updated +
				", created=" + created +
				'}';
	}
}
