Commit 1e906084 authored by shajiaiming's avatar shajiaiming

fix

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