Commit 185b9a0f authored by shajiaming's avatar shajiaming

fix

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