package dto

import (
	"time"

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

	"github.com/shopspring/decimal"
)

type LineUserSettingGetPageReq struct {
	dto.Pagination `search:"-"`
	LineUserSettingOrder
}

type LineUserSettingOrder struct {
	Id                    string `form:"idOrder"  search:"type:order;column:id;table:line_user_setting"`
	MinOrderAmount        string `form:"minOrderAmountOrder"  search:"type:order;column:min_order_amount;table:line_user_setting"`
	SpotUsdtFreeAmount    string `form:"spotUsdtFreeAmountOrder"  search:"type:order;column:spot_usdt_free_amount;table:line_user_setting"`
	FutureUsdtTotalAmount string `form:"futureUsdtTotalAmountOrder"  search:"type:order;column:future_usdt_total_amount;table:line_user_setting"`
	AssetUpdateTime       string `form:"assetUpdateTimeOrder"  search:"type:order;column:asset_update_time;table:line_user_setting"`
	CreatedAt             string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_user_setting"`
	UpdatedAt             string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_user_setting"`
	DeletedAt             string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_user_setting"`
	CreateBy              string `form:"createByOrder"  search:"type:order;column:create_by;table:line_user_setting"`
	UpdateBy              string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_user_setting"`
}

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

type LineUserSettingInsertReq struct {
	Id                   int             `json:"-" comment:"主键"` // 主键
	MinOrderAmount       decimal.Decimal `json:"minOrderAmount" comment:"单笔最小金额"`
	SpotUsdtFreeAmount   decimal.Decimal `json:"spotUsdtFreeAmount" comment:"现货USDT可用余额"`
	FutureUsdtFreeAmount decimal.Decimal `json:"futureUsdtFreeAmount" comment:"合约USDT可用余额"`
	AssetUpdateTime      time.Time       `json:"assetUpdateTime" comment:"资产更新时间"`
	common.ControlBy
}

func (s *LineUserSettingInsertReq) Generate(model *models.LineUserSetting) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.MinOrderAmount = s.MinOrderAmount
	model.SpotUsdtFreeAmount = s.SpotUsdtFreeAmount
	model.FutureUsdtFreeAmount = s.FutureUsdtFreeAmount
	model.AssetUpdateTime = &s.AssetUpdateTime
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineUserSettingUpdateReq struct {
	Id                   int             `uri:"id" comment:"主键"` // 主键
	MinOrderAmount       decimal.Decimal `json:"minOrderAmount" comment:"单笔最小金额"`
	SpotUsdtFreeAmount   decimal.Decimal `json:"spotUsdtFreeAmount" comment:"现货USDT可用余额"`
	FutureUsdtFreeAmount decimal.Decimal `json:"futureUsdtFreeAmount" comment:"合约USDT可用余额"`
	AssetUpdateTime      time.Time       `json:"assetUpdateTime" comment:"资产更新时间"`
	common.ControlBy
}

func (s *LineUserSettingUpdateReq) Generate(model *models.LineUserSetting) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.MinOrderAmount = s.MinOrderAmount
	model.SpotUsdtFreeAmount = s.SpotUsdtFreeAmount
	model.FutureUsdtFreeAmount = s.FutureUsdtFreeAmount
	model.AssetUpdateTime = &s.AssetUpdateTime
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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