package dto

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

	"github.com/shopspring/decimal"
)

type LineReversePositionGetPageReq struct {
	dto.Pagination `search:"-"`
	ApiId          int64  `form:"apiId"  search:"type:exact;column:api_id;table:line_reverse_position" comment:"api_id"`
	ReverseApiId   int64  `form:"reverseApiId"  search:"type:exact;column:reverse_api_id;table:line_reverse_position" comment:"反单api_id"`
	Side           string `form:"side"  search:"type:exact;column:side;table:line_reverse_position" comment:"买卖方向 BUY SELL"`
	PositionSide   string `form:"positionSide"  search:"type:exact;column:position_side;table:line_reverse_position" comment:"持仓方向 LONG SHORT"`
	Symbol         string `form:"symbol"  search:"type:contains;column:symbol;table:line_reverse_position" comment:"交易对"`
	LineReversePositionOrder
}

type LineReversePositionOrder struct {
	Id            string `form:"idOrder"  search:"type:order;column:id;table:line_reverse_position"`
	ApiId         string `form:"apiIdOrder"  search:"type:order;column:api_id;table:line_reverse_position"`
	ReverseApiId  string `form:"reverseApiIdOrder"  search:"type:order;column:reverse_api_id;table:line_reverse_position"`
	ReverseAmount string `form:"reverseAmountOrder"  search:"type:order;column:reverse_amount;table:line_reverse_position"`
	Side          string `form:"sideOrder"  search:"type:order;column:side;table:line_reverse_position"`
	PositionSide  string `form:"positionSideOrder"  search:"type:order;column:position_side;table:line_reverse_position"`
	Symbol        string `form:"symbolOrder"  search:"type:order;column:symbol;table:line_reverse_position"`
	Status        string `form:"statusOrder"  search:"type:order;column:status;table:line_reverse_position"`
	CreatedAt     string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_reverse_position"`
	UpdatedAt     string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_reverse_position"`
	DeletedAt     string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_reverse_position"`
	CreateBy      string `form:"createByOrder"  search:"type:order;column:create_by;table:line_reverse_position"`
	UpdateBy      string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_reverse_position"`
}

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

type LineReversePositionInsertReq struct {
	Id            int             `json:"-" comment:"主键"` // 主键
	ApiId         int             `json:"apiId" comment:"api_id"`
	ReverseApiId  int             `json:"reverseApiId" comment:"反单api_id"`
	ReverseAmount decimal.Decimal `json:"reverseAmount" comment:"反单仓位"`
	Side          string          `json:"side" comment:"买卖方向 BUY SELL"`
	PositionSide  string          `json:"positionSide" comment:"持仓方向 LONG SHORT"`
	Symbol        string          `json:"symbol" comment:"交易对"`
	Status        int             `json:"status" comment:"仓位状态 1-已开仓 2-已平仓"`
	common.ControlBy
}

func (s *LineReversePositionInsertReq) Generate(model *models.LineReversePosition) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ApiId = s.ApiId
	model.ReverseApiId = s.ReverseApiId
	model.ReverseAmount = s.ReverseAmount
	model.Side = s.Side
	model.PositionSide = s.PositionSide
	model.Symbol = s.Symbol
	model.Status = s.Status
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineReversePositionUpdateReq struct {
	Id            int             `uri:"id" comment:"主键"` // 主键
	ApiId         int             `json:"apiId" comment:"api_id"`
	ReverseApiId  int             `json:"reverseApiId" comment:"反单api_id"`
	ReverseAmount decimal.Decimal `json:"reverseAmount" comment:"反单仓位"`
	Side          string          `json:"side" comment:"买卖方向 BUY SELL"`
	PositionSide  string          `json:"positionSide" comment:"持仓方向 LONG SHORT"`
	Symbol        string          `json:"symbol" comment:"交易对"`
	Status        int             `json:"status" comment:"仓位状态 1-已开仓 2-已平仓"`
	common.ControlBy
}

func (s *LineReversePositionUpdateReq) Generate(model *models.LineReversePosition) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ApiId = s.ApiId
	model.ReverseApiId = s.ReverseApiId
	model.ReverseAmount = s.ReverseAmount
	model.Side = s.Side
	model.PositionSide = s.PositionSide
	model.Symbol = s.Symbol
	model.Status = s.Status
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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