package dto

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

type LineApiUserGetPageReq struct {
	dto.Pagination `search:"-"`
	ExchangeType   string `form:"exchangeType" search:"-"`
	OpenStatus     *int   `form:"openStatus" search:"-" comment:"开启状态 0-关闭 1-开启"`
	LineApiUserOrder
}

type LineApiUserOrder struct {
	Id          string `form:"idOrder"  search:"type:order;column:id;table:line_api_user"`
	UserId      string `form:"userIdOrder"  search:"type:order;column:user_id;table:line_api_user"`
	JysId       string `form:"jysIdOrder"  search:"type:order;column:jys_id;table:line_api_user"`
	ApiName     string `form:"apiNameOrder"  search:"type:order;column:api_name;table:line_api_user"`
	ApiKey      string `form:"apiKeyOrder"  search:"type:order;column:api_key;table:line_api_user"`
	ApiSecret   string `form:"apiSecretOrder"  search:"type:order;column:api_secret;table:line_api_user"`
	IpAddress   string `form:"ipAddressOrder"  search:"type:order;column:ip_address;table:line_api_user"`
	UserPass    string `form:"userPassOrder"  search:"type:order;column:user_pass;table:line_api_user"`
	AdminId     string `form:"adminIdOrder"  search:"type:order;column:admin_id;table:line_api_user"`
	Affiliation string `form:"affiliationOrder"  search:"type:order;column:affiliation;table:line_api_user"`
	AdminShow   string `form:"adminShowOrder"  search:"type:order;column:admin_show;table:line_api_user"`
	Site        string `form:"siteOrder"  search:"type:order;column:site;table:line_api_user"`
	Subordinate string `form:"subordinateOrder"  search:"type:order;column:subordinate;table:line_api_user"`
	GroupId     string `form:"groupIdOrder"  search:"type:order;column:group_id;table:line_api_user"`
	OpenStatus  string `form:"openStatusOrder"  search:"type:order;column:open_status;table:line_api_user"`
	CreatedAt   string `form:"createdAtOrder"  search:"type:order;column:created_at;table:line_api_user"`
	UpdatedAt   string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:line_api_user"`
	DeletedAt   string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:line_api_user"`
	CreateBy    string `form:"createByOrder"  search:"type:order;column:create_by;table:line_api_user"`
	UpdateBy    string `form:"updateByOrder"  search:"type:order;column:update_by;table:line_api_user"`
}

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

type LineApiUserInsertReq struct {
	Id           int    `json:"-" comment:"id"` // id
	ExchangeType string `json:"exchangeType" comment:"交易所code"`
	UserId       int64  `json:"userId" comment:"用户id"`
	JysId        int64  `json:"jysId" comment:"关联交易所账号id"`
	ApiName      string `json:"apiName" comment:"api用户名"`
	ApiKey       string `json:"apiKey" comment:"apiKey"`
	ApiSecret    string `json:"apiSecret" comment:"apiSecret"`
	IpAddress    string `json:"ipAddress" comment:"代理地址"`
	UserPass     string `json:"userPass" comment:"代码账号密码"`
	AdminId      int64  `json:"adminId" comment:"管理员id"`
	Affiliation  int64  `json:"affiliation" comment:"归属:1=现货,2=合约,3=现货合约"`
	AdminShow    int64  `json:"adminShow" comment:"是否超管可见:1=是,0=否"`
	Site         string `json:"site" comment:"允许下单的方向:1=多;2=空;3=多空"`
	Subordinate  string `json:"subordinate" comment:"从属关系:0=未绑定关系;1=主账号;2=副帐号"`
	GroupId      int64  `json:"groupId" comment:"所属组id"`
	OpenStatus   int64  `json:"openStatus" comment:"开启状态 0=关闭 1=开启"`
	common.ControlBy
}

func (s *LineApiUserInsertReq) Generate(model *models.LineApiUser) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ExchangeType = s.ExchangeType
	model.UserId = s.UserId
	// model.JysId = s.JysId
	model.ApiName = s.ApiName
	model.ApiKey = s.ApiKey
	model.ApiSecret = s.ApiSecret
	model.IpAddress = s.IpAddress
	model.UserPass = s.UserPass
	// model.AdminId = s.AdminId
	model.Affiliation = s.Affiliation
	model.AdminShow = s.AdminShow
	model.Site = s.Site
	model.Subordinate = s.Subordinate
	model.GroupId = s.GroupId
	model.OpenStatus = s.OpenStatus
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type LineApiUserUpdateReq struct {
	Id           int    `uri:"id" comment:"id"` // id
	ExchangeType string `json:"exchangeType" comment:"交易所code"`
	UserId       int64  `json:"userId" comment:"用户id"`
	JysId        int64  `json:"jysId" comment:"关联交易所账号id"`
	ApiName      string `json:"apiName" comment:"api用户名"`
	ApiKey       string `json:"apiKey" comment:"apiKey"`
	ApiSecret    string `json:"apiSecret" comment:"apiSecret"`
	IpAddress    string `json:"ipAddress" comment:"代理地址"`
	UserPass     string `json:"userPass" comment:"代码账号密码"`
	AdminId      int64  `json:"adminId" comment:"管理员id"`
	Affiliation  int64  `json:"affiliation" comment:"归属:1=现货,2=合约,3=现货合约"`
	AdminShow    int64  `json:"adminShow" comment:"是否超管可见:1=是,0=否"`
	Site         string `json:"site" comment:"允许下单的方向:1=多;2=空;3=多空"`
	Subordinate  string `json:"subordinate" comment:"从属关系:0=未绑定关系;1=主账号;2=副帐号"`
	GroupId      int64  `json:"groupId" comment:"所属组id"`
	OpenStatus   int64  `json:"openStatus" comment:"开启状态 0=关闭 1=开启"`
	common.ControlBy
}

func (s *LineApiUserUpdateReq) Generate(model *models.LineApiUser) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.ExchangeType = s.ExchangeType
	model.UserId = s.UserId
	// model.JysId = s.JysId
	model.ApiName = s.ApiName
	model.ApiKey = s.ApiKey
	model.ApiSecret = s.ApiSecret
	model.IpAddress = s.IpAddress
	model.UserPass = s.UserPass
	// model.AdminId = s.AdminId
	model.Affiliation = s.Affiliation
	model.AdminShow = s.AdminShow
	model.Site = s.Site
	model.Subordinate = s.Subordinate
	model.GroupId = s.GroupId
	model.OpenStatus = s.OpenStatus
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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

type LineApiUserBindSubordinateReq struct {
	ExchangeType string `json:"exchangeType"`
	UserIdStr    string `json:"user_id_str"`
	GroupName    string `json:"group_name"`
}

type GetMainUserReq struct {
	ExchangeType string `json:"exchangeType"`
}
