Commit 60f59f70 by 岳巧源

modify return content

parent e80a94c3
...@@ -5,7 +5,7 @@ import "github.com/gogf/gf/v2/frame/g" ...@@ -5,7 +5,7 @@ import "github.com/gogf/gf/v2/frame/g"
type ApiListReq struct { type ApiListReq struct {
g.Meta `path:"/api/list" method:"get" summary:"查询api列表"` g.Meta `path:"/api/list" method:"get" summary:"查询api列表"`
Page int `json:"page" d:"1" dc:"请输入第几页,不传默认第1页"` Page int `json:"page" d:"1" dc:"请输入第几页,不传默认第1页"`
Limit int `json:"limit" d:"50" dc:"每页限制个数"` Limit int `json:"limit" d:"30" dc:"每页限制个数"`
Sort bool `json:"sort" d:"false" dc:"按照调用次数从多到少排序"` Sort bool `json:"sort" d:"false" dc:"按照调用次数从多到少排序"`
OffsetTime int64 `json:"offset_time" dc:"offset_time为时间戳"` OffsetTime int64 `json:"offset_time" dc:"offset_time为时间戳"`
} }
......
...@@ -16,6 +16,11 @@ import ( ...@@ -16,6 +16,11 @@ import (
"time" "time"
) )
type ApiListData struct {
Total int `json:"total"`
InterfaceNameInfoList []InterfaceNameInfo `json:"interface_name_info_list"`
}
type InterfaceNameInfo struct { type InterfaceNameInfo struct {
InterfaceName string `json:"interface_name"` InterfaceName string `json:"interface_name"`
Version string `json:"version"` Version string `json:"version"`
...@@ -40,6 +45,7 @@ func (s *sApiList) GetApiList(ctx context.Context, req *v1.ApiListReq) (interfac ...@@ -40,6 +45,7 @@ func (s *sApiList) GetApiList(ctx context.Context, req *v1.ApiListReq) (interfac
for i := 0; i < len(interfaceNameInfoList); i++ { for i := 0; i < len(interfaceNameInfoList); i++ {
interfaceNameInfoList[i].DayCallNum = GetNumsByInterfaceName(ctx, interfaceNameInfoList[i].URI) interfaceNameInfoList[i].DayCallNum = GetNumsByInterfaceName(ctx, interfaceNameInfoList[i].URI)
} }
total := len(interfaceNameInfoList)
var sortByCallNums bool = req.Sort var sortByCallNums bool = req.Sort
if sortByCallNums { if sortByCallNums {
sort.Slice(interfaceNameInfoList, func(i, j int) bool { sort.Slice(interfaceNameInfoList, func(i, j int) bool {
...@@ -60,7 +66,10 @@ func (s *sApiList) GetApiList(ctx context.Context, req *v1.ApiListReq) (interfac ...@@ -60,7 +66,10 @@ func (s *sApiList) GetApiList(ctx context.Context, req *v1.ApiListReq) (interfac
interfaceNameInfoList = interfaceNameInfoList[start:end] interfaceNameInfoList = interfaceNameInfoList[start:end]
} }
} }
return interfaceNameInfoList, response.CodeSuccess apiListData := ApiListData{}
apiListData.Total = total
apiListData.InterfaceNameInfoList = interfaceNameInfoList
return apiListData, response.CodeSuccess
} }
// 查询某api调用总次数 // 查询某api调用总次数
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment