Commit 64e7d5e1 authored by shajiaiming's avatar shajiaiming

调整字段

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