package dto

import "time"

// AssetOperationLogListRequest 资产操作日志查询请求
type AssetOperationLogListRequest struct {
	Identifier    string `path:"identifier" description:"资产标识符（虚拟号/ICCID/IMEI/SN/MSISDN）" required:"true"`
	Page          int    `query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码（默认1）"`
	PageSize      int    `query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页条数（默认20，最大100）"`
	OperationType string `query:"operation_type" description:"操作类型（如 device_stop、card_allocate）"`
	ResultStatus  string `query:"result_status" description:"执行结果 (success:成功, failed:失败, denied:拒绝)"`
}

// AssetOperationLogItem 资产操作日志条目
type AssetOperationLogItem struct {
	ID        uint      `json:"id" description:"日志ID"`
	CreatedAt time.Time `json:"created_at" description:"操作时间"`

	OperatorID       *uint  `json:"operator_id,omitempty" description:"操作人ID（系统触发为空）"`
	OperatorType     string `json:"operator_type" description:"操作人类型名称 (系统:系统, 平台用户:平台用户, 代理账号:代理账号, 企业账号:企业账号, 个人客户:个人客户)"`
	OperatorTypeCode string `json:"operator_type_code" description:"操作人类型编码(system/admin_user/agent_user/enterprise_user/personal_customer)"`
	OperatorName     string `json:"operator_name" description:"操作人名称（优先返回可读名称）"`

	AssetType       string `json:"asset_type" description:"资产类型(iot_card/device)"`
	AssetID         uint   `json:"asset_id" description:"资产ID"`
	AssetIdentifier string `json:"asset_identifier" description:"资产标识(ICCID/虚拟号)"`

	OperationType string `json:"operation_type" description:"操作类型"`
	OperationDesc string `json:"operation_desc" description:"操作描述（中文）"`

	OperationContentBefore map[string]any    `json:"operation_content_before,omitempty" description:"操作内容（变更前）"`
	OperationContentAfter  map[string]any    `json:"operation_content_after,omitempty" description:"操作内容（变更后）"`
	OperationFieldsDesc    map[string]string `json:"operation_fields_desc,omitempty" description:"操作内容字段说明（key 为字段名，value 为中文说明）"`

	BeforeData map[string]any `json:"before_data,omitempty" description:"变更前数据"`
	AfterData  map[string]any `json:"after_data,omitempty" description:"变更后数据"`

	RequestID     *string `json:"request_id,omitempty" description:"请求ID"`
	IPAddress     *string `json:"ip_address,omitempty" description:"请求IP"`
	UserAgent     *string `json:"user_agent,omitempty" description:"用户代理"`
	RequestPath   *string `json:"request_path,omitempty" description:"请求路径"`
	RequestMethod *string `json:"request_method,omitempty" description:"请求方法"`

	ResultStatus string  `json:"result_status" description:"执行结果 (success:成功, failed:失败, denied:拒绝)"`
	ErrorCode    *string `json:"error_code,omitempty" description:"错误码"`
	ErrorMsg     *string `json:"error_msg,omitempty" description:"错误摘要"`

	BatchTotal   int `json:"batch_total" description:"批量总数"`
	SuccessCount int `json:"success_count" description:"批量成功数"`
	FailCount    int `json:"fail_count" description:"批量失败数"`
}

// AssetOperationLogListResponse 资产操作日志分页响应
type AssetOperationLogListResponse struct {
	Total    int64                    `json:"total" description:"总条数"`
	Page     int                      `json:"page" description:"当前页码"`
	PageSize int                      `json:"page_size" description:"每页条数"`
	Items    []*AssetOperationLogItem `json:"items" description:"日志列表"`
}
