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
5232ac11
Commit
5232ac11
authored
Mar 04, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
入参验证
parent
371d62e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
44 deletions
+69
-44
wallet_coin_relation.go
routers/api/v1/wallet_coin_relation.go
+58
-31
coin.go
service/coin_service/coin.go
+0
-2
coin.go
validate_service/coin.go
+9
-9
wallet_coin_relation.go
validate_service/wallet_coin_relation.go
+2
-2
No files found.
routers/api/v1/wallet_coin_relation.go
View file @
5232ac11
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"bwallet/validate_service"
"bwallet/validate_service"
"github.com/Unknwon/com"
"github.com/Unknwon/com"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"strconv"
"strings"
"strings"
)
)
...
@@ -90,41 +91,67 @@ func AddWalletCoinRelationCoinRelation(c *gin.Context) {
...
@@ -90,41 +91,67 @@ func AddWalletCoinRelationCoinRelation(c *gin.Context) {
}
}
}
}
coinService
:=
coin_service
.
Coin
{
for
_
,
id
:=
range
strings
.
Split
(
coin_relation
.
CoinId
,
","
)
{
Id
:
coin_relation
.
CoinId
,
if
id
==
""
{
}
continue
exists
,
err
:=
coinService
.
ExistById
()
}
if
err
!=
nil
{
coin_id
,
err
:=
strconv
.
Atoi
(
id
)
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
if
(
nil
!=
err
)
{
return
continue
}
}
if
!
exists
{
coinService
:=
coin_service
.
Coin
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
Id
:
coin_id
,
return
}
exists
,
err
:=
coinService
.
ExistById
()
if
err
!=
nil
||
!
exists
{
continue
}
relationService
:=
wallet_coin_relation_service
.
WalletCoinRelation
{
PlatformId
:
coin_relation
.
PlatformId
,
CoinId
:
coin_id
,
}
relationService
.
Delete
()
relationService
.
Add
()
}
}
relationService
:=
wallet_coin_relation_service
.
WalletCoinRelation
{
handler
.
SendResponse
(
c
,
nil
,
nil
)
CoinId
:
coin_relation
.
CoinId
,
/*
PlatformId
:
coin_relation
.
PlatformId
,
coinService := coin_service.Coin{
PageNum
:
util
.
GetPage
(
c
),
Id: coin_relation.CoinId,
PageSize
:
util
.
GetLimit
(
c
),
}
}
exists, err := coinService.ExistById()
if err != nil {
handler.SendResponse(c, errno.ErrCoinNotFound, nil)
return
}
if !exists {
handler.SendResponse(c, errno.ErrCoinNotFound, nil)
return
}
coins
,
err
:=
relationService
.
GetAll
()
relationService := wallet_coin_relation_service.WalletCoinRelation{
if
err
!=
nil
{
CoinId: coin_relation.CoinId,
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
PlatformId: coin_relation.PlatformId,
return
PageNum: util.GetPage(c),
}
PageSize: util.GetLimit(c),
if
0
!=
len
(
coins
)
{
}
handler
.
SendResponse
(
c
,
errno
.
ErrExistCoin
,
nil
)
return
}
if
err
:=
relationService
.
Add
();
err
!=
nil
{
coins, err := relationService.GetAll()
handler
.
SendResponse
(
c
,
errno
.
ErrAddCoin
,
nil
)
if err != nil {
return
handler.SendResponse(c, errno.InternalServerError, nil)
}
return
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
if 0 != len(coins) {
handler.SendResponse(c, errno.ErrExistCoin, nil)
return
}
if err := relationService.Add(); err != nil {
handler.SendResponse(c, errno.ErrAddCoin, nil)
return
}
handler.SendResponse(c, nil, nil)
*/
}
}
/**
/**
...
...
service/coin_service/coin.go
View file @
5232ac11
...
@@ -3,8 +3,6 @@ package coin_service
...
@@ -3,8 +3,6 @@ package coin_service
import
(
import
(
"bwallet/models"
"bwallet/models"
"encoding/json"
"encoding/json"
//"encoding/json"
)
)
type
Coin
struct
{
type
Coin
struct
{
...
...
validate_service/coin.go
View file @
5232ac11
...
@@ -5,20 +5,20 @@ import "encoding/json"
...
@@ -5,20 +5,20 @@ import "encoding/json"
type
Coin
struct
{
type
Coin
struct
{
Name
string
`json:"name" validate:"required"`
Name
string
`json:"name" validate:"required"`
Nickname
json
.
RawMessage
`json:"nickname" validate:"required"`
Nickname
json
.
RawMessage
`json:"nickname" validate:"required"`
Icon
string
`json:"icon" validate:"
required"`
Icon
string
`json:"icon" validate:"
omitempty"`
//
Introduce
json
.
RawMessage
`json:"introduce" validate:"
required"`
Introduce
json
.
RawMessage
`json:"introduce" validate:"
omitempty"`
//
Official
string
`json:"official" validate:"
required"`
Official
string
`json:"official" validate:"
omitempty"`
//
Paper
string
`json:"paper" validate:"
required"`
Paper
string
`json:"paper" validate:"
omitempty"`
//
Platform
string
`json:"platform" validate:"required"`
Platform
string
`json:"platform" validate:"required"`
Chain
string
`json:"chain" validate:"required"`
Chain
string
`json:"chain" validate:"required"`
Release
string
`json:"release" validate:"
required"`
Release
string
`json:"release" validate:"
omitempty"`
//
AreaSearch
string
`json:"area_search" validate:"
required"`
AreaSearch
string
`json:"area_search" validate:"
omitempty"`
//
PublishCount
float64
`json:"publish_count" validate:"
required"`
PublishCount
float64
`json:"publish_count" validate:"
omitempty"`
//
CirculateCount
float64
`json:"circulate_count" validate:"
required"`
CirculateCount
float64
`json:"circulate_count" validate:"
omitempty"`
//
Decimals
int
`json:"decimals" validate:"required"`
Decimals
int
`json:"decimals" validate:"required"`
Address
string
`json:"address" validate:"
required"`
Address
string
`json:"address" validate:"
omitempty"`
//
Treaty
int
`json:"treaty" validate:"required"`
Treaty
int
`json:"treaty" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
...
...
validate_service/wallet_coin_relation.go
View file @
5232ac11
package
validate_service
package
validate_service
type
WalletCoinRelateion
struct
{
type
WalletCoinRelateion
struct
{
CoinId
int
`json:"coin_id" validate:"required"`
CoinId
string
`json:"coin_id" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
}
}
type
DeleteWalletCoinRelateion
struct
{
type
DeleteWalletCoinRelateion
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