Commit 8851b53e authored by luxq's avatar luxq

add total item return

parent 7ad48fe6
...@@ -31,10 +31,10 @@ func (g baseService) List() ([]string, error) { ...@@ -31,10 +31,10 @@ func (g baseService) List() ([]string, error) {
return res, nil return res, nil
} }
func (g baseService) ListByPage(pageSize int, pageNum int) ([]string, error) { func (g baseService) ListByPage(pageSize int, pageNum int) ([]string, int, error) {
all, err := getAll(g.rdb, g.service) all, err := getAll(g.rdb, g.service)
if err != nil { if err != nil {
return nil, err return nil, 0, err
} }
sort.Sort(ServiceInfoList(all)) sort.Sort(ServiceInfoList(all))
start := pageSize * pageNum start := pageSize * pageNum
...@@ -46,7 +46,7 @@ func (g baseService) ListByPage(pageSize int, pageNum int) ([]string, error) { ...@@ -46,7 +46,7 @@ func (g baseService) ListByPage(pageSize int, pageNum int) ([]string, error) {
for _, v := range all[start:end] { for _, v := range all[start:end] {
res = append(res, string(v.Message())) res = append(res, string(v.Message()))
} }
return res, nil return res, len(all), nil
} }
func (g baseService) ServiceInfo(serviceid string) (string, error) { func (g baseService) ServiceInfo(serviceid string) (string, error) {
......
...@@ -5,7 +5,7 @@ import "encoding/json" ...@@ -5,7 +5,7 @@ import "encoding/json"
type ServiceQuery interface { type ServiceQuery interface {
ModuleName() string ModuleName() string
List() ([]string, error) List() ([]string, error)
ListByPage(pageSize int, pageNum int) ([]string, error) ListByPage(pageSize int, pageNum int) ([]string, int, error)
ServiceInfo(instance string) (string, error) ServiceInfo(instance string) (string, error)
} }
......
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 to comment