From a8aeacfd967b5ff205f9d1e79bb272397555932e Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 18 Oct 2023 11:14:49 +0800 Subject: [PATCH] debug toekn --- utils/basic/basic.go | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/utils/basic/basic.go b/utils/basic/basic.go index 40b108da..da6f5dea 100644 --- a/utils/basic/basic.go +++ b/utils/basic/basic.go @@ -170,6 +170,54 @@ func (resp *Response) SetWithDebug(sr *StatusResponse, debug interface{}) *Respo return resp } +// WithDebug 设置默认debug参数 +func (resp *Response) WithDebug(debug interface{}) *Response { + + if resp == nil { + panic("must call the func Set... before") + } + + resp.Debug = debug + + return resp +} + +// WithData 设置默认data参数 +func (resp *Response) WithData(data interface{}) *Response { + + if resp == nil { + panic("must call the func Set... before") + } + + resp.Data = data + + return resp +} + +// WithMessage 设置默认message参数 +func (resp *Response) WithMessage(msg string) *Response { + + if resp == nil { + panic("must call the func Set... before") + } + + resp.Message = msg + + return resp +} + +// WithError 设置默认error参数 +func (resp *Response) WithError(err error) *Response { + + if resp == nil { + panic("must call the func Set... before") + } + + resp.Message = err.Error() + + return resp +} + // SetStatusWithMessage 设置默认StatusResponse(内部自定义) 非默认msg, 可以带data, data只使用一个参数 func (resp *Response) SetStatusWithMessage(sr *StatusResponse, msg string, dataAndDebug ...interface{}) *Response { newResp := &Response{