package dto

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

type IceRaftGetPageReq struct {
	dto.Pagination `search:"-"`
	Code           string `form:"code" search:"type:contains;column:code;table:ice_raft"`  // 冰排名称
	Status         string `form:"status" search:"type:exact;column:status;table:ice_raft"` // 状态
	IceRaftOrder
}
type IceRaftRecordRecording 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:ice_raft_record"` // 保温箱id
	IceLockerId    string `form:"iceLockerId" search:"type:contains;column:ice_locker_id;table:ice_raft_record"` // 冷冻柜id
	Code           string `form:"code" search:"type:contains;column:code;table:ice_raft_record"`                 // 冰排名称
}
type IceRaftGetNewestRecordPageReq struct {
	dto.Pagination `search:"-"`
	Code           string `form:"code" search:"type:contains;column:code;table:ice_raft"` // 冰排名称
	Status         string `form:"status" search:"-"`                                      // 状态
	IceLockerId    int    `form:"iceLockerId" search:"-"`                                 // 冷冻柜id
	CoolerBoxId    int    `form:"coolerBoxId" search:"-"`                                 // 保温箱id
	IceRaftOrder
}
type GetPageByCoolerBoxIdReq struct {
	CoolerBoxId int `form:"coolerBoxId" search:"-"` // 保温箱id
	IceRaftOrder
}

type IceRaftOrder struct {
	CreatedAtOrder string `search:"type:order;column:created_at;table:ice_raft" form:"createdAtOrder" default:"desc"`
	IdOrder        string `search:"type:order;column:id;table:ice_raft" form:"idOrder" default:"desc"`
}

func (m *IceRaftRecordRecording) GetNeedSearch() interface{} {
	return *m
}
func (m *IceRaftGetPageReq) GetNeedSearch() interface{} {
	return *m
}
func (m *IceRaftGetNewestRecordPageReq) GetNeedSearch() interface{} {
	return *m
}

type IceRaftInsertReq struct {
	Id               int              `json:"id" comment:"编码" swaggerignore:"true"`                     // 编码
	CodeList         []string         `json:"codeList" vd:"len($)>0;msg:'冰排编号不能为空'"`                    // 冰排名称
	Status           string           `json:"status"`                                                   // 1-停用 2-正常
	FreezeClaim      common.FloatList `json:"freezeClaim"`                                              // 冷冻要求 单位小时
	Label            string           `json:"label"`                                                    // 标签
	IceColdAddress   string           `json:"iceColdAddress" gorm:"size:128;comment:冰排预冷地点"`            //冰排遭冷地点
	SuitableForCold  string           `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排遇冷温度
	Sort             int              `json:"sort"`                                                     // 排序
	ForColdTime      float64          `json:"forColdTime"`                                              // 释冷时长 单位分钟
	common.ControlBy `swaggerignore:"true"`
	common.DeptBy    `swaggerignore:"true"`
}

func (s *IceRaftInsertReq) Generate(model *model.IceRaft, code string) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Code = code
	model.Status = s.Status
	model.FreezeClaim = s.FreezeClaim
	model.Label = s.Label
	model.IceColdAddress = s.IceColdAddress
	model.SuitableForCold = s.SuitableForCold
	model.Sort = s.Sort
	model.ForColdTime = s.ForColdTime
	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 *IceRaftInsertReq) GetId() interface{} {
	return s.Id
}

type IceRaftUpdateReq struct {
	Id               int              `json:"id" comment:"编码"`                                          // 编码
	Label            string           `json:"label" gorm:"size:128;comment:标签"`                         // 标签
	Code             string           `json:"code" vd:"len($)>0;msg:'冰排编号不能为空'"`                        // 冰排名称
	Status           string           `json:"status"`                                                   // 1-停用 2-正常
	FreezeClaim      common.FloatList `json:"freezeClaim"`                                              // 冷冻要求 单位小时
	IceColdAddress   string           `json:"iceColdAddress" gorm:"size:128;comment:冰排预冷地点"`            //冰排预冷地点
	SuitableForCold  string           `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排遇冷温度
	Sort             int              `json:"sort"`
	ForColdTime      float64          `json:"forColdTime"` // 适冷时长 单位分钟
	common.ControlBy `swaggerignore:"true"`
}

