package forms import ( "errors" ) type AnnouncementAddReq struct { Title string `json:"title" form:"title"` Content string `json:"content" form:"content"` } func (req *AnnouncementAddReq) Check() error { if req.Content == "" { return errors.New("公告内容不能为空") } if req.Title == "" { return errors.New("公告标题不能为空") } return nil }