增肌处理结果的响应数据

This commit is contained in:
白茶清欢 2021-11-12 11:40:08 +08:00
parent cf07d30ca7
commit a63f196e0b
3 changed files with 21 additions and 3 deletions

View File

@ -14,4 +14,4 @@ import "github.com/gin-gonic/gin"
// Author : go_developer@163.com<白茶清欢>
//
// Date : 6:42 下午 2021/11/11
type IGitHookEventHandler func(ctx *gin.Context, hookData *HookData)
type IGitHookEventHandler func(ctx *gin.Context, hookData *HookData) *ResponseData

View File

@ -152,3 +152,14 @@ type CommitAuthor struct {
Email string `json:"email"` // 邮箱
Username string `json:"username"` // 用户名
}
// ResponseData 处理结果的返回值
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 11:37 上午 2021/11/12
type ResponseData struct {
Code interface{} `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}

View File

@ -31,8 +31,15 @@ func RegisterGitHookRouter(router *gin.Engine, handler IGitHookEventHandler) err
if err = ctx.ShouldBindJSON(&hookData); nil != err {
ctx.JSON(http.StatusBadRequest, gin.H{"code": -1, "message": err.Error()})
}
handler(ctx, &hookData)
// TODO : 响应数据
responseData := handler(ctx, &hookData)
if nil == responseData {
responseData = &ResponseData{
Code: 100,
Message: "处理完成(未设置返回值,系统默认返回此信息)",
Data: map[string]interface{}
}
}
ctx.JSON(http.StatusOK, responseData)
})
return nil
}