package com.gxwebsoft.app.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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 开发者资源（服务器/数据库/云存储/域名/SSL证书）
 *
 * @author 科技小王子
 * @since 2026-03-31
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("app_resource")
@Schema(name = "AppResource对象", description = "开发者资源")
public class AppResource implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "资源ID")
    @TableId(value = "resource_id", type = IdType.AUTO)
    private Long resourceId;

    @Schema(description = "资源类型: server/database/storage/domain/ssl")
    private String resourceType;

    @Schema(description = "资源名称")
    private String name;

    @Schema(description = "服务商: tencent/aliyun/huawei/other")
    private String provider;

    @Schema(description = "关联应用ID（可选）")
    private Long websiteId;

    @Schema(description = "关联应用名称（冗余）")
    private String websiteName;

    // ─── 服务器字段 ───────────────────────────────────────
    @Schema(description = "IP地址（服务器用）")
    private String ip;

    // ─── 数据库字段 ───────────────────────────────────────
    @Schema(description = "数据库类型: MySQL/PostgreSQL/Redis/MongoDB（数据库用）")
    private String dbType;

    @Schema(description = "连接主机地址（数据库用）")
    private String host;

    @Schema(description = "连接端口（数据库用）")
    private Integer port;

    // ─── 云存储字段 ───────────────────────────────────────
    @Schema(description = "地区/Region（云存储用）")
    private String region;

    @Schema(description = "访问权限: public-read/private（云存储用）")
    private String acl;

    @Schema(description = "已用空间（字节，云存储用）")
    private Long usedBytes;

    // ─── 域名字段 ─────────────────────────────────────────
    @Schema(description = "域名（域名用）")
    private String domain;

    @Schema(description = "注册商（域名用）")
    private String registrar;

    @Schema(description = "是否已备案（域名用）")
    private Boolean icp;

    @Schema(description = "ICP备案号（域名用）")
    private String icpNo;

    @Schema(description = "是否已绑定SSL（域名用，冗余）")
    private Boolean sslBound;

    // ─── SSL证书字段 ──────────────────────────────────────
    @Schema(description = "证书类型: DV/OV/EV（SSL用）")
    private String certType;

    @Schema(description = "颁发机构（SSL用）")
    private String issuer;

    // ─── 通用字段 ─────────────────────────────────────────
    @Schema(description = "状态: running/stopped/expired/pending")
    private String status;

    @Schema(description = "到期时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate expireAt;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "所属用户ID")
    private Integer userId;

    @Schema(description = "租户ID")
    private Integer tenantId;

    @Schema(description = "是否删除: 0否 1是")
    private Integer deleted;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
}
