/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.renren.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.UpdateGroup;
import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 系统用户
 *
 * @author Mark sunlightcs@gmail.com
 */
@Data
@TableName("sys_user")
public class SysUserEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @TableId
    private Long userId;

    /**
     * 用户名
     */
    @NotBlank(message = "用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String username;

    /**
     * 密码
     */
    @NotBlank(message = "密码不能为空", groups = AddGroup.class)
    private String password;

    /**
     * 盐
     */
    private String salt;

    /**
     * 性别
     */
    @NotNull(message = "性别不能为空",groups = {AddGroup.class, UpdateGroup.class})
    private Short sex;

    /**
     * 出生日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
    private Date birthday;
    /**
     * 邮箱
     */
    //@NotBlank(message = "邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Email(message = "邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
    private String email;

    /**
     * 手机号
     */
    @NotBlank(message = "手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^1[0-9]{10}$",message = "手机号格式不正确,请检查!",groups = {AddGroup.class,UpdateGroup.class})
    private String mobile;

    /**
     * 状态  0：禁用   1：正常
     */
    private Integer status;

    /**
     * 角色ID列表
     */
    @TableField(exist = false)
    private List<Long> roleIdList;

    /**
     * 部门code
     */
    //@NotBlank(message = "部门识别码不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String departmentCode;

    /**
     * 岗位code
     */
    //@NotBlank(message = "岗位识别码不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String jobCode;

    /**
     * 牧场id
     */
    //@NotNull(message = "牧场不能为空",groups = {AddGroup.class, UpdateGroup.class})
    private Integer farmId;

    /**
     * 详细地址
     */
    //@NotBlank(message = "地址不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String address;

    /**
     * 备注
     */
    private String remarks;

    /**
     * 创建者ID
     */
    private Long createUserId;

    /**
     * 创建时间
     */
    private Date createTime;

}
