First merge from develop to main (WIP) #7
@@ -9,15 +9,30 @@ import (
|
||||
)
|
||||
|
||||
func (self *UserHandler) List(c *gin.Context) {
|
||||
limit, limitStatus := c.GetQuery("limit")
|
||||
offset, offsetStatus := c.GetQuery("offset")
|
||||
type ListQuery struct {
|
||||
Limit *string `form:"limit"`
|
||||
Offset *string `form:"offset"`
|
||||
}
|
||||
|
||||
var query ListQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceList).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
Throw(c).
|
||||
String()
|
||||
|
||||
utils.HttpResponse(c, 400, exception)
|
||||
return
|
||||
}
|
||||
|
||||
userListPayload := &service.UserListPayload{
|
||||
Context: c,
|
||||
Limit: &limit,
|
||||
LimitStatus: &limitStatus,
|
||||
Offset: &offset,
|
||||
OffsetStatus: &offsetStatus,
|
||||
Context: c,
|
||||
Limit: query.Limit,
|
||||
Offset: query.Offset,
|
||||
}
|
||||
|
||||
result := self.svc.ListUsers(userListPayload)
|
||||
|
||||
@@ -279,11 +279,9 @@ func (self *UserServiceImpl) UpdateUserInfo(payload *UserInfoPayload) (result *U
|
||||
}
|
||||
|
||||
type UserListPayload struct {
|
||||
Context context.Context
|
||||
Limit *string
|
||||
LimitStatus *bool
|
||||
Offset *string
|
||||
OffsetStatus *bool
|
||||
Context context.Context
|
||||
Limit *string
|
||||
Offset *string
|
||||
}
|
||||
|
||||
type UserListResult struct {
|
||||
@@ -294,12 +292,12 @@ type UserListResult struct {
|
||||
// ListUsers
|
||||
func (self *UserServiceImpl) ListUsers(payload *UserListPayload) (result *UserListResult) {
|
||||
var limit string
|
||||
if !*payload.LimitStatus || *payload.Limit == "" {
|
||||
if payload.Limit == nil || *payload.Limit == "" {
|
||||
limit = "0"
|
||||
}
|
||||
|
||||
var offset string
|
||||
if !*payload.OffsetStatus || *payload.Offset == "" {
|
||||
if payload.Offset == nil || *payload.Offset == "" {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.ServiceUser).
|
||||
|
||||
Reference in New Issue
Block a user