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
2f53a119
Commit
2f53a119
authored
Feb 13, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
81c137f5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
49 deletions
+52
-49
errno.go
pkg/errno/errno.go
+1
-0
coin.go
routers/api/v1/coin.go
+44
-38
wallet_coin_relation.go
routers/api/v1/wallet_coin_relation.go
+0
-8
router.go
routers/router.go
+7
-3
No files found.
pkg/errno/errno.go
View file @
2f53a119
...
@@ -74,6 +74,7 @@ var (
...
@@ -74,6 +74,7 @@ var (
ErrDeleteCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin delete error."
}
ErrDeleteCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin delete error."
}
ErrExistCoin
=
&
Errno
{
Code
:
20103
,
Message
:
"The coin already exists."
}
ErrExistCoin
=
&
Errno
{
Code
:
20103
,
Message
:
"The coin already exists."
}
ErrNotExistCoin
=
&
Errno
{
Code
:
20104
,
Message
:
"The coin not exists."
}
ErrNotExistCoin
=
&
Errno
{
Code
:
20104
,
Message
:
"The coin not exists."
}
ErrAuthCoin
=
&
Errno
{
Code
:
20105
,
Message
:
"The coin auth error."
}
// recommend coin errors
// recommend coin errors
ErrRecommendCoinNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The recommend coin was not found."
}
ErrRecommendCoinNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The recommend coin was not found."
}
...
...
routers/api/v1/coin.go
View file @
2f53a119
...
@@ -51,6 +51,17 @@ func GetCoin(c *gin.Context) {
...
@@ -51,6 +51,17 @@ func GetCoin(c *gin.Context) {
}
}
func
GetCoins
(
c
*
gin
.
Context
)
{
func
GetCoins
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
valid
:=
validation
.
Validation
{}
valid
:=
validation
.
Validation
{}
name
:=
""
name
:=
""
...
@@ -68,19 +79,12 @@ func GetCoins(c *gin.Context) {
...
@@ -68,19 +79,12 @@ func GetCoins(c *gin.Context) {
chain
=
c
.
Query
(
"chain"
)
chain
=
c
.
Query
(
"chain"
)
}
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
var
platform_id
int
var
platform_id
int
platform_id
=
auth
.
PlatformId
if
arg
:=
c
.
Query
(
"platform_id"
);
arg
!=
""
{
if
(
"administrator"
==
group
)
{
platform_id
=
com
.
StrTo
(
c
.
DefaultQuery
(
"platform_id"
,
"1"
))
.
MustInt
()
if
arg
:=
c
.
Query
(
"platform_id"
);
arg
!=
""
{
platform_id
=
com
.
StrTo
(
c
.
Query
(
"platform_id"
))
.
MustInt
()
}
}
}
if
valid
.
HasErrors
()
{
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
return
...
@@ -115,6 +119,16 @@ func GetCoins(c *gin.Context) {
...
@@ -115,6 +119,16 @@ func GetCoins(c *gin.Context) {
}
}
func
AddCoin
(
c
*
gin
.
Context
)
{
func
AddCoin
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
coin
:=
validate_service
.
Coin
{}
coin
:=
validate_service
.
Coin
{}
c
.
ShouldBindJSON
(
&
coin
)
c
.
ShouldBindJSON
(
&
coin
)
//方法一
//方法一
...
@@ -125,19 +139,6 @@ func AddCoin(c *gin.Context) {
...
@@ -125,19 +139,6 @@ func AddCoin(c *gin.Context) {
}
}
}
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
var
platform_id
int
platform_id
=
auth
.
PlatformId
if
(
"administrator"
==
group
)
{
if
coin
.
PlatformId
!=
0
{
platform_id
=
coin
.
PlatformId
}
}
coinService
:=
coin_service
.
Coin
{
coinService
:=
coin_service
.
Coin
{
Sid
:
coin
.
Sid
,
Sid
:
coin
.
Sid
,
Name
:
coin
.
Name
,
Name
:
coin
.
Name
,
...
@@ -155,7 +156,7 @@ func AddCoin(c *gin.Context) {
...
@@ -155,7 +156,7 @@ func AddCoin(c *gin.Context) {
Decimals
:
coin
.
Decimals
,
Decimals
:
coin
.
Decimals
,
Address
:
coin
.
Address
,
Address
:
coin
.
Address
,
Treaty
:
coin
.
Treaty
,
Treaty
:
coin
.
Treaty
,
PlatformId
:
platform_i
d
,
PlatformId
:
coin
.
PlatformI
d
,
}
}
if
err
:=
coinService
.
Add
();
err
!=
nil
{
if
err
:=
coinService
.
Add
();
err
!=
nil
{
...
@@ -212,9 +213,15 @@ func EditCoin(c *gin.Context) {
...
@@ -212,9 +213,15 @@ func EditCoin(c *gin.Context) {
authService
:=
auth_service
.
Auth
{
Token
:
token
}
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
group
:=
auth
.
Group
coin_model
:=
coin_service
.
Coin
{
Id
:
coin
.
Id
}
coin_exist
,
_
:=
coin_model
.
Get
()
if
coin
.
PlatformId
!=
coin_exist
.
PlatformId
{
handler
.
SendResponse
(
c
,
errno
.
ErrAuthCoin
,
nil
)
return
}
if
(
"administrator"
!=
group
)
{
if
(
"administrator"
!=
group
)
{
coin_model
:=
coin_service
.
Coin
{
Id
:
coin
.
Id
}
coin
,
_
:=
coin_model
.
Get
()
if
coin
.
PlatformId
!=
auth
.
PlatformId
{
if
coin
.
PlatformId
!=
auth
.
PlatformId
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserTokenIncorrect
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
ErrUserTokenIncorrect
,
nil
)
return
return
...
@@ -229,6 +236,17 @@ func EditCoin(c *gin.Context) {
...
@@ -229,6 +236,17 @@ func EditCoin(c *gin.Context) {
}
}
func
DeleteCoin
(
c
*
gin
.
Context
)
{
func
DeleteCoin
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
valid
:=
validation
.
Validation
{}
valid
:=
validation
.
Validation
{}
id
:=
com
.
StrTo
(
c
.
Param
(
"id"
))
.
MustInt
()
id
:=
com
.
StrTo
(
c
.
Param
(
"id"
))
.
MustInt
()
valid
.
Min
(
id
,
1
,
"id"
)
.
Message
(
"ID必须大于0"
)
valid
.
Min
(
id
,
1
,
"id"
)
.
Message
(
"ID必须大于0"
)
...
@@ -250,18 +268,6 @@ func DeleteCoin(c *gin.Context) {
...
@@ -250,18 +268,6 @@ func DeleteCoin(c *gin.Context) {
return
return
}
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
if
(
"administrator"
!=
group
)
{
coin
,
_
:=
coinService
.
Get
()
if
coin
.
PlatformId
!=
auth
.
PlatformId
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
}
err
=
coinService
.
Delete
()
err
=
coinService
.
Delete
()
if
err
!=
nil
{
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrDeleteCoin
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
ErrDeleteCoin
,
nil
)
...
...
routers/api/v1/wallet_coin_relation.go
View file @
2f53a119
...
@@ -51,14 +51,6 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
...
@@ -51,14 +51,6 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
PageSize
:
util
.
GetLimit
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
}
/*
_, err := walletCoinRelateionService.Count()
if err != nil {
handler.SendResponse(c, errno.ErrCountWalletCoinRelation, nil)
return
}
*/
coins
,
err
:=
walletCoinRelateionService
.
GetAll
()
coins
,
err
:=
walletCoinRelateionService
.
GetAll
()
if
err
!=
nil
{
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
...
...
routers/router.go
View file @
2f53a119
...
@@ -29,13 +29,17 @@ func InitRouter() *gin.Engine {
...
@@ -29,13 +29,17 @@ func InitRouter() *gin.Engine {
{
{
//api.POST("/upload",v1.Upload)
//api.POST("/upload",v1.Upload)
api
.
GET
(
"/coins"
,
v1
.
Get
WalletCoinRelationCoinRelatio
ns
)
api
.
GET
(
"/coins"
,
v1
.
Get
Coi
ns
)
api
.
POST
(
"/coin"
,
v1
.
Add
WalletCoinRelationCoinRelatio
n
)
api
.
POST
(
"/coin"
,
v1
.
Add
Coi
n
)
api
.
GET
(
"/coin/:id"
,
v1
.
GetCoin
)
api
.
GET
(
"/coin/:id"
,
v1
.
GetCoin
)
api
.
PUT
(
"/coin"
,
v1
.
EditCoin
)
api
.
PUT
(
"/coin"
,
v1
.
EditCoin
)
api
.
DELETE
(
"/coin
"
,
v1
.
DeleteWalletCoinRelationCoinRelatio
n
)
api
.
DELETE
(
"/coin
/:id"
,
v1
.
DeleteCoi
n
)
api
.
GET
(
"/primary-chains"
,
v1
.
GetPrimaryChains
)
api
.
GET
(
"/primary-chains"
,
v1
.
GetPrimaryChains
)
api
.
GET
(
"/types"
,
v1
.
GetTypes
)
api
.
GET
(
"/types"
,
v1
.
GetTypes
)
api
.
GET
(
"/coin-relation"
,
v1
.
GetWalletCoinRelationCoinRelations
)
api
.
POST
(
"/coin-relation"
,
v1
.
AddWalletCoinRelationCoinRelation
)
api
.
DELETE
(
"/coin-relation"
,
v1
.
DeleteWalletCoinRelationCoinRelation
)
//api.GET("/get-platform", v1.GetCoinsPlatform)
//api.GET("/get-platform", v1.GetCoinsPlatform)
api
.
GET
(
"/wallets"
,
v1
.
GetWallets
)
api
.
GET
(
"/wallets"
,
v1
.
GetWallets
)
...
...
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