Commit d18111f6 authored by shajiaiming's avatar shajiaiming

主链信息

parent ef89831e
...@@ -237,3 +237,13 @@ func GetCoinsPlatform() ([]*Coin, error) { ...@@ -237,3 +237,13 @@ func GetCoinsPlatform() ([]*Coin, error) {
return coins, nil return coins, nil
} }
func GetCoinChains() ([]*Coin, error) {
var coins []*Coin
err := db.Select("chain").Where("chain <> ?", "").Group("chain").Find(&coins).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return coins, nil
}
package v1 package v1
import ( import (
"bwallet/pkg/app"
"bwallet/pkg/e"
"bwallet/pkg/errno" "bwallet/pkg/errno"
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
...@@ -12,6 +14,7 @@ import ( ...@@ -12,6 +14,7 @@ import (
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/astaxie/beego/validation" "github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http"
"strconv" "strconv"
"strings" "strings"
) )
...@@ -325,6 +328,28 @@ func GetCoinsPlatform(c *gin.Context) { ...@@ -325,6 +328,28 @@ func GetCoinsPlatform(c *gin.Context) {
} }
*/ */
func GetCoinChains(c *gin.Context) {
appG := app.Gin{c}
coinService := coin_service.Coin{}
coins, err := coinService.GetCoinChains()
if err != nil {
appG.Response(http.StatusInternalServerError, e.ERROR_GET_COIN_FAIL, nil)
return
}
data := make(map[string]interface{})
var items [] string
for _, value := range coins {
if "" != value.Chain {
items = append(items, value.Chain)
}
}
data["items"] = items
handler.SendResponse(c, nil, data)
}
func GetPrimaryChains(c *gin.Context) { func GetPrimaryChains(c *gin.Context) {
data := make(map[string]interface{}) data := make(map[string]interface{})
data["items"] = [] string{"BTC", "ETH", "BTY", "DCR"} data["items"] = [] string{"BTC", "ETH", "BTY", "DCR"}
......
package routers package routers
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"bwallet/middleware/auth" "bwallet/middleware/auth"
"bwallet/pkg/upload" "bwallet/pkg/upload"
"bwallet/routers/api" "bwallet/routers/api"
"bwallet/routers/api/v1" "bwallet/routers/api/v1"
"net/http" "net/http"
) )
func InitRouter() *gin.Engine { func InitRouter() *gin.Engine {
r := gin.New() r := gin.New()
r.Use(gin.Logger()) r.Use(gin.Logger())
r.Use(gin.Recovery()) r.Use(gin.Recovery())
r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath())) r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
//r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath())) //r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))
r.POST("/auth", api.GetAuth) r.POST("/auth", api.GetAuth)
//r.POST("/upload", api.UploadImage) //r.POST("/upload", api.UploadImage)
api := r.Group("/api") api := r.Group("/api")
api.Use(auth.AUTH()) api.Use(auth.AUTH())
{ {
//api.POST("/upload",v1.Upload) //api.POST("/upload",v1.Upload)
api.GET("/coins", v1.GetCoins) api.GET("/coins", v1.GetCoins)
api.POST("/coin", v1.AddCoin) api.POST("/coin", v1.AddCoin)
api.GET("/coin", v1.GetCoin) api.GET("/coin", v1.GetCoin)
api.PUT("/coin", v1.EditCoin) api.PUT("/coin", v1.EditCoin)
api.DELETE("/coin", v1.DeleteCoin) api.DELETE("/coin", v1.DeleteCoin)
api.GET("/primary-chains", v1.GetPrimaryChains) api.GET("/primary-chains", v1.GetCoinChains)
api.GET("/types", v1.GetTypes) api.GET("/types", v1.GetTypes)
api.GET("/coin-relation", v1.GetWalletCoinRelationCoinRelations) api.GET("/coin-relation", v1.GetWalletCoinRelationCoinRelations)
api.POST("/coin-relation", v1.AddWalletCoinRelationCoinRelation) api.POST("/coin-relation", v1.AddWalletCoinRelationCoinRelation)
api.DELETE("/coin-relation", v1.DeleteWalletCoinRelationCoinRelation) api.DELETE("/coin-relation", v1.DeleteWalletCoinRelationCoinRelation)
//api.GET("/get-platform", v1.GetCoinsPlatform) //api.GET("/get-platform", v1.GetCoinsPlatform)
api.GET("/wallets", v1.GetWallets) api.GET("/wallets", v1.GetWallets)
api.POST("/wallet", v1.AddWallet) api.POST("/wallet", v1.AddWallet)
api.GET("/wallet", v1.GetWallet) api.GET("/wallet", v1.GetWallet)
api.PUT("/wallet", v1.EditWallet) api.PUT("/wallet", v1.EditWallet)
api.DELETE("/wallet", v1.DeleteWallet) api.DELETE("/wallet", v1.DeleteWallet)
api.GET("/chains", v1.GetChains) api.GET("/chains", v1.GetChains)
api.POST("/chain", v1.AddChain) api.POST("/chain", v1.AddChain)
api.GET("/chain", v1.GetChain) api.GET("/chain", v1.GetChain)
api.PUT("/chain", v1.EditChain) api.PUT("/chain", v1.EditChain)
api.DELETE("/chain", v1.DeleteChain) api.DELETE("/chain", v1.DeleteChain)
api.GET("/user-chains", v1.GetUserChains) api.GET("/user-chains", v1.GetUserChains)
api.GET("/recommend-categories", v1.GetWalletRecommendCategories) api.GET("/recommend-categories", v1.GetWalletRecommendCategories)
api.POST("/recommend-category", v1.AddWalletRecommendCategory) api.POST("/recommend-category", v1.AddWalletRecommendCategory)
api.GET("/recommend-category", v1.GetWalletRecommendCategory) api.GET("/recommend-category", v1.GetWalletRecommendCategory)
api.DELETE("/recommend-category", v1.DeleteWalletRecommendCategory) api.DELETE("/recommend-category", v1.DeleteWalletRecommendCategory)
api.PUT("/recommend-category", v1.EditWalletRecommendCategory) api.PUT("/recommend-category", v1.EditWalletRecommendCategory)
api.GET("/recommend-coins", v1.GetRecommendCoins) api.GET("/recommend-coins", v1.GetRecommendCoins)
api.POST("/recommend-coin", v1.AddRecommendCoin) api.POST("/recommend-coin", v1.AddRecommendCoin)
api.PUT("/recommend-coin", v1.EditRecommendCoin) api.PUT("/recommend-coin", v1.EditRecommendCoin)
api.DELETE("/recommend-coin", v1.DeleteRecommendCoin) api.DELETE("/recommend-coin", v1.DeleteRecommendCoin)
api.GET("/supported-currencies", v1.GetSupportedCurrencies) api.GET("/supported-currencies", v1.GetSupportedCurrencies)
api.POST("/supported-currency", v1.AddSupportedCurrency) api.POST("/supported-currency", v1.AddSupportedCurrency)
api.GET("/supported-currency", v1.GetSupportedCurrency) api.GET("/supported-currency", v1.GetSupportedCurrency)
api.PUT("/supported-currency", v1.EditSupportedCurrency) api.PUT("/supported-currency", v1.EditSupportedCurrency)
api.DELETE("/supported-currency", v1.DeleteSupportedCurrency) api.DELETE("/supported-currency", v1.DeleteSupportedCurrency)
api.GET("/currencies", v1.GetCurrencies) api.GET("/currencies", v1.GetCurrencies)
api.GET("/supported-chains", v1.GetSupportedChains) api.GET("/supported-chains", v1.GetSupportedChains)
api.POST("/supported-chain", v1.AddSupportedChain) api.POST("/supported-chain", v1.AddSupportedChain)
api.DELETE("/supported-chain", v1.DeleteSupportedChain) api.DELETE("/supported-chain", v1.DeleteSupportedChain)
} }
return r return r
} }
...@@ -190,6 +190,17 @@ func (c *Coin) GetCoinsPlatform() ([]*models.Coin, error) { ...@@ -190,6 +190,17 @@ func (c *Coin) GetCoinsPlatform() ([]*models.Coin, error) {
return coins, nil return coins, nil
} }
func (c *Coin) GetCoinChains() ([]*models.Coin, error) {
var coins []*models.Coin
coins, err := models.GetCoinChains()
if err != nil {
return nil, err
}
return coins, nil
}
func (c *Coin) getMaps() (map[string]interface{}) { func (c *Coin) getMaps() (map[string]interface{}) {
maps := make(map[string]interface{}) maps := make(map[string]interface{})
......
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