UPDATE: Change cursor to offset, bc FE dk implement
All checks were successful
Build and Release / release (push) Successful in 1m3s
All checks were successful
Build and Release / release (push) Successful in 1m3s
This commit is contained in:
@@ -11,6 +11,11 @@ type PreSignedCompleteDto struct {
|
||||
}
|
||||
|
||||
type SearchMediaDto struct {
|
||||
CursorPaginationDto
|
||||
Search string `json:"search" query:"search" validate:"omitempty,min=2,max=200"`
|
||||
PaginationDto
|
||||
Sort string `json:"sort" query:"sort" validate:"omitempty,oneof=id created_at updated_at size original_name storage_key mime_type"`
|
||||
Search string `json:"search" query:"search" validate:"omitempty,min=2,max=200"`
|
||||
UserIDs []string `json:"user_ids" query:"user_ids" validate:"omitempty,dive,uuid"`
|
||||
MimeType string `json:"mime_type" query:"mime_type" validate:"omitempty,max=100"`
|
||||
MinSize *int64 `json:"min_size" query:"min_size" validate:"omitempty,min=0"`
|
||||
MaxSize *int64 `json:"max_size" query:"max_size" validate:"omitempty,min=0,gtefield=MinSize"`
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package request
|
||||
|
||||
import "time"
|
||||
|
||||
type UpdateProfileDto struct {
|
||||
DisplayName string `json:"display_name" validate:"omitempty,min=2,max=50"`
|
||||
FullName string `json:"full_name" validate:"omitempty,min=2,max=100"`
|
||||
@@ -21,21 +23,18 @@ type ChangeRoleDto struct {
|
||||
Roles []string `json:"role_ids" validate:"required,min=1,dive,required,uuid"`
|
||||
}
|
||||
|
||||
type GetAllUserDto struct {
|
||||
CursorPaginationDto
|
||||
IsDeleted *bool `json:"is_deleted" query:"is_deleted" validate:"omitempty"`
|
||||
RoleIDs []string `json:"role_ids" query:"role_ids" validate:"omitempty,dive,uuid"`
|
||||
}
|
||||
|
||||
type CursorPaginationDto struct {
|
||||
Cursor string `json:"cursor" query:"cursor" validate:"omitempty,uuid"`
|
||||
Limit int `json:"limit" query:"limit" validate:"required,min=1,max=100"`
|
||||
Sort string `json:"sort" query:"sort" validate:"omitempty,oneof=id created_at updated_at"`
|
||||
Order string `json:"order" query:"order" validate:"omitempty,oneof=asc desc"`
|
||||
type PaginationDto struct {
|
||||
Page int `json:"page" query:"page" validate:"omitempty,min=1"`
|
||||
Limit int `json:"limit" query:"limit" validate:"required,min=1,max=100"`
|
||||
Order string `json:"order" query:"order" validate:"omitempty,oneof=asc desc"`
|
||||
}
|
||||
type SearchUserDto struct {
|
||||
CursorPaginationDto
|
||||
Search string `json:"search" query:"search" validate:"omitempty,min=2,max=200"`
|
||||
IsDeleted *bool `json:"is_deleted" query:"is_deleted" validate:"omitempty"`
|
||||
RoleIDs []string `json:"role_ids" query:"role_ids" validate:"omitempty,dive,uuid"`
|
||||
PaginationDto
|
||||
Sort string `json:"sort" query:"sort" validate:"omitempty,oneof=id created_at updated_at email is_deleted auth_provider"`
|
||||
Search string `json:"search" query:"search" validate:"omitempty,min=2,max=200"`
|
||||
IsDeleted *bool `json:"is_deleted" query:"is_deleted" validate:"omitempty"`
|
||||
RoleIDs []string `json:"role_ids" query:"role_ids" validate:"omitempty,dive,uuid"`
|
||||
AuthProvider string `json:"auth_provider" query:"auth_provider" validate:"omitempty"`
|
||||
CreatedFrom *time.Time `json:"created_from" query:"created_from" validate:"omitempty"`
|
||||
CreatedTo *time.Time `json:"created_to" query:"created_to" validate:"omitempty"`
|
||||
}
|
||||
|
||||
@@ -13,18 +13,45 @@ type CommonResponse struct {
|
||||
}
|
||||
|
||||
type JWTClaims struct {
|
||||
UId string `json:"uid"`
|
||||
Roles []constants.Role `json:"roles"`
|
||||
TokenVersion int32 `json:"token_version"`
|
||||
UId string `json:"uid"`
|
||||
Roles []constants.Role `json:"roles"`
|
||||
TokenVersion int32 `json:"token_version"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
type PaginatedResponse struct {
|
||||
Data any `json:"data"`
|
||||
Status bool `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Pagination struct {
|
||||
NextCursor string `json:"next_cursor"`
|
||||
HasMore bool `json:"has_more"`
|
||||
} `json:"pagination"`
|
||||
type PaginationMeta struct {
|
||||
CurrentPage int `json:"current_page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalRecords int64 `json:"total_records"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
type PaginatedResponse struct {
|
||||
Status bool `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
Pagination *PaginationMeta `json:"pagination"`
|
||||
}
|
||||
|
||||
func BuildPaginatedResponse(data any, totalRecords int64, page int, limit int) *PaginatedResponse {
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if limit < 1 {
|
||||
limit = 10
|
||||
}
|
||||
|
||||
totalPages := int((totalRecords + int64(limit) - 1) / int64(limit))
|
||||
|
||||
return &PaginatedResponse{
|
||||
Status: true,
|
||||
Message: "Success",
|
||||
Data: data,
|
||||
Pagination: &PaginationMeta{
|
||||
CurrentPage: page,
|
||||
PageSize: limit,
|
||||
TotalRecords: totalRecords,
|
||||
TotalPages: totalPages,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user