/** 工单优先级 */
export type TicketPriority = 'low' | 'normal' | 'high' | 'urgent'

/** 工单状态 */
export type TicketStatus = 'pending' | 'assigned' | 'processing' | 'resolved' | 'closed' | 'rejected'

/** 工单分类 */
export type TicketCategory = 'bug' | 'feature' | 'consultation' | 'complaint' | 'other'

/** 工单列表项 */
export interface Ticket {
  ticketId: number
  ticketNo: string         // 工单编号 TK-202403xxxxxx
  title: string
  content: string
  productId: number        // 关联应用ID
  productName?: string     // 应用名称（前端展示用）
  category: TicketCategory
  priority: TicketPriority
  status: TicketStatus
  attachments?: string[]   // 附件URL列表
  // 提交方
  submitUserId: number
  submitUserName?: string
  submitUserAvatar?: string
  // 分配方
  assigneeId?: number
  assigneeName?: string
  assigneeAvatar?: string
  // 时间
  createTime: string
  updateTime: string
  resolvedTime?: string
  closedTime?: string
  // 回复数
  replyCount: number
  // 是否已读（对当前用户）
  hasUnread?: boolean
}

/** 工单回复 */
export interface TicketReply {
  replyId: number
  ticketId: number
  content: string
  attachments?: string[]
  userId: number
  userName?: string
  userAvatar?: string
  isStaff: boolean        // 是否是客服/技术人员
  createTime: string
}

/** 提交工单表单 */
export interface TicketSubmitForm {
  title: string
  content: string
  productId: number
  category: TicketCategory
  priority: TicketPriority
  attachments?: string[]
}

/** 工单回复表单 */
export interface TicketReplyForm {
  ticketId: number
  content: string
  attachments?: string
}

/** 分配工单表单 */
export interface TicketAssignForm {
  ticketId: number
  assigneeId: number
}

/** 更新状态表单 */
export interface TicketStatusForm {
  ticketId: number
  status: TicketStatus
  remark?: string
}

/** 工单查询参数 */
export interface TicketQueryParams {
  productId?: number
  status?: TicketStatus
  category?: TicketCategory
  priority?: TicketPriority
  assigneeId?: number
  keywords?: string
  page?: number
  limit?: number
}

/** 工单统计 */
export interface TicketStats {
  total: number
  pending: number
  processing: number
  resolved: number
  closed: number
}
