package com.lesingle.modules.biz.contest.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.lesingle.common.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 活动实体（35+ 字段，7 个 JSON 列）
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "t_biz_contest", autoResultMap = true)
@Schema(description = "活动实体")
public class BizContest extends BaseEntity {

    @Schema(description = "活动名称")
    @TableField("contest_name")
    private String contestName;

    @Schema(description = "活动类型：individual/team")
    @TableField("contest_type")
    private String contestType;

    @Schema(description = "活动发布状态", allowableValues = {"published", "unpublished"})
    @TableField("contest_state")
    private String contestState;

    @Schema(description = "活动进度状态：ongoing/finished")
    private String status;

    @Schema(description = "开始时间")
    @TableField("start_time")
    private LocalDateTime startTime;

    @Schema(description = "结束时间")
    @TableField("end_time")
    private LocalDateTime endTime;

    @Schema(description = "线下地址")
    private String address;

    @Schema(description = "活动详情（富文本）")
    private String content;

    @Schema(description = "可见范围", allowableValues = {"public", "designated", "internal", "private"})
    private String visibility;

    // ====== 授权租户（JSON） ======
    @Schema(description = "授权租户ID数组")
    @TableField(value = "contest_tenants", typeHandler = JacksonTypeHandler.class)
    private List<Integer> contestTenants;

    // ====== 封面和联系方式 ======
    @Schema(description = "封面图URL")
    @TableField("cover_url")
    private String coverUrl;

    @Schema(description = "海报URL")
    @TableField("poster_url")
    private String posterUrl;

    @Schema(description = "联系人姓名")
    @TableField("contact_name")
    private String contactName;

    @Schema(description = "联系电话")
    @TableField("contact_phone")
    private String contactPhone;

    @Schema(description = "联系二维码")
    @TableField("contact_qrcode")
    private String contactQrcode;

    // ====== 主办/协办/赞助（JSON） ======
    @Schema(description = "主办方信息（JSON）")
    @TableField(value = "organizers", typeHandler = JacksonTypeHandler.class)
    private Object organizers;

    @Schema(description = "协办方信息（JSON）")
    @TableField(value = "co_organizers", typeHandler = JacksonTypeHandler.class)
    private Object coOrganizers;

    @Schema(description = "赞助方信息（JSON）")
    @TableField(value = "sponsors", typeHandler = JacksonTypeHandler.class)
    private Object sponsors;

    // ====== 报名配置 ======
    @Schema(description = "报名开始时间")
    @TableField("register_start_time")
    private LocalDateTime registerStartTime;

    @Schema(description = "报名结束时间")
    @TableField("register_end_time")
    private LocalDateTime registerEndTime;

    @Schema(description = "报名状态")
    @TableField("register_state")
    private String registerState;

    @Schema(description = "是否需要审核")
    @TableField("require_audit")
    private Boolean requireAudit;

    @Schema(description = "允许参赛的年级（JSON数组）")
    @TableField(value = "allowed_grades", typeHandler = JacksonTypeHandler.class)
    private List<Integer> allowedGrades;

    @Schema(description = "允许参赛的班级（JSON数组）")
    @TableField(value = "allowed_classes", typeHandler = JacksonTypeHandler.class)
    private List<Integer> allowedClasses;

    @Schema(description = "团队最小人数")
    @TableField("team_min_members")
    private Integer teamMinMembers;

    @Schema(description = "团队最大人数")
    @TableField("team_max_members")
    private Integer teamMaxMembers;

    // ====== 目标筛选 ======
    @Schema(description = "目标城市（JSON数组）")
    @TableField(value = "target_cities", typeHandler = JacksonTypeHandler.class)
    private List<String> targetCities;

    @Schema(description = "最小年龄")
    @TableField("age_min")
    private Integer ageMin;

    @Schema(description = "最大年龄")
    @TableField("age_max")
    private Integer ageMax;

    // ====== 提交配置 ======
    @Schema(description = "提交规则", allowableValues = {"once", "resubmit"})
    @TableField("submit_rule")
    private String submitRule;

    @Schema(description = "提交开始时间")
    @TableField("submit_start_time")
    private LocalDateTime submitStartTime;

    @Schema(description = "提交结束时间")
    @TableField("submit_end_time")
    private LocalDateTime submitEndTime;

    @Schema(description = "作品类型")
    @TableField("work_type")
    private String workType;

    @Schema(description = "作品要求")
    @TableField("work_requirement")
    private String workRequirement;

    // ====== 评审配置 ======
    @Schema(description = "评审规则ID")
    @TableField("review_rule_id")
    private Long reviewRuleId;

    @Schema(description = "评审开始时间")
    @TableField("review_start_time")
    private LocalDateTime reviewStartTime;

    @Schema(description = "评审结束时间")
    @TableField("review_end_time")
    private LocalDateTime reviewEndTime;

    // ====== 成果发布 ======
    @Schema(description = "成绩发布状态", allowableValues = {"published", "unpublished"})
    @TableField("result_state")
    private String resultState;

    @Schema(description = "成绩发布时间")
    @TableField("result_publish_time")
    private LocalDateTime resultPublishTime;
}
