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 GetUserResponse ¶
type GetUserResponse struct {
User *User `json:"user,omitempty"`
Error string `json:"error,omitempty"`
}
GetUserResponse 获取用户响应
type ListUsersRequest ¶ added in v1.1.0
type ListUsersRequest struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
Keyword string `json:"keyword,omitempty"`
}
ListUsersRequest 列表查询请求
type ListUsersResponse ¶ added in v1.1.0
type ListUsersResponse struct {
Total int `json:"total"`
Users []*User `json:"users"`
Error string `json:"error,omitempty"`
}
ListUsersResponse 列表查询响应
type UpdateUserRequest ¶
type UpdateUserRequest struct {
ID uint `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 uint `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Age int `json:"age"`
}
User 表示对外暴露的用户实体
type UserModel ¶ added in v1.1.0
type UserModel struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
Username string `json:"username" gorm:"column:username;type:varchar(64);not null;uniqueIndex"` // 用户名(唯一)
Email string `json:"email" gorm:"column:email;type:varchar(128);not null;uniqueIndex"` // 邮箱(唯一)
Age int `json:"age" gorm:"column:age;type:tinyint unsigned"` // 年龄
Status int `json:"status" gorm:"column:status;type:tinyint;default:1"` // 状态 1=正常 0=禁用
}
UserModel 用户数据库模型(带 gorm tag,microgen -model 时生成 model/repository 代码)
type UserService ¶
type UserService interface {
// CreateUser 创建用户
CreateUser(ctx context.Context, req CreateUserRequest) (CreateUserResponse, error)
// GetUser 获取用户详情
GetUser(ctx context.Context, req GetUserRequest) (GetUserResponse, error)
// UpdateUser 更新用户信息
UpdateUser(ctx context.Context, req UpdateUserRequest) (UpdateUserResponse, error)
// DeleteUser 删除用户
DeleteUser(ctx context.Context, req DeleteUserRequest) (DeleteUserResponse, error)
// ListUsers 分页查询用户列表
ListUsers(ctx context.Context, req ListUsersRequest) (ListUsersResponse, error)
}
UserService 用户服务接口
Click to show internal directories.
Click to hide internal directories.