package dto

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

	"github.com/shopspring/decimal"
)

type LineReverseSettingGetPageReq struct {
	dto.Pagination `search:"-"`
	LineReverseSettingOrder
}

type LineReverseSettingOrder struct {
	Id                  string `form:"idOrder"  search:"type:order;column:id;table:line_reverse_setting"`
	ReverseOrderType    string `form:"reverseOrderTypeOrder"  search:"type:order;column:reverse_order_type;table:line_reverse_setting"`
	ReversePremiumRatio string `form:"reversePremiumRatioOrder"  search:"type:order;column:reverse_premium_ratio;table:line_reverse_setting"`
	CreatedAt           string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_reverse_setting"`
	UpdatedAt           string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_reverse_setting"`
	DeletedAt           string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_reverse_setting"`
	CreateBy            string `form:"createByOrder"  search:"type:order;column:create_by;table:line_reverse_setting"`
	UpdateBy            string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_reverse_setting"`
}

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

type LineReverseSettingInsertReq struct {
	Id                  int             `json:"-" comment:"主键id"` // 主键id
	ReverseOrderType    string          `json:"reverseOrderType" comment:"反单下单类型 LIMIT-限价 MARKET-市价"`
	ReversePremiumRatio decimal.Decimal `json:"reversePremiumRatio" comment:"溢价百分比"`
	TakeProfitRatio     decimal.Decimal `json:"takeProfitRatio" comment:"止盈百分比"`
	StopLossRatio       decimal.Decimal `json:"stopLossRatio" comment:"止损百分比"`
	common.ControlBy
}

func (s *LineReverseSettingInsertReq) Generate(model *models.LineReverseSetting) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ReverseOrderType = s.ReverseOrderType
	model.ReversePremiumRatio = s.ReversePremiumRatio
	model.StopLossRatio = s.StopLossRatio
	model.TakeProfitRatio = s.TakeProfitRatio
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineReverseSettingUpdateReq struct {
	Id                  int             `uri:"id" comment:"主键id"` // 主键id
	ReverseOrderType    string          `json:"reverseOrderType" comment:"反单下单类型 LIMIT-限价 MARKET-市价"`
	ReversePremiumRatio decimal.Decimal `json:"reversePremiumRatio" comment:"溢价百分比"`
	TakeProfitRatio     decimal.Decimal `json:"takeProfitRatio" comment:"止盈百分比"`
	StopLossRatio       decimal.Decimal `json:"stopLossRatio" comment:"止损百分比"`
	common.ControlBy
}

func (s *LineReverseSettingUpdateReq) Generate(model *models.LineReverseSetting) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ReverseOrderType = s.ReverseOrderType
	model.ReversePremiumRatio = s.ReversePremiumRatio
	model.StopLossRatio = s.StopLossRatio
	model.TakeProfitRatio = s.TakeProfitRatio
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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