/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.martial.pojo.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;

import java.time.LocalDateTime;

/**
 * 裁判邀请码实体类
 *
 * @author BladeX
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("martial_judge_invite")
@Schema(description = "裁判邀请码")
public class MartialJudgeInvite extends TenantEntity {

	private static final long serialVersionUID = 1L;

	// ========== 角色常量 ==========
	/** 裁判员 */
	public static final String ROLE_JUDGE = "judge";
	/** 主裁判 */
	public static final String ROLE_CHIEF_JUDGE = "chief_judge";
	/** 总裁(裁判长) */
	public static final String ROLE_GENERAL_JUDGE = "general_judge";

	/**
	 * 赛事ID
	 */
	@Schema(description = "赛事ID")
	private Long competitionId;

	/**
	 * 裁判ID
	 */
	@Schema(description = "裁判ID")
	private Long judgeId;

	/**
	 * 邀请码
	 */
	@Schema(description = "邀请码")
	private String inviteCode;

	/**
	 * 角色(judge-裁判员, chief_judge-主裁判, general_judge-总裁)
	 */
	@Schema(description = "角色")
	private String role;

	/**
	 * 分配场地ID (总裁时为null，表示负责所有场地)
	 */
	@Schema(description = "分配场地ID")
	private Long venueId;

	/**
	 * 分配项目(JSON数组)
	 */
	@Schema(description = "分配项目")
	private String projects;

	/**
	 * 过期时间
	 */
	@Schema(description = "过期时间")
	private LocalDateTime expireTime;

	/**
	 * 是否已使用(0-未使用,1-已使用)
	 */
	@Schema(description = "是否已使用")
	private Integer isUsed;

	/**
	 * 使用时间
	 */
	@Schema(description = "使用时间")
	private LocalDateTime useTime;

	/**
	 * 设备信息
	 */
	@Schema(description = "设备信息")
	private String deviceInfo;

	/**
	 * 登录IP
	 */
	@Schema(description = "登录IP")
	private String loginIp;

	/**
	 * 访问令牌
	 */
	@Schema(description = "访问令牌")
	private String accessToken;

	/**
	 * token过期时间
	 */
	@Schema(description = "token过期时间")
	private LocalDateTime tokenExpireTime;

	/**
	 * 邀请状态(0-待回复,1-已接受,2-已拒绝,3-已取消)
	 */
	@Schema(description = "邀请状态")
	private Integer inviteStatus;

	/**
	 * 邀请时间
	 */
	@Schema(description = "邀请时间")
	private LocalDateTime inviteTime;

	/**
	 * 回复时间
	 */
	@Schema(description = "回复时间")
	private LocalDateTime replyTime;

	/**
	 * 回复备注
	 */
	@Schema(description = "回复备注")
	private String replyNote;

	/**
	 * 联系电话
	 */
	@Schema(description = "联系电话")
	private String contactPhone;

	/**
	 * 联系邮箱
	 */
	@Schema(description = "联系邮箱")
	private String contactEmail;

	/**
	 * 邀请消息
	 */
	@Schema(description = "邀请消息")
	private String inviteMessage;

	/**
	 * 取消原因
	 */
	@Schema(description = "取消原因")
	private String cancelReason;

	/**
	 * 裁判类型
	 */
	@Schema(description = "裁判类型")
	private Integer refereeType;

	/**
	 * 判断是否为裁判员
	 */
	public boolean isJudge() {
		return ROLE_JUDGE.equals(this.role);
	}

	/**
	 * 判断是否为主裁判
	 */
	public boolean isChiefJudge() {
		return ROLE_CHIEF_JUDGE.equals(this.role);
	}

	/**
	 * 判断是否为总裁
	 */
	public boolean isGeneralJudge() {
		return ROLE_GENERAL_JUDGE.equals(this.role);
	}

}
