Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct {
Username string `json:"username"`
Email string `json:"email"`
Age int `json:"age"`
}
CreateUserRequest 定义创建用户的请求参数
type CreateUserResponse ¶
type CreateUserResponse struct {
User *User `json:"user,omitempty"`
Error string `json:"error,omitempty"`
}
CreateUserResponse 定义创建用户的响应结果
type DeleteUserRequest ¶
type DeleteUserRequest struct {
ID string `json:"id"`
}
DeleteUserRequest 定义删除用户的请求参数
type DeleteUserResponse ¶
type DeleteUserResponse struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}
DeleteUserResponse 定义删除用户的响应结果
type GetUserRequest ¶
type GetUserRequest struct {
ID string `json:"id"`
}
GetUserRequest 定义获取用户的请求参数
type GetUserResponse ¶
type GetUserResponse struct {
User *User `json:"user,omitempty"`
Error string `json:"error,omitempty"`
}
GetUserResponse 定义获取用户的响应结果
type ManageService ¶
type ManageService interface {
// 创建用户
CreateUser(ctx context.Context, req CreateUserRequest) (CreateUserResponse, error)
// 获取用户
GetUser(ctx context.Context, req GetUserRequest) (GetUserResponse, error)
// 更新用户
UpdateUser(ctx context.Context, req UpdateUserRequest) (UpdateUserResponse, error)
// 删除用户
DeleteUser(ctx context.Context, req DeleteUserRequest) (DeleteUserResponse, error)
}
ManageService 定义用户服务的核心接口
type UpdateUserRequest ¶
type UpdateUserRequest struct {
ID string `json:"id"`
Username string `json:"username,omitempty"`
Email string `json:"email,omitempty"`
Age int `json:"age,omitempty"`
}
UpdateUserRequest 定义更新用户的请求参数
type UpdateUserResponse ¶
type UpdateUserResponse struct {
User *User `json:"user,omitempty"`
Error string `json:"error,omitempty"`
}
UpdateUserResponse 定义更新用户的响应结果
type User ¶
type User struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Age int `json:"age"`
}
User 表示用户实体数据结构
type UserService ¶
type UserService interface {
// 创建用户
CreateUser(ctx context.Context, req CreateUserRequest) (CreateUserResponse, error)
// 获取用户
GetUser(ctx context.Context, req GetUserRequest) (GetUserResponse, error)
// 更新用户
UpdateUser(ctx context.Context, req UpdateUserRequest) (UpdateUserResponse, error)
// 删除用户
DeleteUser(ctx context.Context, req DeleteUserRequest) (DeleteUserResponse, error)
}
UserService 定义用户服务的核心接口
Click to show internal directories.
Click to hide internal directories.