36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package validate
|
||
|
||
import "github.com/mcuadros/go-defaults"
|
||
|
||
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"`
|
||
}
|
||
|
||
type DeleteItemParam struct {
|
||
Id uint `json:"id" validate:"required" example:"1"`
|
||
}
|
||
|
||
type PagingParam struct {
|
||
// @description 页码
|
||
Page int `json:"page" validate:"min=0" example:"1" default:"1"`
|
||
// @description 每页数量
|
||
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)
|
||
}
|