optimize table index
This commit is contained in:
+5
-1
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/mayswind/lab/pkg/core"
|
||||
"github.com/mayswind/lab/pkg/errs"
|
||||
"github.com/mayswind/lab/pkg/log"
|
||||
@@ -30,7 +32,7 @@ func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error)
|
||||
return nil, errs.ErrOperationFailed
|
||||
}
|
||||
|
||||
tokenResps := make([]*models.TokenInfoResponse, len(tokens))
|
||||
tokenResps := make(models.TokenInfoResponseSlice, len(tokens))
|
||||
claims := c.GetTokenClaims()
|
||||
|
||||
for i := 0; i < len(tokens); i++ {
|
||||
@@ -50,6 +52,8 @@ func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error)
|
||||
tokenResps[i] = tokenResp
|
||||
}
|
||||
|
||||
sort.Sort(tokenResps)
|
||||
|
||||
return tokenResps, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/mayswind/lab/pkg/core"
|
||||
"github.com/mayswind/lab/pkg/errs"
|
||||
"github.com/mayswind/lab/pkg/log"
|
||||
@@ -27,12 +29,14 @@ func (a *TransactionTagsApi) TagListHandler(c *core.Context) (interface{}, *errs
|
||||
return nil, errs.ErrOperationFailed
|
||||
}
|
||||
|
||||
tagResps := make([]*models.TransactionTagInfoResponse, len(tags))
|
||||
tagResps := make(models.TransactionTagInfoResponseSlice, len(tags))
|
||||
|
||||
for i := 0; i < len(tags); i++ {
|
||||
tagResps[i] = tags[i].ToTransactionTagInfoResponse()
|
||||
}
|
||||
|
||||
sort.Sort(tagResps)
|
||||
|
||||
return tagResps, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user