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 com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.gxwebsoft.common.core.config.JsonArrayToStringDeserializer;
import com.gxwebsoft.common.core.config.JsonStringToArraySerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * 应用工单
 *
 * @author 科技小王子
 * @since 2026-03-30
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("app_ticket")
@Schema(name = "AppTicket对象", description = "应用工单")
public class AppTicket implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "工单ID")
    @TableId(value = "ticket_id", type = IdType.AUTO)
    private Long ticketId;

    @Schema(description = "工单编号（TK-yyyyMMddHHmmss+4位随机）")
    private String ticketNo;

    @Schema(description = "工单标题")
    private String title;

    @Schema(description = "工单内容描述")
    private String content;

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

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

    @Schema(description = "工单分类: bug/feature/consultation/complaint/other")
    private String category;

    @Schema(description = "优先级: low/normal/high/urgent")
    private String priority;

    @Schema(description = "状态: pending/assigned/processing/resolved/closed/rejected")
    private String status;

    @Schema(description = "附件JSON数组")
    @JsonDeserialize(using = JsonArrayToStringDeserializer.class)
    @JsonSerialize(using = JsonStringToArraySerializer.class)
    private String attachments;

    @Schema(description = "提交人用户ID")
    private Integer submitUserId;

    @Schema(description = "提交人昵称（冗余）")
    private String submitUserName;

    @Schema(description = "提交人头像（冗余）")
    private String submitUserAvatar;

    @Schema(description = "分配的处理人用户ID")
    private Integer assigneeId;

    @Schema(description = "处理人昵称（冗余）")
    private String assigneeName;

    @Schema(description = "处理人头像（冗余）")
    private String assigneeAvatar;

    @Schema(description = "回复数量")
    private Integer replyCount;

    @Schema(description = "解决时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime resolvedTime;

    @Schema(description = "关闭时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime closedTime;

    @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;
}
