Commit 185b9a0f authored by shajiaming's avatar shajiaming

fix

parent 45ff7424
......@@ -114,9 +114,9 @@ func AddCoin(data map[string]interface{}) (error) {
coin := Coin{
Sid: data["sid"].(string),
Name: data["name"].(string),
Nickname: data["nickname"].(string),
Nickname: "{\"ja\": \"\", \"en-US\": \"\", \"zh-CN\": \"ICON\"}",
Icon: data["icon"].(string),
Introduce: data["introduce"].(string),
Introduce: "{\"ja\": \"\", \"en-US\": \"\", \"zh-CN\": \"ICON\"}",
Official: data["official"].(string),
Paper: data["paper"].(string),
Platform: data["platform"].(string),
......
......@@ -7,6 +7,7 @@ import (
"bwallet/service/auth_service"
"bwallet/service/coin_service"
"bwallet/validate_service"
"fmt"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
......@@ -170,7 +171,6 @@ func GetCoins(c *gin.Context) {
func AddCoin(c *gin.Context) {
coin := validate_service.Coin{}
c.ShouldBindJSON(&coin)
//方法一
if ok, errors := validateCoinInputs(coin); !ok {
for _, err := range errors {
......@@ -218,11 +218,11 @@ func AddCoin(c *gin.Context) {
}
func EditCoin(c *gin.Context) {
wallet := validate_service.EditCoin{}
c.ShouldBindJSON(&wallet)
coin := validate_service.EditCoin{}
c.ShouldBindJSON(&coin)
//方法一
if ok, errors := validateCoinInputs(wallet); !ok {
if ok, errors := validateCoinInputs(coin); !ok {
for _, err := range errors {
handler.SendResponse(c, errno.ErrBind, strings.Join(err, " "))
return
......@@ -230,23 +230,23 @@ func EditCoin(c *gin.Context) {
}
coinService := coin_service.Coin{
Id: wallet.Id,
Sid: wallet.Sid,
Name: wallet.Name,
Nickname: wallet.Nickname,
Icon: wallet.Icon,
Introduce: wallet.Introduce,
Official: wallet.Official,
Paper: wallet.Paper,
Platform: wallet.Platform,
Chain: wallet.Chain,
Release: wallet.Release,
AreaSearch: wallet.AreaSearch,
PublishCount: wallet.PublishCount,
CirculateCount: wallet.CirculateCount,
Decimals: wallet.Decimals,
Address: wallet.Address,
Treaty: wallet.Treaty,
Id: coin.Id,
Sid: coin.Sid,
Name: coin.Name,
Nickname: coin.Nickname,
Icon: coin.Icon,
Introduce: coin.Introduce,
Official: coin.Official,
Paper: coin.Paper,
Platform: coin.Platform,
Chain: coin.Chain,
Release: coin.Release,
AreaSearch: coin.AreaSearch,
PublishCount: coin.PublishCount,
CirculateCount: coin.CirculateCount,
Decimals: coin.Decimals,
Address: coin.Address,
Treaty: coin.Treaty,
}
exists, err := coinService.ExistById()
......@@ -264,7 +264,7 @@ func EditCoin(c *gin.Context) {
auth, _ := authService.GetUserInfo()
group := auth.Group
if ("administrator" != group) {
coin_model := coin_service.Coin{Id: wallet.Id}
coin_model := coin_service.Coin{Id: coin.Id}
coin, _ := coin_model.Get()
if coin.PlatformId != auth.PlatformId {
handler.SendResponse(c, errno.ErrUserTokenIncorrect, nil)
......
......@@ -9,17 +9,14 @@ type Coin struct {
Id int
Sid string
Name string
OptionalName string
Nickname string
Icon string
Introduce string
Official string
Paper string
Exchange int
Platform string
Chain string
Release string
Price float64
AreaSearch string
PublishCount float64
CirculateCount float64
......@@ -82,17 +79,14 @@ func (c *Coin) Add() error {
coin := map[string]interface{}{
"sid": c.Sid,
"name": c.Name,
"optional_name": c.OptionalName,
"nickname": c.Nickname,
"icon": c.Icon,
"introduce": c.Introduce,
"official": c.Official,
"paper": c.Paper,
"exchange": c.Exchange,
"platform": c.Platform,
"chain": c.Chain,
"release": c.Release,
"price": c.Price,
"area_search": c.AreaSearch,
"publish_count": c.PublishCount,
"circulate_count": c.CirculateCount,
......@@ -118,17 +112,14 @@ func (c *Coin) Edit() error {
return models.EditCoin(c.Id, map[string]interface{}{
"sid": c.Sid,
"name": c.Name,
"optional_name": c.OptionalName,
"nickname": c.Nickname,
"icon": c.Icon,
"introduce": c.Introduce,
"official": c.Official,
"paper": c.Paper,
"exchange": c.Exchange,
"platform": c.Platform,
"chain": c.Chain,
"release": c.Release,
"price": c.Price,
"area_search": c.AreaSearch,
"publish_count": c.PublishCount,
"circulate_count": c.CirculateCount,
......
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