package dto

import (
	"github.com/shopspring/decimal"
	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type LinePriceLimitGetPageReq struct {
	dto.Pagination  `search:"-"`
	Symbol          string `form:"symbol"  search:"type:exact;column:symbol;table:line_price_limit" comment:"交易对"`
	Type            string `form:"type"  search:"type:exact;column:type;table:line_price_limit" comment:"类型:1=现货,2=合约"`
	DirectionStatus string `form:"directionStatus"  search:"type:exact;column:direction_status;table:line_price_limit" comment:"方向:1=涨,2=跌"`
	Range           string `form:"range"  search:"type:exact;column:range;table:line_price_limit" comment:"幅度"`
	StartRange      string `form:"startRange" search:"-" comment:"幅度"`
	EndRange        string `form:"endRange" search:"-" comment:"幅度"`
	LinePriceLimitOrder
}

type LinePriceLimitOrder struct {
	Id              string `form:"idOrder"  search:"type:order;column:id;table:line_price_limit"`
	Symbol          string `form:"symbolOrder"  search:"type:order;column:symbol;table:line_price_limit"`
	Type            string `form:"typeOrder"  search:"type:order;column:type;table:line_price_limit"`
	DirectionStatus string `form:"directionStatusOrder"  search:"type:order;column:direction_status;table:line_price_limit"`
	Range           string `form:"rangeOrder"  search:"type:order;column:range;table:line_price_limit"`
	CreatedAt       string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_price_limit"`
	UpdatedAt       string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_price_limit"`
	DeletedAt       string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_price_limit"`
	CreateBy        string `form:"createByOrder"  search:"type:order;column:create_by;table:line_price_limit"`
	UpdateBy        string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_price_limit"`
}

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

type LinePriceLimitInsertReq struct {
	Id              int             `json:"-" comment:"id"` // id
	Symbol          string          `json:"symbol" comment:"交易对"`
	Type            string          `json:"type" comment:"类型:1=现货,2=合约"`
	DirectionStatus string          `json:"directionStatus" comment:"方向:1=涨,2=跌"`
	Range           decimal.Decimal `json:"range" comment:"幅度"`
	common.ControlBy
}

func (s *LinePriceLimitInsertReq) Generate(model *models.LinePriceLimit) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Symbol = s.Symbol
	model.Type = s.Type
	model.DirectionStatus = s.DirectionStatus
	model.Range = s.Range
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LinePriceLimitUpdateReq struct {
	Id              int             `uri:"id" comment:"id"` // id
	Symbol          string          `json:"symbol" comment:"交易对"`
	Type            string          `json:"type" comment:"类型:1=现货,2=合约"`
	DirectionStatus string          `json:"directionStatus" comment:"方向:1=涨,2=跌"`
	Range           decimal.Decimal `json:"range" comment:"幅度"`
	common.ControlBy
}

func (s *LinePriceLimitUpdateReq) Generate(model *models.LinePriceLimit) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Symbol = s.Symbol
	model.Type = s.Type
	model.DirectionStatus = s.DirectionStatus
	model.Range = s.Range
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

// LinePriceLimitGetReq 功能获取请求参数
type LinePriceLimitGetReq struct {
	Id int `uri:"id"`
}

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

// LinePriceLimitDeleteReq 功能删除请求参数
type LinePriceLimitDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *LinePriceLimitDeleteReq) GetId() interface{} {
	return s.Ids
}

type Ticker24Hr struct {
	Symbol             string `json:"symbol"`
	PriceChange        string `json:"priceChange"`
	PriceChangePercent string `json:"priceChangePercent"`
	WeightedAvgPrice   string `json:"weightedAvgPrice"`
	PrevClosePrice     string `json:"prevClosePrice"`
	LastPrice          string `json:"lastPrice"`
	LastQty            string `json:"lastQty"`
	BidPrice           string `json:"bidPrice"`
	BidQty             string `json:"bidQty"`
	AskPrice           string `json:"askPrice"`
	AskQty             string `json:"askQty"`
	OpenPrice          string `json:"openPrice"`
	HighPrice          string `json:"highPrice"`
	LowPrice           string `json:"lowPrice"`
	Volume             string `json:"volume"`
	QuoteVolume        string `json:"quoteVolume"`
	OpenTime           int64  `json:"openTime"`
	CloseTime          int64  `json:"closeTime"`
	FirstId            int    `json:"firstId"`
	LastId             int    `json:"lastId"`
	Count              int    `json:"count"`
}
type FutTicker24Hr struct {
	Symbol             string `json:"symbol"`
	PriceChange        string `json:"priceChange"`
	PriceChangePercent string `json:"priceChangePercent"`
	WeightedAvgPrice   string `json:"weightedAvgPrice"`
	LastPrice          string `json:"lastPrice"`
	LastQty            string `json:"lastQty"`
	OpenPrice          string `json:"openPrice"`
	HighPrice          string `json:"highPrice"`
	LowPrice           string `json:"lowPrice"`
	Volume             string `json:"volume"`
	QuoteVolume        string `json:"quoteVolume"`
	OpenTime           int64  `json:"openTime"`
	CloseTime          int64  `json:"closeTime"`
	FirstId            int    `json:"firstId"`
	LastId             int    `json:"lastId"`
	Count              int    `json:"count"`
}
