Commit 5346bc7c authored by shajiaiming's avatar shajiaiming

获取浏览器地址

parent 5d46ef7b
......@@ -17,7 +17,7 @@ type Chain struct {
Token string `json:"token"` //基础代币
Fee float32 `json:"fee"` //手续费(基础代币)
BrowerUrl string `json:"brower_url"` //浏览器链接
Icon string `json:"icon"` //是否允许转币
Icon string `json:"icon"` //图标
Lock int `json:"lock"` //是否允许转币
}
......@@ -28,6 +28,11 @@ type UserChain struct {
Platform string `json:"platform"` //平行链名称
}
type Explore struct {
BrowerUrl string `json:"brower_url"` //浏览器链接
Icon string `json:"icon"` //图标
}
func (c Chain) TableName() string {
return setting.DatabaseSetting.Name_Sources + ".coin_platform_withhold"
}
......@@ -96,6 +101,21 @@ func GetUserChains(maps interface{}) ([]*UserChain, error) {
return chains, nil
}
func GetExplore(platform string) (*Chain, error) {
var explore Chain
err := db.Where("platform = ?", platform).First(&explore).Error
if err != nil {
return nil, err
}
err = db.Model(&explore).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return &explore, nil
}
/**
* 通过id获取指定链信息
* @param id
......
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
}
......@@ -48,6 +48,7 @@ func InitRouter() *gin.Engine {
client.GET("/live-banners",app.GetLiveBanners)
client.GET("/fees/recommended",app.GetTransactionGas)
client.GET("/tokenview/explore",app.Explore)
api := r.Group("/api")
......
package chain_service
import "bwallet/models"
import (
"bwallet/models"
)
type Chain struct {
ID int
......@@ -18,6 +20,11 @@ type Chain struct {
PageSize int
}
type Explore struct {
BrowerUrl string `json:"brower_url,omitempty"` //浏览器链接
Icon string `json:"icon,omitempty"` //图标
}
func (c *Chain) Get() (*models.Chain, error) {
chain, err := models.GetChain(c.ID)
if err != nil {
......@@ -38,6 +45,19 @@ func (c *Chain) GetAll() ([]*models.Chain, error) {
return chains, nil
}
func (c *Chain) Explore() (*models.Explore, error) {
tmp, err := models.GetExplore(c.Platform)
if err != nil {
return nil, err
}
var explore models.Explore
explore.BrowerUrl = tmp.BrowerUrl
explore.Icon = tmp.Icon
return &explore, nil
}
func (c *Chain) GetUserChain() ([]*models.UserChain, error) {
var chains []*models.UserChain
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment