增加使用exception发送响应
This commit is contained in:
@ -52,3 +52,19 @@ func Send(ctx *gin.Context, code interface{}, httpCode int, data interface{}) {
|
||||
func SendWithStatusOK(ctx *gin.Context, code interface{}, data map[string]interface{}) {
|
||||
Send(ctx, code, http.StatusOK, data)
|
||||
}
|
||||
|
||||
// SendWithException 使用exception发送数据
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 13:08 2022/6/26
|
||||
func SendWithException(ctx *gin.Context, e *exception.Exception, data interface{}) {
|
||||
if nil == e {
|
||||
e = exception.NewSuccess(data)
|
||||
}
|
||||
if nil != e.GetData() {
|
||||
Send(ctx, e.GetCode(), e.GetHttpCode(), e.GetData())
|
||||
} else {
|
||||
Send(ctx, e.GetCode(), e.GetHttpCode(), data)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user