package com.competition.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.competition.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;

@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "t_biz_contest_work", autoResultMap = true)
@Schema(description = "赛事作品实体")
public class BizContestWork extends BaseEntity {

    @Schema(description = "租户ID")
    @TableField("tenant_id")
    private Long tenantId;

    @Schema(description = "赛事ID")
    @TableField("contest_id")
    private Long contestId;

    @Schema(description = "报名ID")
    @TableField("registration_id")
    private Long registrationId;

    @Schema(description = "作品编号")
    @TableField("work_no")
    private String workNo;

    @Schema(description = "作品标题")
    private String title;

    @Schema(description = "作品描述")
    private String description;

    @Schema(description = "作品文件（JSON）")
    @TableField(value = "files", typeHandler = JacksonTypeHandler.class)
    private Object files;

    @Schema(description = "版本号")
    private Integer version;

    @Schema(description = "是否最新版本")
    @TableField("is_latest")
    private Boolean isLatest;

    @Schema(description = "作品状态：submitted/locked/reviewing/rejected/accepted")
    private String status;

    @Schema(description = "提交时间")
    @TableField("submit_time")
    private LocalDateTime submitTime;

    @Schema(description = "提交人用户ID")
    @TableField("submitter_user_id")
    private Long submitterUserId;

    @Schema(description = "提交人账号")
    @TableField("submitter_account_no")
    private String submitterAccountNo;

    @Schema(description = "提交来源：teacher/student/team_leader")
    @TableField("submit_source")
    private String submitSource;

    @Schema(description = "预览图URL")
    @TableField("preview_url")
    private String previewUrl;

    @Schema(description = "预览图URL列表（JSON）")
    @TableField(value = "preview_urls", typeHandler = JacksonTypeHandler.class)
    private List<String> previewUrls;

    @Schema(description = "AI模型元数据（JSON）")
    @TableField(value = "ai_model_meta", typeHandler = JacksonTypeHandler.class)
    private Object aiModelMeta;

    @Schema(description = "用户作品ID")
    @TableField("user_work_id")
    private Long userWorkId;

    // ====== 赛果字段 ======
    @Schema(description = "最终得分")
    @TableField("final_score")
    private BigDecimal finalScore;

    @Schema(description = "排名")
    @TableField("`rank`")
    private Integer rank;

    @Schema(description = "获奖等级：first/second/third/excellent/none")
    @TableField("award_level")
    private String awardLevel;

    @Schema(description = "奖项名称")
    @TableField("award_name")
    private String awardName;

    @Schema(description = "证书URL")
    @TableField("certificate_url")
    private String certificateUrl;
}
