package dto

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

type LineApiGroupGetPageReq struct {
	dto.Pagination `search:"-"`
	ExchangeType   string `form:"exchangeType" search:"-"`
	GroupName      string `form:"groupName"  search:"type:exact;column:group_name;table:line_api_group" comment:"用户组名称"`
	LineApiGroupOrder
}

type LineApiGroupOrder struct {
	Id        string `form:"idOrder"  search:"type:order;column:id;table:line_api_group"`
	GroupName string `form:"groupNameOrder"  search:"type:order;column:group_name;table:line_api_group"`
	ApiUserId string `form:"apiUserIdOrder"  search:"type:order;column:api_user_id;table:line_api_group"`
	CreatedAt string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_api_group"`
	UpdatedAt string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_api_group"`
	DeletedAt string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_api_group"`
	CreateBy  string `form:"createByOrder"  search:"type:order;column:create_by;table:line_api_group"`
	UpdateBy  string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_api_group"`
}

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

type LineApiGroupInsertReq struct {
	Id           int    `json:"-" comment:""` //
	ExchangeType string `json:"exchangeType" comment:"交易所编码"`
	GroupName    string `json:"groupName" comment:"用户组名称"`
	ApiUserId    string `json:"apiUserId" comment:"绑定的api账户id"`
	common.ControlBy
}

func (req *LineApiGroupInsertReq) Valid() error {
	if req.ExchangeType == "" {
		return errors.New("交易所不能为空")
	}
	return nil
}

func (s *LineApiGroupInsertReq) Generate(model *models.LineApiGroup) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ExchangeType = s.ExchangeType
	model.GroupName = s.GroupName
	model.ApiUserId = s.ApiUserId
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineApiGroupUpdateReq struct {
	Id           int    `uri:"id" comment:""` //
	ExchangeType string `json:"exchangeType" comment:"交易所编码"`
	GroupName    string `json:"groupName" comment:"用户组名称"`
	ApiUserId    string `json:"apiUserId" comment:"绑定的api账户id"`
	common.ControlBy
}

func (s *LineApiGroupUpdateReq) Generate(model *models.LineApiGroup) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ExchangeType = s.ExchangeType
	model.GroupName = s.GroupName
	model.ApiUserId = s.ApiUserId
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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