package app

import (
	"bwallet/pkg/errno"
	"bwallet/pkg/handler"
	"bwallet/service/chain_service"
	"github.com/astaxie/beego/validation"
	"github.com/gin-gonic/gin"
)

func Explore(c *gin.Context) {
	valid := validation.Validation{}
	platform := c.DefaultQuery("platform", "")
	valid.Required(platform, "platform").Message("平台名不能为空")

	if valid.HasErrors() {
		handler.SendResponse(c, valid.Errors[0], nil)
		return
	}

	chainService := chain_service.Chain{Platform: platform}
	explore, err := chainService.Explore()

	if err != nil {
		handler.SendResponse(c, errno.ErrCoinNotFound, nil)
		return
	}

	handler.SendResponse(c, nil, explore)
	return
}
