package com.reading.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.reading.platform.common.serializer.UpperCaseSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 租户实体（幼儿园/机构）
 */
@Data
@TableName("t_tenant")
public class Tenant {

    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    private String name;

    @JsonProperty("loginAccount")
    private String code;

    @JsonProperty("contactPerson")
    private String contactName;

    private String contactPhone;

    private String contactEmail;

    private String address;

    private String logoUrl;

    @JsonSerialize(using = UpperCaseSerializer.class)
    private String status;

    @JsonProperty("expireDate")
    private LocalDateTime expireAt;

    @JsonProperty("studentQuota")
    private Integer maxStudents;

    @JsonProperty("teacherQuota")
    private Integer maxTeachers;

    @Schema(description = "创建人用户名", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private String createdBy;

    @Schema(description = "更新人用户名", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updatedBy;

    @Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @Schema(description = "更新时间", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @TableLogic
    private Integer deleted;

    // Not persisted - used in create response to return temp password
    @TableField(exist = false)
    private String tempPassword;

}
