Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
1e906084
Commit
1e906084
authored
Apr 13, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
1dce8628
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
36 deletions
+29
-36
chain.go
models/chain.go
+7
-5
chain.go
routers/api/v1/chain.go
+8
-21
coin.go
routers/api/v1/coin.go
+1
-1
chain.go
service/chain_service/chain.go
+6
-3
chain.go
validate_service/chain.go
+7
-6
No files found.
models/chain.go
View file @
1e906084
...
@@ -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"`
//代扣私钥
Exe
cer
string
`json:"execer"`
//执行器
Exe
r
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
),
Exe
cer
:
data
[
"exec
er"
]
.
(
string
),
Exe
r
:
data
[
"ex
er"
]
.
(
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
...
...
routers/api/v1/chain.go
View file @
1e906084
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
,
Exe
cer
:
chain
.
Exec
er
,
Exe
r
:
chain
.
Ex
er
,
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
,
Exe
cer
:
chain
.
Exec
er
,
Exe
r
:
chain
.
Ex
er
,
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
()
...
...
routers/api/v1/coin.go
View file @
1e906084
...
@@ -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
GetUserChains
Bak
(
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
}
...
...
service/chain_service/chain.go
View file @
1e906084
...
@@ -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
Exe
cer
string
Exe
r
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
,
"exe
cer"
:
c
.
Exec
er
,
"exe
r"
:
c
.
Ex
er
,
"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
,
"exe
cer"
:
c
.
Exec
er
,
"exe
r"
:
c
.
Ex
er
,
"token"
:
c
.
Token
,
"token"
:
c
.
Token
,
"brower_url"
:
c
.
BrowerUrl
,
"brower_url"
:
c
.
BrowerUrl
,
"fee"
:
c
.
Fee
,
"fee"
:
c
.
Fee
,
"lock"
:
c
.
Lock
,
})
})
}
}
...
...
validate_service/chain.go
View file @
1e906084
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment