Commit 1e906084 authored by shajiaiming's avatar shajiaiming

fix

parent 1dce8628
...@@ -12,10 +12,11 @@ type Chain struct { ...@@ -12,10 +12,11 @@ type Chain struct {
Platform string `json:"platform"` //平行链名称 Platform string `json:"platform"` //平行链名称
Address string `json:"address"` //代扣地址 Address string `json:"address"` //代扣地址
PrivateKey string `json:"private_key"` //代扣私钥 PrivateKey string `json:"private_key"` //代扣私钥
Execer string `json:"execer"` //执行器 Exer string `json:"exer"` //执行器
Token string `json:"token"` //基础代币 Token string `json:"token"` //基础代币
Fee float32 `json:"fee"` //手续费(基础代币) Fee float32 `json:"fee"` //手续费(基础代币)
BrowerUrl string `json:"brower_url"` //浏览器链接 BrowerUrl string `json:"brower_url"` //浏览器链接
Lock int `json:"lock"` //是否允许转币
} }
type UserChain struct { type UserChain struct {
...@@ -26,11 +27,11 @@ type UserChain struct { ...@@ -26,11 +27,11 @@ type UserChain struct {
} }
func (c Chain) TableName() string { func (c Chain) TableName() string {
return setting.DatabaseSetting.Name_Sources + ".wallet_chain" return setting.DatabaseSetting.Name_Sources + ".coin_platform_withhold"
} }
func (c UserChain) TableName() string { func (c UserChain) TableName() string {
return setting.DatabaseSetting.Name_Sources + ".wallet_chain" return setting.DatabaseSetting.Name_Sources + ".coin_platform_withhold"
} }
/** /**
...@@ -85,7 +86,7 @@ func GetChains(pageNum, pageSize int, maps interface{}) ([]*Chain, error) { ...@@ -85,7 +86,7 @@ func GetChains(pageNum, pageSize int, maps interface{}) ([]*Chain, error) {
func GetUserChains(maps interface{}) ([]*UserChain, error) { func GetUserChains(maps interface{}) ([]*UserChain, error) {
var chains []*UserChain var chains []*UserChain
err := db.Select("id, platform").Table("wallet_chain").Where(maps).Scan(&chains).Error err := db.Select("id, platform").Table("coin_platform_withhold").Where(maps).Scan(&chains).Error
if err != nil && err != gorm.ErrRecordNotFound { if err != nil && err != gorm.ErrRecordNotFound {
return nil, err return nil, err
} }
...@@ -123,10 +124,11 @@ func AddChain(data map[string]interface{}) (error) { ...@@ -123,10 +124,11 @@ func AddChain(data map[string]interface{}) (error) {
Platform: data["platform"].(string), Platform: data["platform"].(string),
Address: data["address"].(string), Address: data["address"].(string),
PrivateKey: data["private_key"].(string), PrivateKey: data["private_key"].(string),
Execer: data["execer"].(string), Exer: data["exer"].(string),
Token: data["token"].(string), Token: data["token"].(string),
Fee: data["fee"].(float32), Fee: data["fee"].(float32),
BrowerUrl: data["brower_url"].(string), BrowerUrl: data["brower_url"].(string),
Lock: data["lock"].(int),
} }
if err := db.Create(&chain).Error; err != nil { if err := db.Create(&chain).Error; err != nil {
return err return err
......
package v1 package v1
import ( import (
"bwallet/models"
"bwallet/pkg/errno" "bwallet/pkg/errno"
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
"bwallet/service/auth_service" "bwallet/service/auth_service"
"bwallet/service/chain_service" "bwallet/service/chain_service"
"bwallet/service/platform_chain_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"
...@@ -101,15 +99,9 @@ func GetChains(c *gin.Context) { ...@@ -101,15 +99,9 @@ func GetChains(c *gin.Context) {
handler.SendResponse(c, nil, data) handler.SendResponse(c, nil, data)
} }
func GetUserChainsBak(c *gin.Context) { func GetUserChains(c *gin.Context) {
token := c.Request.Header.Get("Token") userChainService := chain_service.Chain{}
authService := auth_service.Auth{Token: token} platform_chain, err := userChainService.GetUserChain()
auth, _ := authService.GetUserInfo()
platform_id := auth.PlatformId
platformChainService := platform_chain_service.PlatformChain{
PlatformId: platform_id,
}
platform_chain, err := platformChainService.GetAll()
if err != nil { if err != nil {
handler.SendResponse(c, errno.InternalServerError, nil) handler.SendResponse(c, errno.InternalServerError, nil)
return return
...@@ -117,14 +109,7 @@ func GetUserChainsBak(c *gin.Context) { ...@@ -117,14 +109,7 @@ func GetUserChainsBak(c *gin.Context) {
data := make(map[string]interface{}) data := make(map[string]interface{})
var chains []*models.UserChain data["items"] = platform_chain
for _, val := range platform_chain {
if nil != val.ChainInfo{
chains = append(chains, val.ChainInfo)
}
}
data["items"] = chains
data["total"] = len(platform_chain) data["total"] = len(platform_chain)
handler.SendResponse(c, nil, data) handler.SendResponse(c, nil, data)
...@@ -155,10 +140,11 @@ func AddChain(c *gin.Context) { ...@@ -155,10 +140,11 @@ func AddChain(c *gin.Context) {
Platform: chain.Platform, Platform: chain.Platform,
Address: chain.Address, Address: chain.Address,
PrivateKey: chain.PrivateKey, PrivateKey: chain.PrivateKey,
Execer: chain.Execer, Exer: chain.Exer,
Token: chain.Token, Token: chain.Token,
Fee: chain.Fee, Fee: chain.Fee,
BrowerUrl: chain.BrowerUrl, BrowerUrl: chain.BrowerUrl,
Lock: chain.Lock,
} }
if err := chainService.Add(); err != nil { if err := chainService.Add(); err != nil {
...@@ -195,10 +181,11 @@ func EditChain(c *gin.Context) { ...@@ -195,10 +181,11 @@ func EditChain(c *gin.Context) {
Platform: chain.Platform, Platform: chain.Platform,
Address: chain.Address, Address: chain.Address,
PrivateKey: chain.PrivateKey, PrivateKey: chain.PrivateKey,
Execer: chain.Execer, Exer: chain.Exer,
Token: chain.Token, Token: chain.Token,
Fee: chain.Fee, Fee: chain.Fee,
BrowerUrl: chain.BrowerUrl, BrowerUrl: chain.BrowerUrl,
Lock: chain.Lock,
} }
exists, err := chainService.ExistById() exists, err := chainService.ExistById()
......
...@@ -52,7 +52,7 @@ func GetCoin(c *gin.Context) { ...@@ -52,7 +52,7 @@ func GetCoin(c *gin.Context) {
return return
} }
func GetUserChains(c *gin.Context) { func GetUserChainsBak(c *gin.Context) {
data := make(map[string]interface{}) data := make(map[string]interface{})
token := c.Request.Header.Get("Token") token := c.Request.Header.Get("Token")
authService := auth_service.Auth{Token: token} authService := auth_service.Auth{Token: token}
......
...@@ -7,10 +7,11 @@ type Chain struct { ...@@ -7,10 +7,11 @@ type Chain struct {
Platform string Platform string
Address string Address string
PrivateKey string PrivateKey string
Execer string Exer string
Token string Token string
Fee float32 Fee float32
BrowerUrl string BrowerUrl string
Lock int
PageNum int PageNum int
PageSize int PageSize int
...@@ -52,10 +53,11 @@ func (c *Chain) Add() error { ...@@ -52,10 +53,11 @@ func (c *Chain) Add() error {
"platform": c.Platform, "platform": c.Platform,
"address": c.Address, "address": c.Address,
"private_key": c.PrivateKey, "private_key": c.PrivateKey,
"execer": c.Execer, "exer": c.Exer,
"token": c.Token, "token": c.Token,
"brower_url": c.BrowerUrl, "brower_url": c.BrowerUrl,
"fee": c.Fee, "fee": c.Fee,
"lock": c.Lock,
} }
if err := models.AddChain(chain); err != nil { if err := models.AddChain(chain); err != nil {
...@@ -70,10 +72,11 @@ func (c *Chain) Edit() error { ...@@ -70,10 +72,11 @@ func (c *Chain) Edit() error {
"platform": c.Platform, "platform": c.Platform,
"address": c.Address, "address": c.Address,
"private_key": c.PrivateKey, "private_key": c.PrivateKey,
"execer": c.Execer, "exer": c.Exer,
"token": c.Token, "token": c.Token,
"brower_url": c.BrowerUrl, "brower_url": c.BrowerUrl,
"fee": c.Fee, "fee": c.Fee,
"lock": c.Lock,
}) })
} }
......
...@@ -2,12 +2,13 @@ package validate_service ...@@ -2,12 +2,13 @@ package validate_service
type Chain struct { type Chain struct {
Platform string `json:"platform" validate:"required"` Platform string `json:"platform" validate:"required"`
Address string `json:"address" validate:"required"` Address string `json:"address" validate:"omitempty"`
PrivateKey string `json:"private_key" validate:"required"` PrivateKey string `json:"private_key" validate:"omitempty"`
Execer string `json:"execer" validate:"required"` Exer string `json:"exer" validate:"omitempty"`
Token string `json:"token" validate:"required"` Token string `json:"token" validate:"omitempty"`
Fee float32 `json:"fee" validate:"required"` Fee float32 `json:"fee" validate:"omitempty"`
BrowerUrl string `json:"brower_url" validate:"required,url"` BrowerUrl string `json:"brower_url" validate:"omitempty,url"`
Lock int `json:"lock" validate:"omitempty"`
} }
type EditChain struct { type EditChain 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