// Copyright 2019 getensh.com. All rights reserved.
// Use of this source code is governed by getensh.com.
package gd_management

type ManagementTryBaseApiReq struct {
	AppKey          string                   `json:"app_key"`
	AppSecret       string                   `json:"app_secret"`
	IsCrypto        bool                     `json:"is_crypto"`
	Method          string                   `json:"method"`
	Router          string                   `json:"router"`
	AppPassword     string                   `json:"app_password"`
	MerchantAccount bool                     `json:"merchant_account"`
	Params          []ManagementBaseApiParam `json:"request_param"`
	EncryptoType    int `json:"encrypto_type"`
}

type ManagementTryBaseApiReply struct {
	Data    string `json:"data"`
	OrderNo string `json:"order_no,omitempty"`
}

type ManagementCreateTryApiTaskReq struct {
	FileName     string `json:"file_name"`
	ApiName      string `json:"api_name"`
	Router       string `json:"router"`
	Method       string `json:"method"`
	DownloadFile string `json:"download_file"`
	OriginFile   string `json:"origin_file"`
	RequestInfo  string `json:"request_info"`
	AppKey       string `json:"app_key"`
	IsMerchant   bool   `json:"is_merchant"`
	TaskName     string `json:"task_name"`
}

type ManagementCreateTryApiTaskReply struct {
	Id int64 `json:"id"`
}

type ManagementGetTryApiTaskListReq struct {
	IsAll      bool   `json:"is_all"`
	PageNumber int    `json:"page_number"`
	PageSize   int    `json:"page_size"`
	ApiName    string `json:"api_name" in:"query" require:"false"`
	Type       int    `json:"type"`
}

type ManagementGetTryApiTaskListReply struct {
	Total      int          `json:"total"`
	PageNumber int          `json:"page_number"`
	PageSize   int          `json:"page_size"`
	Tasks      []TryApiItem `json:"tasks"`
}

type ManagementDeleteTryApiTaskReq struct {
	TaskId int64 `json:"task_id"`
}

type ManagementDeleteTryBaseApiTaskReply struct {
	DownloadFile string `json:"download_file"`
	OriginFile   string `json:"origin_file"`
	TaskType     int    `json:"task_type"`
}

type ManagementBatchTryApiReq struct {
	TaskId          int64    `json:"task_id"`
	Method          string   `json:"method"`
	Router          string   `json:"router"`
	Params          []string `json:"params"`
	AppKey          string   `json:"app_key"`
	AppSecret       string   `json:"app_secret"`
	IsCrypto        bool     `json:"is_crypto"`
	MerchantAccount bool     `json:"merchant_account"`
	MultiMode       bool     `json:"multi_mode"`
	AppPassword     string   `json:"app_password"`
	EncryptoType    int `json:"encrypto_type"`
}

type BatchTryApiParams struct {
	Requset        string `json:"request"`
	Response       string `json:"response"`
	OriginResponse string `json:"origin_response"`
}

type ManagementBatchTryApiReply struct {
	Params []BatchTryApiParams `json:"params"`
	Stop   bool                `json:"stop"`
}

type ManagementUpdateTryApiTaskReq struct {
	Status       int    `json:"status"`
	DownloadFile string `json:"download_file"`
	TaskId       int64  `json:"task_id"`
	ErrMsg       string `json:"err_msg"`
}

type ManagementUpdateTryApiTaskReply struct {
}

type TryApiTaskAddReq struct {
	Type      int    `json:"type"`
	FileName  string `json:"file_name"`
	ApiName   string `json:"api_name"`
	ApiHost   string `json:"api_host"`
	ApiRouter string `json:"api_router"`
	Status    int    `json:"status"`
}

type TryApiTaskAddReply struct {
	Id int64 `json:"id"`
}

type TryApiTaskUpdateReq struct {
	Id           int64  `json:"id"`
	Status       int    `json:"status"`
	DownloadFile string `json:"download_file"`
}

type TryApiTaskUpdateReply struct {
}

type GetTryApiTaskListReq struct {
	Type       int   `json:"type"`
	PageSize   int64 `json:"page_size"`
	PageNumber int64 `json:"page_number"`
}

type GetTryApiTaskList struct {
	Id           int64  `json:"id"`
	FileName     string `json:"file_name" description:"上传的文件名"`
	ApiName      string `json:"api_name" description:"接口名"`
	ApiHost      string `json:"api_host" description:"接口地址"`
	ApiRouter    string `json:"api_router" description:"接口路由"`
	Status       int    `json:"status" description:"状态：-1失败，0进行中， 1成功"`
	DownloadFile string `json:"download_file" description:"现在文件地址"`
	CreatedAt    string `json:"created_at" description:"任务发起时间"`
}

type TryApiItem struct {
	Id           int64  `json:"id"`
	FileName     string `json:"file_name"`
	ApiName      string `json:"api_name"`
	ApiRouter    string `json:"api_router"`
	Status       string `json:"status"`
	StatusCode   int    `json:"status_code"`
	DownloadFile string `json:"download_file"`
	CreatedAt    string `json:"created_at"`
	TaskName     string `json:"task_name"`
	Merchant     string `json:"merchant"`
}

type GetTryApiTaskListReply struct {
	PageSize   int64               `json:"page_size"`
	PageNumber int64               `json:"page_number"`
	Total      int64               `json:"total"`
	List       []GetTryApiTaskList `json:"list"`
}

type TryApi struct {
	Id           int64  `orm:"auto,column(id)" json:"id"`
	Type         int    `orm:"column(type)" json:"type"`
	FileName     string `orm:"column(file_name)" json:"file_name"`
	ApiName      string `orm:"column(api_name)" json:"api_name"`
	ApiHost      string `orm:"column(api_host)" json:"api_host"`
	ApiRouter    string `orm:"column(api_router)" json:"api_router"`
	Status       int    `orm:"column(status)" json:"status_code"`
	DownloadFile string `orm:"column(download_file)" json:"download_file"`
	OriginFile   string `json:"origin_file"`
	RequestInfo  string `json:"request_info"`
	CreatedAt    string `orm:"column(created_at)" json:"created_at"`
	UpdatedAt    string `orm:"column(updated_at)" json:"updated_at"`
}

type ManagementGetApiTaskReq struct {
	TaskId int64 `json:"task_id"`
}

type ManagementGetApiTaskReply struct {
	Data TryApi `json:"data"`
}
