Commit a7e14536 authored by shajiaiming's avatar shajiaiming

修复添加币种权限

parent aa31e5ee
package models package models
import ( import (
"github.com/jinzhu/gorm"
"bwallet/pkg/setting" "bwallet/pkg/setting"
"github.com/jinzhu/gorm"
) )
type Wallet struct { type Wallet struct {
...@@ -11,9 +11,9 @@ type Wallet struct { ...@@ -11,9 +11,9 @@ type Wallet struct {
Name string `gorm:"size:255;not null;" json:"name"` Name string `gorm:"size:255;not null;" json:"name"`
DownloadUrl string `gorm:"not null;" json:"download_url"` DownloadUrl string `gorm:"not null;" json:"download_url"`
Introduce string `gorm:"not null;" json:"introduce"` Introduce string `gorm:"not null;" json:"introduce"`
//ChainId int `gorm:"not null;default:0" json:"chain_id"` ChainId int `gorm:"default:0" json:"chain_id,omitempty"`
//IssueCharge float32 `gorm:"not null;default:0.00" json:"issue_charge"` IssueCharge float32 `gorm:"default:0.00" json:"issue_charge"`
//ChargeUnit string `gorm:"not null;default:BTY" json:"charge_unit"` ChargeUnit string `gorm:"default:BTY" json:"charge_unit"`
} }
func (w Wallet) TableName() string { func (w Wallet) TableName() string {
...@@ -73,9 +73,9 @@ func AddWallet(data map[string]interface{}) (error) { ...@@ -73,9 +73,9 @@ func AddWallet(data map[string]interface{}) (error) {
Name: data["name"].(string), Name: data["name"].(string),
DownloadUrl: data["download_url"].(string), DownloadUrl: data["download_url"].(string),
Introduce: data["introduce"].(string), Introduce: data["introduce"].(string),
//ChargeUnit: data["charge_unit"].(string), ChargeUnit: data["charge_unit"].(string),
//IssueCharge: data["issue_charge"].(float32), IssueCharge: data["issue_charge"].(float32),
//ChainId: data["chain_id"].(int), ChainId: data["chain_id"].(int),
} }
if err := db.Create(&wallet).Error; err != nil { if err := db.Create(&wallet).Error; err != nil {
return err return err
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
"bwallet/service/chain_service" "bwallet/service/chain_service"
"bwallet/service/wallet_service"
"bwallet/validate_service" "bwallet/validate_service"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/astaxie/beego/validation" "github.com/astaxie/beego/validation"
...@@ -97,7 +98,29 @@ func GetChains(c *gin.Context) { ...@@ -97,7 +98,29 @@ func GetChains(c *gin.Context) {
} }
func GetUserChains(c *gin.Context) { func GetUserChains(c *gin.Context) {
token := c.Request.Header.Get("Token")
user, _ := util.ParseToken(token)
group := user.UserInfo.Group
userChainService := chain_service.Chain{} userChainService := chain_service.Chain{}
if ("administrator" != group) {
walletService := wallet_service.Wallet{Id: user.UserInfo.PlatformId}
exists, err := walletService.ExistById()
if err != nil {
handler.SendResponse(c, errno.ErrWalletNotFound, nil)
return
}
if (!exists) {
handler.SendResponse(c, errno.ErrWalletNotFound, nil)
return
}
wallet, err := walletService.Get()
userChainService = chain_service.Chain{
ID:wallet.ChainId,
}
}
platform_chain, err := userChainService.GetUserChain() platform_chain, err := userChainService.GetUserChain()
if err != nil { if err != nil {
handler.SendResponse(c, errno.InternalServerError, nil) handler.SendResponse(c, errno.InternalServerError, nil)
......
...@@ -182,9 +182,9 @@ func AddWallet(c *gin.Context) { ...@@ -182,9 +182,9 @@ func AddWallet(c *gin.Context) {
Name: wallet.Name, Name: wallet.Name,
DownloadUrl: wallet.DownloadUrl, DownloadUrl: wallet.DownloadUrl,
Introduce: wallet.Introduce, Introduce: wallet.Introduce,
//ChainId: wallet.ChainId, ChainId: wallet.ChainId,
//IssueCharge: wallet.IssueCharge, IssueCharge: wallet.IssueCharge,
//ChargeUnit: wallet.ChargeUnit, ChargeUnit: wallet.ChargeUnit,
} }
if err := walletService.Add(); err != nil { if err := walletService.Add(); err != nil {
......
...@@ -9,9 +9,9 @@ type Wallet struct { ...@@ -9,9 +9,9 @@ type Wallet struct {
Name string Name string
DownloadUrl string DownloadUrl string
Introduce string Introduce string
//ChainId int ChainId int
//IssueCharge float32 IssueCharge float32
//ChargeUnit string ChargeUnit string
PageNum int PageNum int
PageSize int PageSize int
...@@ -43,9 +43,9 @@ func (w *Wallet) Add() error { ...@@ -43,9 +43,9 @@ func (w *Wallet) Add() error {
"name": w.Name, "name": w.Name,
"download_url": w.DownloadUrl, "download_url": w.DownloadUrl,
"introduce": w.Introduce, "introduce": w.Introduce,
//"chain_id": w.ChainId, "chain_id": w.ChainId,
//"charge_unit": w.ChargeUnit, "charge_unit": w.ChargeUnit,
//"issue_charge": w.IssueCharge, "issue_charge": w.IssueCharge,
} }
if err := models.AddWallet(wallet); err != nil { if err := models.AddWallet(wallet); err != nil {
...@@ -60,9 +60,9 @@ func (w *Wallet) Edit() error { ...@@ -60,9 +60,9 @@ func (w *Wallet) Edit() error {
"name": w.Name, "name": w.Name,
"download_url": w.DownloadUrl, "download_url": w.DownloadUrl,
"introduce": w.Introduce, "introduce": w.Introduce,
//"chain_id": w.ChainId, "chain_id": w.ChainId,
//"issue_charge": w.IssueCharge, "issue_charge": w.IssueCharge,
//"charge_unit": w.ChargeUnit, "charge_unit": w.ChargeUnit,
}) })
} }
......
...@@ -4,9 +4,9 @@ type Wallet struct { ...@@ -4,9 +4,9 @@ type Wallet struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
DownloadUrl string `json:"download_url" validate:"required,url"` DownloadUrl string `json:"download_url" validate:"required,url"`
Introduce string `json:"introduce" validate:"required"` Introduce string `json:"introduce" validate:"required"`
//ChainId int `json:"chain_id" validate:"required"` ChainId int `json:"chain_id ,omitempty"`
//IssueCharge float32 `json:"issue_charge" validate:"required"` IssueCharge float32 `json:"issue_charge ,omitempty"`
//ChargeUnit string `json:"charge_unit" validate:"required"` ChargeUnit string `json:"charge_unit ,omitempty"`
} }
type EditWallet struct { type EditWallet struct {
......
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