Documentation
¶
Index ¶
- type CreateUserRequest
- type CreateUserResponse
- type DeleteUserRequest
- type DeleteUserResponse
- type ErrorDTO
- type GetUserRequest
- type GetUserResponse
- type ListUsersRequest
- type ListUsersResponse
- type PageInfoDTO
- type Service
- type UpdateUserRequest
- type UpdateUserResponse
- type UserConnectionDTO
- type UserDTO
- type UserEdgeDTO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct {
Email string `json:"email" validate:"required,email"`
Name string `json:"name" validate:"required,min=1,max=255"`
}
CreateUserRequest represents a request to create a new user
type CreateUserResponse ¶
type CreateUserResponse struct {
User *UserDTO `json:"user"`
Errors []ErrorDTO `json:"errors,omitempty"`
}
CreateUserResponse represents the response for creating a user
type DeleteUserRequest ¶
type DeleteUserRequest struct {
ID string `json:"id" validate:"required"`
}
DeleteUserRequest represents a request to delete a user
type DeleteUserResponse ¶
type DeleteUserResponse struct {
Success bool `json:"success"`
Errors []ErrorDTO `json:"errors,omitempty"`
}
DeleteUserResponse represents the response for deleting a user
type ErrorDTO ¶
type ErrorDTO struct {
Message string `json:"message"`
Field string `json:"field,omitempty"`
Code string `json:"code"`
}
ErrorDTO represents an error in the application layer
type GetUserRequest ¶
type GetUserRequest struct {
ID string `json:"id" validate:"required"`
}
GetUserRequest represents a request to get a user by ID
type GetUserResponse ¶
type GetUserResponse struct {
User *UserDTO `json:"user"`
Errors []ErrorDTO `json:"errors,omitempty"`
}
GetUserResponse represents the response for getting a user
type ListUsersRequest ¶
type ListUsersRequest struct {
First int `json:"first" validate:"min=1,max=100"`
After string `json:"after"`
}
ListUsersRequest represents a request to list users with pagination
type ListUsersResponse ¶
type ListUsersResponse struct {
Users *UserConnectionDTO `json:"users"`
Errors []ErrorDTO `json:"errors,omitempty"`
}
ListUsersResponse represents the response for listing users
type PageInfoDTO ¶
type PageInfoDTO struct {
HasNextPage bool `json:"hasNextPage"`
HasPreviousPage bool `json:"hasPreviousPage"`
StartCursor *string `json:"startCursor"`
EndCursor *string `json:"endCursor"`
}
PageInfoDTO represents pagination information
type Service ¶
type Service interface {
// GetUser retrieves a user by ID
GetUser(ctx context.Context, req GetUserRequest) (*GetUserResponse, error)
// ListUsers retrieves a paginated list of users
ListUsers(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error)
// CreateUser creates a new user
CreateUser(ctx context.Context, req CreateUserRequest) (*CreateUserResponse, error)
// UpdateUser updates an existing user
UpdateUser(ctx context.Context, req UpdateUserRequest) (*UpdateUserResponse, error)
// DeleteUser deletes a user by ID
DeleteUser(ctx context.Context, req DeleteUserRequest) (*DeleteUserResponse, error)
}
Service defines the interface for user application services
func NewService ¶
func NewService(userRepo user.Repository, logger *slog.Logger) Service
NewService creates a new user service
type UpdateUserRequest ¶
type UpdateUserRequest struct {
ID string `json:"id" validate:"required"`
Email *string `json:"email,omitempty" validate:"omitempty,email"`
Name *string `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
}
UpdateUserRequest represents a request to update an existing user
type UpdateUserResponse ¶
type UpdateUserResponse struct {
User *UserDTO `json:"user"`
Errors []ErrorDTO `json:"errors,omitempty"`
}
UpdateUserResponse represents the response for updating a user
type UserConnectionDTO ¶
type UserConnectionDTO struct {
Edges []*UserEdgeDTO `json:"edges"`
PageInfo *PageInfoDTO `json:"pageInfo"`
}
UserConnectionDTO represents a paginated list of users
type UserDTO ¶
type UserDTO struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
UserDTO represents a user in the application layer
type UserEdgeDTO ¶
UserEdgeDTO represents a user edge in a connection