package gd_management

//参数名，参数含义，类型，示例，必选与否

type ManagementBaseApiParam struct {
	Required bool                     `json:"required" description:"是否必选"`
	Name     string                   `json:"name" description:"参数名字"`
	Mean     string                   `json:"mean" description:"参数含义"`
	Type     string                   `json:"type" description:"参数类型，整形、字符串等"`
	Example  string                   `json:"example" description:"参数示例"`
	Selected bool                     `json:"selected" description:"是否选择"`
	In       string                   `json:"in" description:"参数转换"`
	Child    []ManagementBaseApiParam `json:"child"`
	Value    string                   `json:"value"`
}

type ManagementBaseApiInfo struct {
	Type                  int                      `json:"type" description:"参数类型0：数据api，1:h5 api， 2：辅助api"`
	Name                  string                   `json:"name" description:"基础api名"`
	Method                string                   `json:"method" description:"方法，GET POST等"`
	Router                string                   `json:"router" description:"路由"`
	RequestParam          []ManagementBaseApiParam `json:"request_param" description:"请求参数"`
	ResponseParam         []ManagementBaseApiParam `json:"response_param" description:"响应参数"`
	ErrorCode             []int                    `json:"error_code" description:"错误码数组"`
	ThresholdTimeout      int                      `json:"threshold_timeout"`
	ThresholdFailRate     float64                  `json:"threshold_fail_rate"`
	ThresholdNorecordRate float64                  `json:"threshold_norecord_rage"`
	Enable                bool                     `json:"enable"`
	Comment               string                   `json:"comment"`
}

type TGdApi struct {
	Id            int64  `json:"id"`
	ApiType       int    `json:"api_type"`
	Name          string `json:"name"`
	Method        string `json:"method" description:"方法，GET POST等"`
	Router        string `json:"router" description:"路由"`
	RequestParam  string `json:"request_param" description:"请求参数"`
	ResponseParam string `json:"response_param" description:"响应参数"`
	//ProviderApiIds string `json:"provider_api_ids" description:"三方api列表 "`
	Enable       bool   `json:"enable"`
	ErrorCodeIds string `json:"error_code_ids"`
	CreateTime   string `json:"create_time"`
	UpdateTime   string `json:"update_time"`
}

type ManagementAddBaseApiReq struct {
	BaseApiInfo ManagementBaseApiInfo `json:"base_api_info" description:""`
}
type ManagementAddBaseApiReply struct {
	ApiId int64 `json:"api_id" description:""`
}

type ManagementDelBaseApiReq struct {
	ApiId int64 `json:"api_id" description:""`
}

type ManagementDelBaseApiReply struct {
}

type ManagementUpdateBaseApiReq struct {
	ApiId       int64                 `json:"api_id" description:""`
	BaseApiInfo ManagementBaseApiInfo `json:"base_api_info" description:""`
}

type ManagementUpdateBaseApiReply struct {
	ApiId int64 `json:"api_id" description:""`
}

type ManagementBaseApiListItem struct {
	ApiId                 int64   `json:"api_id" description:""`
	Enable                bool    `json:"enable"`
	IsShow                bool    `json:"is_show"`
	OperationTime         string  `json:"operation_time" description:"操作时间"`
	Name                  string  `json:"api_name" description:""`
	Type                  string  `json:"api_type" description:""`
	Router                string  `json:"router"`
	Method                string  `json:"method"`
	RequestParam          string  `json:"request_param"`
	ThresholdTimeout      int     `json:"threshold_timeout"`
	ThresholdFailRate     float64 `json:"threshold_fail_rate"`
	ThresholdNorecordRate float64 `json:"threshold_norecord_rate"`
	WarningEnable         bool    `json:"warning_enable"`
	RateLimit             int     `json:"rate_limit" description:"并发限制"`
}

type ManagementGetBaseApiListReq struct {
	ApiType    int    `json:"api_type"`
	PageNumber int    `json:"page_number" description:""`
	Search     string `json:"search"`
	IsAll      bool   `json:"is_all"`
	MerchantId int64  `json:"merchant_id" require:"false" in:"query"`
}
type ManagementGetBaseApiListReply struct {
	Total                                    int                         `json:"total" description:""`
	PageNumber                               int                         `json:"page_number" description:""`
	PageSize                                 int                         `json:"page_size" description:""`
	BaseApiItemLManagementBaseApiListItemist []ManagementBaseApiListItem `json:"base_api_item_list"`
}

type ManagementGetBaseApiInfoReq struct {
	ApiId int64 `json:"api_id" description:""`
}

type ManagementGetBaseApiInfoReply struct {
	BaseApiInfo ManagementBaseApiInfo `json:"base_api_info" description:""`
}

