package com.github.microservice.auth.server.core.domain;

import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
import com.mongodb.client.gridfs.model.GridFSFile;
import lombok.*;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
import org.springframework.util.Assert;

import java.util.List;
import java.util.Set;

@Data
@EqualsAndHashCode(callSuper = true)
@Builder
@Document
@AllArgsConstructor
@NoArgsConstructor
public class User extends SuperEntity {

    //账号
    @Indexed(unique = true, sparse = true)
    private String userName;

    //手机号码
    @Indexed(unique = true, sparse = true)
    private String phone;

    //邮箱
    @Indexed(unique = true, sparse = true)
    private String email;

    //身份证
    @Indexed(unique = true, sparse = true)
    private String idcard;


    //密码
    private String passWord;


    //是否禁止
    @Indexed
    private boolean disable;

    //人脸图片文件id
    @Indexed
    private List<String> facePic;

    //NFC卡号
    @Indexed
    private List<String> nfcCard;

    /**
     * 构建用户
     *
     * @param uid
     * @return
     */
    public static User build(String uid) {
        Assert.hasText(uid, "用户id不能为空");
        User user = new User();
        user.setId(uid);
        return user;
    }

}
