对接
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/gin-gonic/gin"
|
||||
bizgift "kra/internal/biz/gift"
|
||||
"kra/internal/service/dto"
|
||||
service "kra/internal/service/gift"
|
||||
)
|
||||
@@ -136,6 +138,16 @@ func (h *Gift) Send(c *gin.Context) {
|
||||
}
|
||||
v, e := h.s.Send(c.Request.Context(), claims.ID, id, in)
|
||||
if e != nil {
|
||||
var insufficient *bizgift.InsufficientBalanceError
|
||||
if errors.As(e, &insufficient) {
|
||||
Write(c, CodeError, gin.H{
|
||||
"reason": "insufficient_balance",
|
||||
"required": insufficient.Required,
|
||||
"balance": insufficient.Balance,
|
||||
"missing": insufficient.Missing,
|
||||
}, e.Error())
|
||||
return
|
||||
}
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user