package subject import ( "github.com/gin-gonic/gin" "product/backend/handlers/base" "product/backend/models" ) // 请求结构体 type WithParams struct { WithKnowledgeGroup bool `json:"withKnowledgeGroup" form:"withKnowledgeGroup"` WithDirectiveGroup bool `json:"withDirectiveGroup" form:"withDirectiveGroup"` WithProductGroup bool `json:"withProductGroup" form:"withProductGroup"` WithLessonType bool `json:"withLessonType" form:"withLessonType"` } type PostReq struct { Type string `json:"type" binding:"oneof='common''special'''"` models.Subject WithParams } type PutReq struct { ID uint `json:"id" binding:"required"` Type string `json:"type" binding:"oneof='common''special'''"` models.Subject WithParams } type GetReq struct { base.GetReq Type string `json:"type" binding:"oneof='common''special'''"` WithParams } func (getReq *GetReq) BindAndInit(ctx *gin.Context) error { if err := ctx.ShouldBindQuery(&getReq); err != nil { return err } getReq.GetReq.Init() return nil } type DelReq struct { base.DelReq }