Commit a3b2e002 by yemin

提供不带事务返回封装的方法

parent ab097e5d
......@@ -49,6 +49,15 @@ func FailAndMsg(c *gin.Context, subCode, subMsg string) {
logEnd(c, resp)
}
// FailAndMsgNoTx 不带事务
func FailAndMsgNoTx(c *gin.Context, subCode, subMsg string) {
resp := ServerResponse{Code: BusinessError, Msg: "业务错误", SubCode: subCode, SubMsg: subMsg}
c.JSON(http.StatusOK, resp)
c.Abort()
logEnd(c, resp)
}
// Success 有事务的用这个
func Success(c *gin.Context) {
db.Commit()
resp := response(OK)
......@@ -57,6 +66,15 @@ func Success(c *gin.Context) {
logEnd(c, resp)
}
// SuccessNoTx 不带事务提交
func SuccessNoTx(c *gin.Context) {
resp := response(OK)
c.JSON(http.StatusOK, resp)
c.Abort()
logEnd(c, resp)
}
// SuccessData 有事务的用这个
func SuccessData(c *gin.Context, data interface{}) {
db.Commit()
resp := ServerDataResponse{response(OK), data}
......@@ -65,6 +83,14 @@ func SuccessData(c *gin.Context, data interface{}) {
logEnd(c, resp)
}
// SuccessDataNoTx 不带事务提交
func SuccessDataNoTx(c *gin.Context, data interface{}) {
resp := ServerDataResponse{response(OK), data}
c.JSON(http.StatusOK, resp)
c.Abort()
logEnd(c, resp)
}
func SuccessString(c *gin.Context, data string) {
c.String(http.StatusOK, data)
c.Abort()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment