package dto

import "git.huangwc.com/pig/pig-farm-controller/internal/infra/models"

// CreateDeviceRequest 定义了创建设备时需要传入的参数
type CreateDeviceRequest struct {
	Name             string                 `json:"name" validate:"required"`
	DeviceTemplateID uint32                 `json:"device_template_id" validate:"required"`
	AreaControllerID uint32                 `json:"area_controller_id" validate:"required"`
	Location         string                 `json:"location,omitempty" validate:"omitempty"`
	Properties       map[string]interface{} `json:"properties,omitempty" validate:"omitempty"`
}

// UpdateDeviceRequest 定义了更新设备时需要传入的参数
type UpdateDeviceRequest struct {
	Name             string                 `json:"name" validate:"required"`
	DeviceTemplateID uint32                 `json:"device_template_id" validate:"required"`
	AreaControllerID uint32                 `json:"area_controller_id" validate:"required"`
	Location         string                 `json:"location,omitempty" validate:"omitempty"`
	Properties       map[string]interface{} `json:"properties,omitempty" validate:"omitempty"`
}

// ManualControlDeviceRequest 定义了手动控制设备时需要传入的参数
type ManualControlDeviceRequest struct {
	// Action 不传表示这是一个传感器, 会触发一次采集
	Action *string `json:"action"`
}

// CreateAreaControllerRequest 定义了创建区域主控时需要传入的参数
type CreateAreaControllerRequest struct {
	Name       string                 `json:"name" validate:"required"`
	NetworkID  string                 `json:"network_id" validate:"required"`
	Location   string                 `json:"location,omitempty" validate:"omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty" validate:"omitempty"`
}

// UpdateAreaControllerRequest 定义了更新区域主控时需要传入的参数
type UpdateAreaControllerRequest struct {
	Name       string                 `json:"name" validate:"required"`
	NetworkID  string                 `json:"network_id" validate:"required"`
	Location   string                 `json:"location,omitempty" validate:"omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty" validate:"omitempty"`
}

// CreateDeviceTemplateRequest 定义了创建设备模板时需要传入的参数
type CreateDeviceTemplateRequest struct {
	Name         string                   `json:"name" validate:"required"`
	Manufacturer string                   `json:"manufacturer,omitempty" validate:"omitempty"`
	Description  string                   `json:"description,omitempty" validate:"omitempty"`
	Category     models.DeviceCategory    `json:"category" validate:"required"`
	Commands     map[string]interface{}   `json:"commands" validate:"required"`
	Values       []models.ValueDescriptor `json:"values,omitempty" validate:"omitempty,dive"`
}

// UpdateDeviceTemplateRequest 定义了更新设备模板时需要传入的参数
type UpdateDeviceTemplateRequest struct {
	Name         string                   `json:"name" validate:"required"`
	Manufacturer string                   `json:"manufacturer,omitempty" validate:"omitempty"`
	Description  string                   `json:"description,omitempty" validate:"omitempty"`
	Category     models.DeviceCategory    `json:"category" validate:"required"`
	Commands     map[string]interface{}   `json:"commands" validate:"required"`
	Values       []models.ValueDescriptor `json:"values,omitempty" validate:"omitempty,dive"`
}

// DeviceResponse 定义了返回给客户端的单个设备信息的结构
type DeviceResponse struct {
	ID                 uint32                 `json:"id"`
	Name               string                 `json:"name"`
	DeviceTemplateID   uint32                 `json:"device_template_id"`
	DeviceTemplateName string                 `json:"device_template_name"`
	AreaControllerID   uint32                 `json:"area_controller_id"`
	AreaControllerName string                 `json:"area_controller_name"`
	Location           string                 `json:"location"`
	Properties         map[string]interface{} `json:"properties"`
	CreatedAt          string                 `json:"created_at"`
	UpdatedAt          string                 `json:"updated_at"`
}

// AreaControllerResponse 定义了返回给客户端的单个区域主控信息的结构
type AreaControllerResponse struct {
	ID         uint32                 `json:"id"`
	Name       string                 `json:"name"`
	NetworkID  string                 `json:"network_id"`
	Location   string                 `json:"location"`
	Status     string                 `json:"status"`
	Properties map[string]interface{} `json:"properties"`
	CreatedAt  string                 `json:"created_at"`
	UpdatedAt  string                 `json:"updated_at"`
}

// DeviceTemplateResponse 定义了返回给客户端的单个设备模板信息的结构
type DeviceTemplateResponse struct {
	ID           uint32                   `json:"id"`
	Name         string                   `json:"name"`
	Manufacturer string                   `json:"manufacturer"`
	Description  string                   `json:"description"`
	Category     models.DeviceCategory    `json:"category"`
	Commands     map[string]interface{}   `json:"commands"`
	Values       []models.ValueDescriptor `json:"values"`
	CreatedAt    string                   `json:"created_at"`
	UpdatedAt    string                   `json:"updated_at"`
}
