package dto

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

	"github.com/shopspring/decimal"
)

type LineSystemSettingGetPageReq struct {
	dto.Pagination `search:"-"`
	LineSystemSettingOrder
}

type LineSystemSettingOrder struct {
	Id                  string `form:"idOrder"  search:"type:order;column:id;table:line_system_setting"`
	CreatedAt           string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_system_setting"`
	UpdatedAt           string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_system_setting"`
	DeletedAt           string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_system_setting"`
	Time                string `form:"timeOrder"  search:"type:order;column:time;table:line_system_setting"`
	BatchTime           string `form:"batchTimeOrder"  search:"type:order;column:batch_time;table:line_system_setting"`
	ProfitRate          string `form:"profitRateOrder"  search:"type:order;column:profit_rate;table:line_system_setting"`
	CoverOrderTypeBRate string `form:"coverOrderTypeBRateOrder"  search:"type:order;column:cover_order_type_b_rate;table:line_system_setting"`
	CreateBy            string `form:"createByOrder"  search:"type:order;column:create_by;table:line_system_setting"`
	UpdateBy            string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_system_setting"`
}

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

type LineSystemSettingInsertReq struct {
	Id                  int             `json:"-" comment:"id"` // id
	Time                int64           `json:"time" comment:"导入:挂单时长达到时间后失效"`
	BatchTime           int64           `json:"batchTime" comment:"批量:挂单时长达到时间后失效"`
	ProfitRate          string          `json:"profitRate" comment:"平仓盈利比例"`
	CoverOrderTypeBRate string          `json:"coverOrderTypeBRate" comment:"b账户限价补单的买入百分比"`
	StopLossPremium     decimal.Decimal `json:"stopLossPremium" comment:"限价止损溢价"`
	common.ControlBy
}

func (s *LineSystemSettingInsertReq) Generate(model *models.LineSystemSetting) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Time = s.Time
	model.BatchTime = s.BatchTime
	model.ProfitRate = s.ProfitRate
	model.CoverOrderTypeBRate = s.CoverOrderTypeBRate
	model.StopLossPremium = s.StopLossPremium
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineSystemSettingUpdateReq struct {
	Id                        int             `uri:"id" comment:"id"` // id
	Time                      int64           `json:"time" comment:"导入:挂单时长达到时间后失效"`
	BatchTime                 int64           `json:"batchTime" comment:"批量:挂单时长达到时间后失效"`
	ProfitRate                string          `json:"profitRate" comment:"平仓盈利比例"`
	CoverOrderTypeBRate       string          `json:"coverOrderTypeBRate" comment:"b账户限价补单的买入百分比"`
	StopLossPremium           decimal.Decimal `json:"stopLossPremium" comment:"限价止损溢价"`
	AddPositionPremium        decimal.Decimal `json:"addPositionPremium" comment:"限价加仓溢价"`
	ReducePremium             decimal.Decimal `json:"reducePremium" comment:"限价减仓溢价"`
	ReduceEarlyTriggerPercent decimal.Decimal `json:"reduceEarlyTriggerPercent" comment:"减仓提前触发百分比"`
	common.ControlBy
}

func (s *LineSystemSettingUpdateReq) Generate(model *models.LineSystemSetting) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Time = s.Time
	model.BatchTime = s.BatchTime
	model.ProfitRate = s.ProfitRate
	model.CoverOrderTypeBRate = s.CoverOrderTypeBRate
	model.StopLossPremium = s.StopLossPremium
	model.AddPositionPremium = s.AddPositionPremium
	model.ReducePremium = s.ReducePremium
	model.ReduceEarlyTriggerPercent = s.ReduceEarlyTriggerPercent
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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