Commit a7e14536 authored by shajiaiming's avatar shajiaiming

修复添加币种权限

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