-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.go
32 lines (25 loc) · 815 Bytes
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package user
import (
"github.com/gin-gonic/gin"
"github.com/skeleton1231/gotal/internal/apiserver/store/model"
"github.com/skeleton1231/gotal/internal/pkg/code"
"github.com/skeleton1231/gotal/internal/pkg/errors"
"github.com/skeleton1231/gotal/internal/pkg/response"
"github.com/skeleton1231/gotal/pkg/log"
)
// List list the users in the storage.
// Only administrator can call this function.
func (u *UserController) List(c *gin.Context) {
log.Record(c).Info("list user function called.")
var r model.ListOptions
if err := c.ShouldBindQuery(&r); err != nil {
response.WriteResponse(c, errors.WithCode(code.ErrBind, err.Error()), nil)
return
}
users, err := u.srv.Users().List(c, r)
if err != nil {
response.WriteResponse(c, err, nil)
return
}
response.WriteResponse(c, nil, users)
}