Commit 64e7d5e1 authored by shajiaiming's avatar shajiaiming

调整字段

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