package dto

import "time"

// TriggerSingleReq 单卡手动触发请求
type TriggerSingleReq struct {
	CardID   uint   `json:"card_id" validate:"required" description:"卡ID"`
	TaskType string `json:"task_type" validate:"required,oneof=polling:realname polling:carddata polling:package" description:"任务类型"`
}

// TriggerBatchReq 批量手动触发请求
type TriggerBatchReq struct {
	CardIDs  []uint `json:"card_ids" validate:"required,min=1,max=1000" description:"卡ID列表，最多1000个"`
	TaskType string `json:"task_type" validate:"required,oneof=polling:realname polling:carddata polling:package" description:"任务类型"`
}

// TriggerByConditionReq 条件筛选触发请求
type TriggerByConditionReq struct {
	TaskType      string `json:"task_type" validate:"required,oneof=polling:realname polling:carddata polling:package" description:"任务类型"`
	CardStatus    string `json:"card_status" validate:"omitempty" description:"卡状态筛选"`
	CarrierCode   string `json:"carrier_code" validate:"omitempty" description:"运营商代码筛选"`
	CardType      string `json:"card_type" validate:"omitempty" description:"卡类型筛选"`
	ShopID        *uint  `json:"shop_id" validate:"omitempty" description:"店铺ID筛选"`
	PackageIDs    []uint `json:"package_ids" validate:"omitempty" description:"套餐ID列表筛选"`
	EnablePolling *bool  `json:"enable_polling" validate:"omitempty" description:"是否启用轮询筛选"`
	Limit         int    `json:"limit" validate:"omitempty,min=1,max=1000" description:"限制数量，最多1000"`
}

// CancelTriggerReq 取消触发请求
type CancelTriggerReq struct {
	TriggerID uint `json:"trigger_id" validate:"required" description:"触发任务ID"`
}

// ManualTriggerLogResp 手动触发日志响应
type ManualTriggerLogResp struct {
	ID              uint       `json:"id" description:"日志ID"`
	TaskType        string     `json:"task_type" description:"任务类型"`
	TaskTypeName    string     `json:"task_type_name" description:"任务类型名称"`
	TriggerType     string     `json:"trigger_type" description:"触发类型：single/batch/by_condition"`
	TriggerTypeName string     `json:"trigger_type_name" description:"触发类型名称"`
	TotalCount      int        `json:"total_count" description:"总卡数"`
	ProcessedCount  int        `json:"processed_count" description:"已处理数"`
	SuccessCount    int        `json:"success_count" description:"成功数"`
	FailedCount     int        `json:"failed_count" description:"失败数"`
	Status          string     `json:"status" description:"状态：pending/processing/completed/cancelled"`
	StatusName      string     `json:"status_name" description:"状态名称"`
	TriggeredBy     uint       `json:"triggered_by" description:"触发人ID"`
	TriggeredAt     time.Time  `json:"triggered_at" description:"触发时间"`
	CompletedAt     *time.Time `json:"completed_at,omitempty" description:"完成时间"`
}

// ManualTriggerLogListResp 手动触发日志列表响应
type ManualTriggerLogListResp struct {
	Items    []*ManualTriggerLogResp `json:"items" description:"日志列表"`
	Total    int64                   `json:"total" description:"总数"`
	Page     int                     `json:"page" description:"当前页"`
	PageSize int                     `json:"size" description:"每页数量"`
}

// ListManualTriggerLogReq 查询手动触发日志请求
type ListManualTriggerLogReq struct {
	TaskType string `json:"task_type" query:"task_type" description:"任务类型筛选"`
	Page     int    `json:"page" query:"page" validate:"omitempty,min=1" description:"页码"`
	PageSize int    `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" description:"每页数量"`
}

// ManualTriggerStatusResp 手动触发状态响应
type ManualTriggerStatusResp struct {
	RunningTasks []*ManualTriggerLogResp `json:"running_tasks" description:"正在运行的任务"`
	QueueSizes   map[string]int64        `json:"queue_sizes" description:"各队列大小"`
}
