Documentation
¶
Overview ¶
Package user demonstrates a go-bricks module with enhanced OpenAPI metadata. This module shows both backward-compatible usage and new features for documentation generation.
Index ¶
- type CreateUserReq
- type DeleteUserReq
- type GetUserReq
- type ListResponse
- type ListUsersReq
- type Module
- func (m *Module) DescribeModule() app.ModuleDescriptor
- func (m *Module) DescribeRoutes() []server.RouteDescriptor
- func (m *Module) Init(deps *app.ModuleDeps) error
- func (m *Module) Name() string
- func (m *Module) RegisterMessaging(_ *messaging.Registry)
- func (m *Module) RegisterRoutes(hr *server.HandlerRegistry, r server.RouteRegistrar)
- func (m *Module) Shutdown() error
- type Response
- type UpdateUserReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateUserReq ¶
type CreateUserReq struct {
Name string `json:"name" validate:"required,min=2,max=100" doc:"User's full name" example:"testUserName"`
Email string `json:"email" validate:"required,email" doc:"User's email address" example:"testEmail"`
Age *int `json:"age,omitempty" validate:"omitempty,min=13,max=120" doc:"User's age (optional)" example:"30"`
Role string `json:"role" validate:"oneof=admin user guest" doc:"User role" example:"user"`
Active bool `json:"active" doc:"Whether the user account is active" example:"true"`
Metadata map[string]string `json:"metadata,omitempty" doc:"Additional user metadata"`
}
CreateUserReq represents a request to create a new user
type DeleteUserReq ¶
type DeleteUserReq struct {
ID int `param:"id" validate:"required,min=1" doc:"User ID to delete" example:"123"`
Force bool `query:"force" doc:"Force deletion even if user has associated data" example:"false"`
}
DeleteUserReq represents a request to delete a user
type GetUserReq ¶
type GetUserReq struct {
ID int `param:"id" validate:"required,min=1" doc:"User ID" example:"123"`
}
GetUserReq represents a request to get a user by ID
type ListResponse ¶
type ListResponse struct {
Users []Response `json:"users" doc:"List of users for the current page"`
Total int `json:"total" doc:"Total number of users matching the filter" example:"150"`
Page int `json:"page" doc:"Current page number" example:"1"`
Pages int `json:"pages" doc:"Total number of pages" example:"8"`
}
ListResponse represents a paginated list of users
type ListUsersReq ¶
type ListUsersReq struct {
Page int `query:"page" validate:"omitempty,min=1" doc:"Page number (1-based)" example:"1"`
PageSize int `query:"page_size" validate:"omitempty,min=1,max=100" doc:"Number of users per page" example:"20"`
Search string `query:"search" doc:"Search term for name or email" example:"john"`
Roles []string `query:"roles" doc:"Filter by user roles (repeat query param: roles=user&roles=admin)" example:"user,admin"`
Active *bool `query:"active" doc:"Filter by active status" example:"true"`
}
ListUsersReq represents a request to list users with pagination and filtering
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the go-bricks Module interface and optionally the Describer interface
func (*Module) DescribeModule ¶
func (m *Module) DescribeModule() app.ModuleDescriptor
DescribeModule implements the optional Describer interface
func (*Module) DescribeRoutes ¶
func (m *Module) DescribeRoutes() []server.RouteDescriptor
DescribeRoutes implements the optional Describer interface
func (*Module) Init ¶
func (m *Module) Init(deps *app.ModuleDeps) error
Init initializes the module with dependencies
func (*Module) RegisterMessaging ¶
RegisterMessaging sets up messaging for this module
func (*Module) RegisterRoutes ¶
func (m *Module) RegisterRoutes(hr *server.HandlerRegistry, r server.RouteRegistrar)
RegisterRoutes demonstrates both old and new registration styles
type Response ¶
type Response struct {
ID int `json:"id" doc:"Unique user identifier" example:"123"`
Name string `json:"name" doc:"User's full name" example:"testUserName"`
Email string `json:"email" doc:"User's email address" example:"testEmail"`
Age *int `json:"age,omitempty" doc:"User's age" example:"30"`
Role string `json:"role" doc:"User role" example:"user"`
Active bool `json:"active" doc:"Whether the user account is active" example:"true"`
CreatedAt time.Time `json:"created_at" doc:"Account creation timestamp" example:"2023-01-15T10:30:00Z"`
UpdatedAt time.Time `json:"updated_at" doc:"Last update timestamp" example:"2023-01-15T14:45:00Z"`
Metadata map[string]string `json:"metadata,omitempty" doc:"Additional user metadata"`
}
Response represents a user in API responses
type UpdateUserReq ¶
type UpdateUserReq struct {
ID int `param:"id" validate:"required,min=1" doc:"User ID" example:"123"`
Name string `json:"name,omitempty" validate:"omitempty,min=2,max=100" doc:"User's full name" example:"testUserName"`
Email string `json:"email,omitempty" validate:"omitempty,email" doc:"User's email address" example:"testEmail"`
Age *int `json:"age,omitempty" validate:"omitempty,min=13,max=120" doc:"User's age" example:"30"`
Role string `json:"role,omitempty" validate:"omitempty,oneof=admin user guest" doc:"User role" example:"user"`
Active *bool `json:"active,omitempty" doc:"Whether the user account is active" example:"true"`
}
UpdateUserReq represents a request to update user information