chain.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package wallet
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. "mtp2_if/models"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. )
  10. type QueryWalletChainsReq struct {
  11. ChannelCode string `form:"channelCode" binding:"required"` // 渠道代码
  12. }
  13. // QueryWalletChains
  14. // @Summary 查询钱包链
  15. // @Produce json
  16. // @Security ApiKeyAuth
  17. // @Param channelCode query string true "渠道代码"
  18. // @Success 200 {array} models.WalletChainRsp
  19. // @Failure 500 {object} app.Response
  20. // @Router /Wallet/QueryWalletChains [get]
  21. // @Tags 钱包
  22. func QueryWalletChains(c *gin.Context) {
  23. appG := app.Gin{C: c}
  24. // 获取请求参数
  25. var req QueryWalletChainsReq
  26. if err := appG.C.ShouldBindQuery(&req); err != nil {
  27. logger.GetLogger().Errorf("QueryWalletChains failed: %s", err.Error())
  28. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  29. return
  30. }
  31. if rsp, err := models.GetWalletChains(req.ChannelCode); err == nil {
  32. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  33. } else {
  34. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  35. }
  36. }