Commit 371d62e7 authored by shajiaiming's avatar shajiaiming

fix

parent b640f5e7
...@@ -10,8 +10,8 @@ type Coin struct { ...@@ -10,8 +10,8 @@ type Coin struct {
Model Model
Id int `json:"primary_key, id,omitempty"` Id int `json:"primary_key, id,omitempty"`
Symbol string `json:"symbol"` //简称 Name string `json:"name"` //简称
Name json.RawMessage `json:"name"` //全称 Nickname json.RawMessage `json:"nickname"` //全称
Icon string `json:"icon"` //币种图标 Icon string `json:"icon"` //币种图标
Introduce json.RawMessage `json:"introduce"` //币种介绍 Introduce json.RawMessage `json:"introduce"` //币种介绍
Official string `json:"official"` //官网 Official string `json:"official"` //官网
...@@ -124,8 +124,8 @@ func GetCoin(id int) (*Coin, error) { ...@@ -124,8 +124,8 @@ func GetCoin(id int) (*Coin, error) {
*/ */
func AddCoin(data map[string]interface{}) (error) { func AddCoin(data map[string]interface{}) (error) {
coin := Coin{ coin := Coin{
Symbol: data["symbol"].(string), Name: data["name"].(string),
Name: data["name"].(json.RawMessage), Nickname: data["nickname"].(json.RawMessage),
Icon: data["icon"].(string), Icon: data["icon"].(string),
Introduce: data["introduce"].(json.RawMessage), Introduce: data["introduce"].(json.RawMessage),
Official: data["official"].(string), Official: data["official"].(string),
......
...@@ -64,9 +64,9 @@ func GetCoins(c *gin.Context) { ...@@ -64,9 +64,9 @@ func GetCoins(c *gin.Context) {
valid := validation.Validation{} valid := validation.Validation{}
symbol := "" name := ""
if arg := c.Query("symbol"); arg != "" { if arg := c.Query("name"); arg != "" {
symbol = c.Query("symbol") name = c.Query("name")
} }
platform := "" platform := ""
...@@ -90,7 +90,7 @@ func GetCoins(c *gin.Context) { ...@@ -90,7 +90,7 @@ func GetCoins(c *gin.Context) {
} }
coinService := coin_service.Coin{ coinService := coin_service.Coin{
Symbol: symbol, Name: name,
Chain: chain, Chain: chain,
Platform: platform, Platform: platform,
PlatformId: platform_id, PlatformId: platform_id,
...@@ -140,7 +140,7 @@ func AddCoin(c *gin.Context) { ...@@ -140,7 +140,7 @@ func AddCoin(c *gin.Context) {
coinService := coin_service.Coin{ coinService := coin_service.Coin{
Name: coin.Name, Name: coin.Name,
Symbol: coin.Symbol, Nickname: coin.Nickname,
Icon: coin.Icon, Icon: coin.Icon,
Introduce: coin.Introduce, Introduce: coin.Introduce,
Official: coin.Official, Official: coin.Official,
...@@ -179,7 +179,7 @@ func EditCoin(c *gin.Context) { ...@@ -179,7 +179,7 @@ func EditCoin(c *gin.Context) {
coinService := coin_service.Coin{ coinService := coin_service.Coin{
Id: coin.Id, Id: coin.Id,
Name: coin.Name, Name: coin.Name,
Symbol: coin.Symbol, Nickname: coin.Nickname,
Icon: coin.Icon, Icon: coin.Icon,
Introduce: coin.Introduce, Introduce: coin.Introduce,
Official: coin.Official, Official: coin.Official,
......
...@@ -81,8 +81,8 @@ func AddSupportedChain(c *gin.Context) { ...@@ -81,8 +81,8 @@ func AddSupportedChain(c *gin.Context) {
} }
coinService := coin_service.Coin{ coinService := coin_service.Coin{
Symbol: chain.CoinName, Name: chain.CoinName,
Chain: strings.ToUpper(chain.CoinName), Chain: strings.ToUpper(chain.CoinName),
} }
coin, err := coinService.Find() coin, err := coinService.Find()
...@@ -90,10 +90,10 @@ func AddSupportedChain(c *gin.Context) { ...@@ -90,10 +90,10 @@ func AddSupportedChain(c *gin.Context) {
handler.SendResponse(c, errno.ErrCoinNotFound, nil) handler.SendResponse(c, errno.ErrCoinNotFound, nil)
return return
} }
if "" == coin.Symbol { if "" == coin.Name {
coinService := coin_service.Coin{ coinService := coin_service.Coin{
Symbol: chain.CoinName, Name: chain.CoinName,
Chain: "BTY", Chain: "BTY",
} }
coin, err = coinService.Find() coin, err = coinService.Find()
if err != nil { if err != nil {
...@@ -101,7 +101,7 @@ func AddSupportedChain(c *gin.Context) { ...@@ -101,7 +101,7 @@ func AddSupportedChain(c *gin.Context) {
return return
} }
} }
if "" == coin.Symbol { if "" == coin.Name {
handler.SendResponse(c, errno.ErrCoinNotFound, nil) handler.SendResponse(c, errno.ErrCoinNotFound, nil)
return return
} }
......
...@@ -25,9 +25,9 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) { ...@@ -25,9 +25,9 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
} else { } else {
platform_id = auth.PlatformId platform_id = auth.PlatformId
} }
symbol := "" name := ""
if arg := c.Query("symbol"); arg != "" { if arg := c.Query("name"); arg != "" {
symbol = c.Query("symbol") name = c.Query("name")
} }
platform := "" platform := ""
...@@ -43,10 +43,10 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) { ...@@ -43,10 +43,10 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
walletCoinRelateionService := wallet_coin_relation_service.WalletCoinRelation{ walletCoinRelateionService := wallet_coin_relation_service.WalletCoinRelation{
PlatformId: platform_id, PlatformId: platform_id,
CoinCondition: struct { CoinCondition: struct {
Symbol string Name string
Chain string Chain string
Platform string Platform string
}{Symbol: symbol, Chain: chain, Platform: platform}, }{Name: name, Chain: chain, Platform: platform},
PageNum: util.GetPage(c), PageNum: util.GetPage(c),
PageSize: util.GetLimit(c), PageSize: util.GetLimit(c),
} }
......
...@@ -9,8 +9,8 @@ import ( ...@@ -9,8 +9,8 @@ import (
type Coin struct { type Coin struct {
Id int Id int
Symbol string Name string
Name json.RawMessage Nickname json.RawMessage
Icon string Icon string
Introduce json.RawMessage Introduce json.RawMessage
Official string Official string
...@@ -74,7 +74,7 @@ func (c *Coin) GetAll() ([]*models.Coin, error) { ...@@ -74,7 +74,7 @@ func (c *Coin) GetAll() ([]*models.Coin, error) {
func (c *Coin) Find() (*models.Coin, error) { func (c *Coin) Find() (*models.Coin, error) {
var coin *models.Coin var coin *models.Coin
coin, err := models.Find(c.Symbol, c.Chain) coin, err := models.Find(c.Name, c.Chain)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -88,8 +88,8 @@ func (c *Coin) Find() (*models.Coin, error) { ...@@ -88,8 +88,8 @@ func (c *Coin) Find() (*models.Coin, error) {
*/ */
func (c *Coin) Add() error { func (c *Coin) Add() error {
coin := map[string]interface{}{ coin := map[string]interface{}{
"symbol": c.Symbol,
"name": c.Name, "name": c.Name,
"nickname": c.Nickname,
"icon": c.Icon, "icon": c.Icon,
"introduce": c.Introduce, "introduce": c.Introduce,
"official": c.Official, "official": c.Official,
...@@ -121,7 +121,7 @@ func (c *Coin) Add() error { ...@@ -121,7 +121,7 @@ func (c *Coin) Add() error {
func (c *Coin) Edit() error { func (c *Coin) Edit() error {
return models.EditCoin(c.Id, map[string]interface{}{ return models.EditCoin(c.Id, map[string]interface{}{
"name": c.Name, "name": c.Name,
"symbol": c.Symbol, "nickname": c.Nickname,
"icon": c.Icon, "icon": c.Icon,
"introduce": c.Introduce, "introduce": c.Introduce,
"official": c.Official, "official": c.Official,
...@@ -184,8 +184,8 @@ func (c *Coin) getMaps() (map[string]interface{}) { ...@@ -184,8 +184,8 @@ func (c *Coin) getMaps() (map[string]interface{}) {
maps["id"] = c.Id maps["id"] = c.Id
} }
if c.Symbol != "" { if c.Name != "" {
maps["symbol"] = c.Symbol maps["name"] = c.Name
} }
if c.Chain != "" { if c.Chain != "" {
maps["chain"] = c.Chain maps["chain"] = c.Chain
......
...@@ -14,7 +14,7 @@ type WalletCoinRelation struct { ...@@ -14,7 +14,7 @@ type WalletCoinRelation struct {
} }
type CoinCondition struct { type CoinCondition struct {
Symbol string Name string
Chain string Chain string
Platform string Platform string
} }
...@@ -82,8 +82,8 @@ func (c *WalletCoinRelation) getMaps() (map[string]interface{}) { ...@@ -82,8 +82,8 @@ func (c *WalletCoinRelation) getMaps() (map[string]interface{}) {
} }
var condition = make(map[string]interface{}) var condition = make(map[string]interface{})
if c.CoinCondition.Symbol != "" { if c.CoinCondition.Name != "" {
condition["name"] = c.CoinCondition.Symbol condition["name"] = c.CoinCondition.Name
} }
if c.CoinCondition.Chain != "" { if c.CoinCondition.Chain != "" {
......
...@@ -3,8 +3,8 @@ package validate_service ...@@ -3,8 +3,8 @@ package validate_service
import "encoding/json" import "encoding/json"
type Coin struct { type Coin struct {
Symbol string `json:"symbol" validate:"required"` Name string `json:"name" validate:"required"`
Name json.RawMessage `json:"name" validate:"required"` Nickname json.RawMessage `json:"nickname" validate:"required"`
Icon string `json:"icon" validate:"required"` Icon string `json:"icon" validate:"required"`
Introduce json.RawMessage `json:"introduce" validate:"required"` Introduce json.RawMessage `json:"introduce" validate:"required"`
......
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