func (s *IceRaftUpdateReq) Generate(model *model.IceRaft) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Code = s.Code
	model.Status = s.Status
	model.FreezeClaim = s.FreezeClaim
	model.Label = s.Label
	model.IceColdAddress = s.IceColdAddress
	model.SuitableForCold = s.SuitableForCold
	model.Sort = s.Sort
	model.ForColdTime = s.ForColdTime
	if s.ControlBy.UpdateBy != 0 {
		model.UpdateBy = s.UpdateBy
	}
	if s.ControlBy.CreateBy != 0 {
		model.CreateBy = s.CreateBy
	}
}

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

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

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

type IceRaftGetByCodeReq struct {
	Code string `uri:"code"`
}
type GetCoolerBoxByIceRaft struct {
	Id string `json:"id"`
}

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

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

type IceRaftInStorageReq struct {
	Code             []string `json:"code"`
	IceLockerId      int      `json:"iceLockerId"` // 冷冻柜id
	FreezeClaim      float32  `json:"freezeClaim"` // 冷冻要求
	common.ControlBy `swaggerignore:"true"`
}
type IceRaftOutStorageReq struct {
	Code             []string `json:"code"`
	CoolerBoxId      int      `json:"coolerBoxId"`     // 保温箱id
	SuitableForCold  int      `json:"suitableForCold"` // 冰排适冷温度
	common.ControlBy `swaggerignore:"true"`
}
type BindCoolerBox struct {
	Code        []string `json:"code"`
	CoolerBoxId []int    `json:"coolerBoxId"` // 保温箱id
}
type UnBindCoolerBox struct {
	Code        string `json:"code"`
	CoolerBoxId []int  `json:"coolerBoxId"` // 保温箱id
}
type IceStartbleForColfTimReq struct {
	Id []string `json:"id"`
}
type IceOutStorageReq struct {
	Code             []string `json:"code"`
	common.ControlBy `swaggerignore:"true"`
}

type IceRaftRecordGetPageReq struct {
	dto.Pagination `search:"-"`
	IceRaftId      int    `form:"iceRaftId" search:"type:exact;column:ice_raft_id;table:ice_raft_record" vd:"$>0;msg:'冰排id不能为空'"` // 冰排id
	Status         string `form:"status" search:"type:exact;column:status;table:ice_raft_record"`                                 // 状态
	IceRaftRecordOrder
}
type IceRaftRecordOrder struct {
	CreatedAtOrder string `search:"type:order;column:created_at;table:ice_raft_record" form:"createdAtOrder" default:"desc"`
}

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

type IceRaftRecordUpdateReq struct {
	Id               int              `json:"id" comment:"编码"` // 编码
	IceLockerId      int              `json:"iceLockerId"`     // 冷冻柜id
	CoolerBoxId      int              `json:"coolerBoxId"`     // 保温箱id
	FreezeClaim      common.FloatList `json:"freezeClaim"`     // 冷冻要求 单位小时
	common.ControlBy `swaggerignore:"true"`
}

func (s *IceRaftRecordUpdateReq) GetId() interface{} {
	return s.Id
}
func (s *IceRaftRecordUpdateReq) Generate(model *model.IceRaftRecord) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.IceLockerId = s.IceLockerId
	model.CoolerBoxId = s.CoolerBoxId
	model.FreezeClaim = s.FreezeClaim
	if s.ControlBy.UpdateBy != 0 {
		model.UpdateBy = s.UpdateBy
	}
	if s.ControlBy.CreateBy != 0 {
		model.CreateBy = s.CreateBy
	}
}

type IceRaftRecordDeleteReq struct {
	Id               int `json:"id"`
	common.ControlBy `swaggerignore:"true"`
}
type IceRaftRecordEedReq struct {
	Id               []int `json:"iceRaftRecordId"`
	common.ControlBy `swaggerignore:"true"`
}

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