Skip to content

Commit

Permalink
API if Fail Return
Browse files Browse the repository at this point in the history
  • Loading branch information
cherry-yl-sh committed Mar 5, 2024
1 parent 19a5e24 commit ce8e82e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rpc_server/api/v1/get_support_entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ func GetSupportEntrypoint(c *gin.Context) {
if err := c.ShouldBindJSON(&request); err != nil {
errStr := fmt.Sprintf("Request Error [%v]", err)
response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr)
return
}
if err := request.Validate(); err != nil {
errStr := fmt.Sprintf("Request Error [%v]", err)
response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr)
return
}

//2. recall service
result, err := operator.GetSupportEntrypointExecute(request)
if err != nil {
errStr := fmt.Sprintf("%v", err)
response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr)
return
}
response.WithData(result).Success(c)

Expand Down
3 changes: 3 additions & 0 deletions rpc_server/api/v1/get_support_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ func GetSupportStrategy(c *gin.Context) {
if err := c.ShouldBindJSON(&request); err != nil {
errStr := fmt.Sprintf("Request Error [%v]", err)
response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr)
return
}
if err := request.Validate(); err != nil {
errStr := fmt.Sprintf("Request Error [%v]", err)
response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr)
return
}
result, err := operator.GetSupportStrategyExecute(request)
if err != nil {
errStr := fmt.Sprintf("%v", err)
response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr)
return
}
response.WithData(result).Success(c)
}
3 changes: 3 additions & 0 deletions rpc_server/api/v1/try_pay_user_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ func TryPayUserOperation(c *gin.Context) {
if err := c.ShouldBindJSON(&request); err != nil {
errStr := fmt.Sprintf("Request Error [%v]", err)
response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr)
return
}

if err := request.Validate(); err != nil {
errStr := fmt.Sprintf("Request Error [%v]", err)
response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr)
return
}
//2. recall service
result, err := operator.TryPayUserOpExecute(request)
if err != nil {
errStr := fmt.Sprintf("TryPayUserOpExecute ERROR [%v]", err)
response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr)
return
}
response.WithData(result).Success(c)
}

0 comments on commit ce8e82e

Please sign in to comment.