package request import ( "errors" "gitea.ddegame.cn/open/servicebase/pkg/tools" ) type BaseRequest struct { AccessToken string } // 参数合法性检验 func (request *BaseRequest) CheckParameter() (err error) { if len(request.AccessToken) == 0 { err = errors.New("AccessToken不能为空") return } return } type IdReq struct { BaseRequest BizId string } func (request *IdReq) CheckParameter() (e error) { if e = request.BaseRequest.CheckParameter(); e != nil { return } if len(request.BizId) == 0 { return errors.New("BizId不能为空") } return } type BasePageReq struct { BaseRequest Page string Size string } func (d *BasePageReq) Check() (e error) { if e = d.BaseRequest.CheckParameter(); e != nil { return } if len(d.Page) == 0 { d.Page = "0" } if len(d.Size) == 0 { d.Size = "10" } return } func (d *BasePageReq) Offset() int { return tools.StrToInt(d.Page) * tools.StrToInt(d.Size) } func (d *BasePageReq) Limit() int { return tools.StrToInt(d.Size) }