//api停启用
type ManagementSetBaseApiStateReq struct {
	ApiId  int64 `json:"api_id" description:""`
	Enable bool  `json:"enable" description:""`
}

type ManagementSetBaseApiStateReply struct {
}

//api与数据源

type ProviderGroupApiIdItem struct {
	GroupNo           int     `json:"group_no"`
	GroupName         string  `json:"group_name"`
	ProviderApiIdList []int64 `json:"provider_api_id_list"`
}

type ManagementAddBaseApiProviderReq struct {
	ApiId int64 `json:"api_id"`
	//ProviderApiIdList []int64 `json:"provider_api_id_list"`
	ProviderGroupList []ProviderGroupApiIdItem `json:"provider_group_list"`
}

type ManagementAddBaseApiProviderReply struct {
}

/*
type ManagementDelBaseApiProviderReq struct {
	ApiId         int64 `json:"api_id" description:"基础api id"`
	GroupNumber   int   `json:"group_number" description:"组号"`
	ProviderApiId int64 `json:"provider_api_id" description:"数据源api id"`
}

type ManagementDelBaseApiProviderReply struct {
}
*/

type ManagementGetBaseApiProviderListReq struct {
	ApiId int64 `json:"api_id" description:"基础api id"`
	//PageNumber int64 `json:"page_number" description:"当前页"`
}

type BaseApiProviderItem struct {
	ProviderApiId      int64  `json:"provider_api_id"`
	Priority           int    `json:"priority" description:"优先级"`
	ThirdpartApiName   string `json:"thirdpart_api_name" description:"数据源接口名称"`
	ThirdpartApiRouter string `json:"thirdpart_api_router" description:"数据源接口路径"`
	PlatformName       string `json:"platform_name" description:"数据源平台名称"`
	Enable             bool   `json:"enable"`
}

/*type BaseApiProviderGroupItem struct {
	GroupNumber int                   `json:"group_number" description:"组号"`
	List        []BaseApiProviderItem `json:"list" description:""`
}
*/

type BaseApiProviderGroupItem struct {
	GroupNo         int                   `json:"group_no"`
	GroupName       string                `json:"group_name"`
	ProviderApiList []BaseApiProviderItem `json:"provider_api_list" description:""`
}

type ManagementGetBaseApiProviderListReply struct {
	//Total      int                    `json:"" description:""`
	//PageSize   int                    `json:"" description:""`
	//PageNumber int                    `json:"" description:""`
	//List []BaseApiProviderGroupItem `json:"list" description:""`
	//ProviderApiList []BaseApiProviderItem `json:"provider_api_list" description:""`
	ProviderGroupList []BaseApiProviderGroupItem `json:"provider_group_list"`
}

/*type ManagementSetBaseApiProviderPriorityReq struct {
	GroupNumber    int    `json:"group_number" description:"组号"`
	ApiId          int64  `json:"api_id" description:"基础api id"`
	ProviderApiIds string `json:"provider_api_ids" description:"逗号分隔的拍好序的id"`
}

type ManagementSetBaseApiProviderPriorityReply struct {
}
*/

type ManagementSetBaseApiThresholdReq struct {
	ApiId                 int64   `json:"api_id" in:"query" require:"true"`
	ThresholdTimeout      int     `json:"threshold_timeout" in:"query" require:"false"`
	ThresholdFailRate     float64 `json:"threshold_fail_rate" in:"query" require:"false"`
	ThresholdNorecordRate float64 `json:"threshold_norecord_rate" in:"query" require:"false"`
	WarningEnable         bool    `json:"warning_enable" in:"query"`
	RateLimit             int     `json:"rate_limit" description:"并发限制"`
}

type ManagementSetBaseApiThresholdReply struct {
}

type ManagementSetBaseApiShowInfoReq struct {
	ApiId  int64 `json:"api_id" description:"api id" in:"path"`
	IsShow bool  `json:"is_show"`
}

type ManagementSetBaseApiShowInfoReply struct {
}

type ManagementGetFilterRuleReq struct {
}

type FilterRule struct {
	RuleId         int64  `orm:"id" json:"rule_id"`
	RuleName       string `orm:"name" json:"rule_name"`
	RuleDesc       string `orm:"desc" json:"rule_desc"`
	EffectiveParam string `orm:"effective_param" json:"effective_param"`
}

type ManagementGetFilterRuleReply struct {
	Rules []FilterRule `json:"rules"`
}

type ManagementGetBaseApiByRouterReq struct {
	Method     string `json:"method" description:"方法，GET POST等"`
	Router     string `json:"router" description:"路由"`
	AppKey     string `json:"app_key"`
	ApiId      int    `json:"api_id"`
	MerchantId int    `json:"merchant_id"`
}

type ManagementGetBaseApiByRouterReply struct {
	Data map[string]string `json:"data"`
}
