package dto

import (
	"cold-delivery/app/admin/model"
	"cold-delivery/common/dto"
	common "cold-delivery/common/model"
	"strings"
)

type CoolerBoxGetPageReq struct {
	dto.Pagination `search:"-"`
	Name           string `form:"name" search:"type:contains;column:name;table:cooler_box"`                    // 保温箱
	Sn             string `form:"sn" search:"type:contains;column:sn;table:cooler_box"`                        // sn
	Status         string `form:"status" search:"type:exact;column:status;table:cooler_box"`                   // 状态
	ShowTemp       bool   `form:"showTemp" search:"-"`                                                         // 展示最新温度
	MonitorStatus  string `form:"monitorStatus" search:"type:contains;column:monitor_status;table:cooler_box"` // 监控状态
	CoolerBoxOrder
}

type CoolerBoxOrder struct {
	CreatedAtOrder string `search:"type:order;column:created_at;table:cooler_box" form:"createdAtOrder" default:"desc"`
}

func (m *CoolerBoxGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type CoolerBoxInsertReq struct {
	Id                int      `json:"id" comment:"编码" swaggerignore:"true"` // 编码
	Name              string   `json:"name"`                                 // 保温箱名称
	Sn                string   `json:"sn"`                                   // sn
	Status            string   `json:"status"`                               // 1-停用 2-正常
	ColdSpots         string   `json:"cold_spots"`                           //遇冷地点
	ColdTemperatures  string   `json:"cold_temperatures"`                    //遇冷温度
	Code              []string `json:"code"`
	ForColdCoolerTime float64  `json:"for_cold_cooler_time" gorm:"comment:预冷要求"` //保温箱预冷要求
	common.ControlBy  `swaggerignore:"true"`
	common.DeptBy     `swaggerignore:"true"`
}

func (s *CoolerBoxInsertReq) Generate(model *model.CoolerBox) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	model.Sn = strings.TrimSpace(s.Sn)
	model.Status = s.Status
	model.ColdSpots = s.ColdSpots
	model.ColdTemperatures = s.ColdTemperatures
	model.ForColdCoolerTime = s.ForColdCoolerTime
	if s.ControlBy.UpdateBy != 0 {
		model.UpdateBy = s.UpdateBy
	}
	if s.ControlBy.CreateBy != 0 {
		model.CreateBy = s.CreateBy
	}
	if s.DeptBy.DeptId != 0 {
		model.DeptId = s.DeptId
	}
}

func (s *CoolerBoxInsertReq) GetId() interface{} {
	return s.Id
}

type CoolerBoxUpdateReq struct {
	Id                int      `json:"id" comment:"编码"` // 编码
	Name              string   `json:"name"`            // 保温箱名称
	Sn                string   `json:"sn"`              // sn
	Status            string   `json:"status"`          // 1-停用 2-正常
	ColdSpots         string   `json:"cold_spots"`      //遇冷地点
	ColdTemperatures  string   `json:"cold_temperatures"`
	Code              []string `json:"code"`
	ForColdCoolerTime float64  `json:"for_cold_cooler_time" gorm:"comment:预冷要求"` //保温箱预冷要求
	common.ControlBy  `swaggerignore:"true"`
}

func (s *CoolerBoxUpdateReq) Generate(model *model.CoolerBox) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	model.Sn = strings.TrimSpace(s.Sn)
	model.Status = s.Status
	model.ColdSpots = s.ColdSpots
	model.ColdTemperatures = s.ColdTemperatures
	model.ForColdCoolerTime = s.ForColdCoolerTime
	if s.ControlBy.UpdateBy != 0 {
		model.UpdateBy = s.UpdateBy
	}
	if s.ControlBy.CreateBy != 0 {
		model.CreateBy = s.CreateBy
	}
}

func (s *CoolerBoxUpdateReq) GetId() interface{} {
	return s.Id
}

type CoolerBoxGetReq struct {
	Id int `uri:"id"`
}

func (s *CoolerBoxGetReq) GetId() interface{} {
	return s.Id
}

type CoolerBoxDeleteReq struct {
	Id               int `json:"id"`
	common.ControlBy `swaggerignore:"true"`
}

func (s *CoolerBoxDeleteReq) GetId() interface{} {
	return s.Id
}

type CoolerBoxBatchInsertReq struct {
	List             []CoolerBoxInsertReq
	Status           string `json:"status"` // 1-停用 2-正常
	common.ControlBy `swaggerignore:"true"`
	common.DeptBy    `swaggerignore:"true"`
}
type CoolerBoxBatchReqSN struct {
	Id    int `json:"id"`
	Page  int `json:"page"`
	PageZ int `json:"page_z"`
}
type CoolerBoxBatchReq struct {
	SnId      string `json:"sn"`
	T_id      string `json:"t_id"`
	StartTime string `json:"start_time"`
	EndTime   string `json:"end_time"`
	Page      int    `json:"page"`
	PageZ     int    `json:"page_z"`
}
type CoolerBoxReq struct {
	T_sn       string `json:"T_sn"`
	Id         string `json:"Id"`
	CoolerName string `json:"CoolerName"`
}
type HistoricalData struct {
	Sn          string `json:"sn"`           //设备Sn
	StartTime   string `json:"start_time"`   //开始时间
	EndTime     string `json:"end_time"`     //结束时间
	CompanyName string `json:"company_name"` //公司名称
	Driver      string `json:"driver"`       //配送员，司机
	T_id        string `json:"t_id"`
}
type GetCoolerBoxIce struct {
	dto.Pagination `search:"-"`
	CoolerBoxId    int `form:"cooler_box_id"`
}
type GetCoolerBoxIceAll struct {
	dto.Pagination `search:"-"`
	StartTime      string `form:"startTime" search:"-"`                                                            // 开始时间
	EndTime        string `form:"endTime" search:"-"`                                                              // 结束时间
	CoolerBoxId    string `form:"coolerBoxId" search:"type:contains;column:cooler_box_id;table:cooler_box_record"` // 保温箱id
	Status         string `form:"status" search:"type:contains;column:status;table:cooler_box_record"`             // 状态
}

func (m *GetCoolerBoxIceAll) GetNeedSearch() interface{} {
	return *m
}
