package com.storlead.user.pojo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.storlead.framework.mybatis.entity.SysBaseField;
import com.storlead.framework.mybatis.entity.TenantBaseField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 租户用户表 {@code tenant_user}：表示某平台用户（{@code userId}）在某个租户（{@code tenantId} / {@code enterpriseId}）下的成员关系，
 * 租户登录、授权范围应以此表为准。
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "TenantUserEntity", description = "企业-账号关系表")
@TableName("tenant_user")
public class TenantUserEntity extends TenantBaseField {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty("主键")
    private Long id;

    @ApiModelProperty("企业主键ID")
    private Long enterpriseId;

    @ApiModelProperty("用户ID")
    private Long userId;

    @ApiModelProperty("是否企业管理员:0否1是")
    private Integer isAdmin;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("加入时间")
    private Date joinedAt;
}
