YiTao/validate/item_validate.go

36 lines
1.3 KiB
Go
Raw Normal View History

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"`
2024-11-21 21:52:35 +08:00
//@description 图片ID请用 /file/upload/item-img 接口上传图片后获取的图片唯一标识,多张图片请数组上传
Imgs []string `json:"img" validate:"required" example:"123456789012,abcdefghijkl" description:""`
Desc string `json:"desc" validate:"required" example:"这是一个女大自用的iPhone18"`
2024-11-09 14:59:27 +08:00
// @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
}