package com.zhangmeng.model.entity;

import com.zhangmeng.model.base.baseEntity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.*;

/**
 * @author zhengmeng
 * @version 1.0
 * @date 2021年1月7日11:38:42
 */
@NoArgsConstructor
@Data
@AllArgsConstructor
@Entity
@EqualsAndHashCode(callSuper = false)
@Table(name = "user")
public class User extends BaseEntity<Long> {

    public enum Status {
        DISABLED("已停用"),
        VALID("正常"),
        LOCKED("锁定");

        Status(String description) {
            this.description = description;
        }

        private String description;//描述

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public static List<Map<String,Object>> enumListMap(){
            Status[] values = Status.values();
            List<Map<String, Object>> list = new ArrayList<>();
            for (Status value : values) {
                Map<String, Object> map = new HashMap<>();
                String description = value.getDescription();
                map.put("description",description);
                map.put("value",value);
                list.add(map);
            }
            return list;
        }
    }


    public enum Gender {
        male("男"),
        female("女");

        Gender(String description) {
            this.description = description;
        }

        private String description;//描述

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public static List<Map<String,Object>> enumListMap(){
            Gender[] values = Gender.values();
            List<Map<String, Object>> list = new ArrayList<>();
            for (Gender value : values) {
                Map<String, Object> map = new HashMap<>();
                String description = value.getDescription();
                map.put("description",description);
                map.put("value",value);
                list.add(map);
            }
            return list;
        }
    }

    private String username;

    private String password;

    private Status status;

    @Column(columnDefinition = "longtext")
    private String sign;

    private String avatar;

    private String email;

    private String name;//姓名

    private String nickname;//昵称

    private String profession;//职业

    private String qq;

    private String telephone;

    private Date birthday;

    private Gender gender;//性别

    private String remarks;//备注

    private Role.Type roleType;//角色类型

    private Long photo_id;
}
