Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateProductRequest ¶
type CreateProductRequest struct {
Name string `json:"name" binding:"required"`
Description string `json:"description"`
Price float64 `json:"price" binding:"required,min=0"`
Stock int `json:"stock" binding:"min=0"`
Category string `json:"category"`
}
CreateProductRequest 创建产品请求
type CreateUserRequest ¶
type CreateUserRequest struct {
Username string `json:"username" binding:"required,min=3,max=50"`
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required,min=6"`
FullName string `json:"full_name" binding:"required"`
}
CreateUserRequest 创建用户请求
type LoginRequest ¶
type LoginRequest struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
}
LoginRequest 登录请求
type LoginResponse ¶
LoginResponse 登录响应
type Product ¶
type Product struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"not null"`
Description string `json:"description"`
Price float64 `json:"price" gorm:"not null"`
Stock int `json:"stock" gorm:"default:0"`
Category string `json:"category"`
IsActive bool `json:"is_active" gorm:"default:true"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
Product 产品模型
type ProductListResponse ¶
type ProductListResponse struct {
Products []Product `json:"products"`
Total int64 `json:"total"`
Page int `json:"page"`
Limit int `json:"limit"`
}
ProductListResponse 产品列表响应
type ProductQuery ¶
type ProductQuery struct {
Page int `form:"page,default=1" binding:"min=1"`
Limit int `form:"limit,default=10" binding:"min=1,max=100"`
Category string `form:"category"`
MinPrice float64 `form:"min_price" binding:"min=0"`
MaxPrice float64 `form:"max_price" binding:"min=0"`
Search string `form:"search"`
}
ProductQuery 产品查询参数
type UpdateProductRequest ¶
type UpdateProductRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Price *float64 `json:"price" binding:"omitempty,min=0"`
Stock *int `json:"stock" binding:"omitempty,min=0"`
Category string `json:"category"`
IsActive *bool `json:"is_active"`
}
UpdateProductRequest 更新产品请求
type UpdateUserRequest ¶
type UpdateUserRequest struct {
FullName string `json:"full_name"`
IsActive *bool `json:"is_active"`
}
UpdateUserRequest 更新用户请求
type User ¶
type User struct {
ID uint `json:"id" gorm:"primaryKey"`
Username string `json:"username" gorm:"uniqueIndex;not null"`
Email string `json:"email" gorm:"uniqueIndex;not null"`
Password string `json:"-" gorm:"not null"`
FullName string `json:"full_name"`
IsActive bool `json:"is_active" gorm:"default:true"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
User 用户模型
Click to show internal directories.
Click to hide internal directories.