Skip to content

Commit

Permalink
Merge branch 'feat/coupon' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sjatsh committed Nov 8, 2023
2 parents bac97b1 + 46ae857 commit 941936d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions http_server/handle/check_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (h *HttpHandle) CheckPermissions(ctx *gin.Context) {
var apiResp api_code.ApiResp
defer func() {
if apiResp.ErrNo != 0 {
ctx.JSON(http.StatusOK, apiResp)
ctx.Abort()
}
}()
Expand Down
3 changes: 2 additions & 1 deletion http_server/handle/coupon_code_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/dotbitHQ/das-lib/core"
api_code "github.com/dotbitHQ/das-lib/http_api"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"net/http"
)

Expand Down Expand Up @@ -44,7 +45,7 @@ func (h *HttpHandle) CouponCodeList(ctx *gin.Context) {
)
log.Info("ApiReq:", funcName, clientIp, remoteAddrIP, ctx)

if err := ctx.ShouldBindJSON(&req); err != nil {
if err := ctx.ShouldBindBodyWith(&req, binding.JSON); err != nil {
log.Error("ShouldBindJSON err: ", err.Error(), funcName, clientIp, remoteAddrIP, ctx)
apiResp.ApiRespErr(api_code.ApiCodeParamsInvalid, "params invalid")
ctx.JSON(http.StatusOK, apiResp)
Expand Down
3 changes: 2 additions & 1 deletion http_server/handle/coupon_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/dotbitHQ/das-lib/core"
api_code "github.com/dotbitHQ/das-lib/http_api"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"net/http"
)

Expand All @@ -25,7 +26,7 @@ func (h *HttpHandle) CouponDownload(ctx *gin.Context) {
)
log.Info("ApiReq:", funcName, clientIp, remoteAddrIP, ctx)

if err := ctx.ShouldBindJSON(&req); err != nil {
if err := ctx.ShouldBindBodyWith(&req, binding.JSON); err != nil {
log.Error("ShouldBindJSON err: ", err.Error(), funcName, clientIp, remoteAddrIP, ctx)
apiResp.ApiRespErr(api_code.ApiCodeParamsInvalid, "params invalid")
ctx.JSON(http.StatusOK, apiResp)
Expand Down
3 changes: 2 additions & 1 deletion http_server/handle/coupon_order_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/dotbitHQ/das-lib/core"
api_code "github.com/dotbitHQ/das-lib/http_api"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/scorpiotzh/toolib"
"github.com/shopspring/decimal"
"net/http"
Expand Down Expand Up @@ -59,7 +60,7 @@ func (h *HttpHandle) CouponOrderCreate(ctx *gin.Context) {
err error
)

if err := ctx.ShouldBindJSON(&req); err != nil {
if err := ctx.ShouldBindBodyWith(&req, binding.JSON); err != nil {
log.Error("ShouldBindJSON err: ", err.Error(), funcName, clientIp, remoteAddrIP, ctx)
apiResp.ApiRespErr(api_code.ApiCodeParamsInvalid, "params invalid")
ctx.JSON(http.StatusOK, apiResp)
Expand Down

0 comments on commit 941936d

Please sign in to comment.