2024-11-09 14:59:27 +08:00
|
|
|
|
package validate
|
|
|
|
|
|
2024-11-13 16:30:51 +08:00
|
|
|
|
import "github.com/mcuadros/go-defaults"
|
|
|
|
|
|
2024-11-09 14:59:27 +08:00
|
|
|
|
type CreateItemParam struct {
|
|
|
|
|
Itemname string `json:"itemname" validate:"required,max=12" example:"女大自用iPhone18"`
|
|
|
|
|
// @description 商品价格,单位为分
|
|
|
|
|
Price int `json:"price" validate:"required" example:"1000"`
|
|
|
|
|
//@description 图片ID,请用 /file/upload/item-img 接口上传图片后获取的图片唯一标识
|
|
|
|
|
Img string `json:"img" validate:"required,len=12" example:"123456789012" description:""`
|
|
|
|
|
Desc string `json:"desc" validate:"required" example:"这是一个女大自用的iPhone18"`
|
|
|
|
|
// @description 商品类型,可以有多个类型,请用数组传过来,类型id请使用 /item/types 接口获取
|
|
|
|
|
Types []int `json:"types" validate:"required" example:"1,2"`
|
|
|
|
|
}
|
2024-11-09 16:36:28 +08:00
|
|
|
|
|
|
|
|
|
type DeleteItemParam struct {
|
|
|
|
|
Id uint `json:"id" validate:"required" example:"1"`
|
|
|
|
|
}
|
2024-11-11 22:38:17 +08:00
|
|
|
|
|
2024-11-13 16:30:51 +08:00
|
|
|
|
type PagingParam struct {
|
2024-11-13 16:40:17 +08:00
|
|
|
|
// @description 页码
|
2024-11-13 16:30:51 +08:00
|
|
|
|
Page int `json:"page" validate:"min=0" example:"1" default:"1"`
|
2024-11-11 22:38:17 +08:00
|
|
|
|
// @description 每页数量
|
2024-11-13 16:30:51 +08:00
|
|
|
|
PageSize int `json:"pageSize" validate:"max=50" example:"10" default:"10"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *CreateItemParam) Default() {
|
|
|
|
|
defaults.SetDefaults(p)
|
|
|
|
|
}
|
|
|
|
|
func (p *DeleteItemParam) Default() {
|
|
|
|
|
defaults.SetDefaults(p)
|
|
|
|
|
}
|
|
|
|
|
func (p *PagingParam) Default() {
|
|
|
|
|
defaults.SetDefaults(p)
|
2024-11-11 22:38:17 +08:00
|
|
|
|
}
|