package dto

import (
	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
	"strings"
)

type LineSymbolGroupGetPageReq struct {
	dto.Pagination `search:"-"`
	ExchangeType   string `form:"exchangeType" search:"-"`
	Type           string `form:"type"  search:"type:exact;column:type;table:line_symbol_group" comment:"类型:1=现货,2=合约"`
	LineSymbolGroupOrder
}

type LineSymbolGroupOrder struct {
	Id string `form:"idOrder"  search:"type:order;column:id;table:line_symbol_group"`
	// Exchange  string `form:"exchangeOrder" `
	GroupName string `form:"groupNameOrder"  search:"type:order;column:group_name;table:line_symbol_group"`
	Symbol    string `form:"symbolOrder"  search:"type:order;column:symbol;table:line_symbol_group"`
	GroupType string `form:"groupTypeOrder"  search:"type:order;column:groupType;table:line_symbol_group"`
	Type      string `form:"typeOrder"  search:"type:order;column:type;table:line_symbol_group"`
	CreatedAt string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_symbol_group"`
	UpdatedAt string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_symbol_group"`
	DeletedAt string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_symbol_group"`
	CreateBy  string `form:"createByOrder"  search:"type:order;column:create_by;table:line_symbol_group"`
	UpdateBy  string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_symbol_group"`
}

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

type LineSymbolGroupInsertReq struct {
	Id           int    `json:"-" comment:""` //
	ExchangeType string `json:"exchangeType"`
	GroupName    string `json:"groupName" comment:"交易对组名称"`
	Symbol       string `json:"symbol" comment:"交易对"`
	GroupType    string `json:"groupType" comment:"分组类型:1=普通类型"`
	Type         string `json:"type" comment:"类型:1=现货,2=合约"`
	common.ControlBy
}

func (s *LineSymbolGroupInsertReq) Generate(model *models.LineSymbolGroup) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	// model.ExchangeType = s.ExchangeType
	model.ExchangeType = s.ExchangeType
	model.GroupName = s.GroupName
	model.Symbol = strings.ReplaceAll(strings.ReplaceAll(s.Symbol, "，", ","), " ", "")
	model.Symbol = strings.ReplaceAll(model.Symbol, "\r\n", ",")
	model.Symbol = strings.ReplaceAll(model.Symbol, "\n", ",")
	model.GroupType = s.GroupType
	model.Type = s.Type
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineSymbolGroupUpdateReq struct {
	Id           int    `uri:"id" comment:""` //
	ExchangeType string `json:"exchangeType"`
	GroupName    string `json:"groupName" comment:"交易对组名称"`
	Symbol       string `json:"symbol" comment:"交易对"`
	GroupType    string `json:"groupType" comment:"分组类型:1=普通类型"`
	Type         string `json:"type" comment:"类型:1=现货,2=合约"`
	common.ControlBy
}

func (s *LineSymbolGroupUpdateReq) Generate(model *models.LineSymbolGroup) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	// model.ExchangeType = s.ExchangeType
	model.GroupName = s.GroupName
	model.Symbol = strings.ReplaceAll(strings.ReplaceAll(s.Symbol, "，", ","), " ", "")
	model.Symbol = strings.ReplaceAll(model.Symbol, "\r\n", ",")
	model.Symbol = strings.ReplaceAll(model.Symbol, "\n", ",")
	model.GroupType = s.GroupType
	model.ExchangeType = s.ExchangeType
	model.Type = s.Type
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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