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
4c4e7b60
Commit
4c4e7b60
authored
Jan 07, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
3e8e05a0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
21 deletions
+68
-21
errno.go
pkg/errno/errno.go
+9
-0
coin.go
routers/api/v1/coin.go
+4
-2
recommend_coin.go
routers/api/v1/recommend_coin.go
+19
-2
supported_currency.go
routers/api/v1/supported_currency.go
+29
-12
supported_currency.go
service/supported_currency_service/supported_currency.go
+5
-3
supported_currency.go
validate_service/supported_currency.go
+2
-2
No files found.
pkg/errno/errno.go
View file @
4c4e7b60
...
@@ -73,6 +73,14 @@ var (
...
@@ -73,6 +73,14 @@ var (
ErrUpdateCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin update error."
}
ErrUpdateCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin update error."
}
ErrDeleteCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin delete error."
}
ErrDeleteCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin delete error."
}
// recommend coin errors
ErrRecommendCoinNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The recommend coin was not found."
}
ErrCountRecommendCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The recommend coins statistic error."
}
ErrAddRecommendCoin
=
&
Errno
{
Code
:
20101
,
Message
:
"The recommend coin add error."
}
ErrUpdateRecommendCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The recommend coin update error."
}
ErrDeleteRecommendCoin
=
&
Errno
{
Code
:
20102
,
Message
:
"The recommend coin delete error."
}
ErrExistRecommendCoin
=
&
Errno
{
Code
:
20103
,
Message
:
"The recommend coin already exists."
}
// wallet errors
// wallet errors
ErrWalletNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The wallet was not found."
}
ErrWalletNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The wallet was not found."
}
ErrCountWallet
=
&
Errno
{
Code
:
20102
,
Message
:
"The wallets statistic error."
}
ErrCountWallet
=
&
Errno
{
Code
:
20102
,
Message
:
"The wallets statistic error."
}
...
@@ -93,6 +101,7 @@ var (
...
@@ -93,6 +101,7 @@ var (
ErrAddSupportedCurrency
=
&
Errno
{
Code
:
20101
,
Message
:
"The supported currency add error."
}
ErrAddSupportedCurrency
=
&
Errno
{
Code
:
20101
,
Message
:
"The supported currency add error."
}
ErrUpdateSupportedCurrency
=
&
Errno
{
Code
:
20102
,
Message
:
"The supported currency update error."
}
ErrUpdateSupportedCurrency
=
&
Errno
{
Code
:
20102
,
Message
:
"The supported currency update error."
}
ErrDeleteSupportedCurrency
=
&
Errno
{
Code
:
20102
,
Message
:
"The supported currency delete error."
}
ErrDeleteSupportedCurrency
=
&
Errno
{
Code
:
20102
,
Message
:
"The supported currency delete error."
}
ErrExistSupportedCurrency
=
&
Errno
{
Code
:
20103
,
Message
:
"The supported currency already exists."
}
// user errors
// user errors
ErrUserTokenIncorrect
=
&
Errno
{
Code
:
40001
,
Message
:
"The user token was incorrect."
}
ErrUserTokenIncorrect
=
&
Errno
{
Code
:
40001
,
Message
:
"The user token was incorrect."
}
...
...
routers/api/v1/coin.go
View file @
4c4e7b60
...
@@ -129,11 +129,13 @@ func AddCoin(c *gin.Context) {
...
@@ -129,11 +129,13 @@ func AddCoin(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
var
platform_id
int
var
platform_id
int
platform_id
=
auth
.
PlatformId
platform_id
=
auth
.
PlatformId
if
(
"administrator"
==
group
)
{
if
(
"administrator"
==
group
)
{
platform_id
=
coin
.
PlatformId
if
coin
.
PlatformId
!=
0
{
platform_id
=
coin
.
PlatformId
}
}
}
coinService
:=
coin_service
.
Coin
{
coinService
:=
coin_service
.
Coin
{
...
...
routers/api/v1/recommend_coin.go
View file @
4c4e7b60
...
@@ -65,15 +65,32 @@ func AddRecommendCoin(c *gin.Context) {
...
@@ -65,15 +65,32 @@ func AddRecommendCoin(c *gin.Context) {
}
}
}
}
//自定义验证
recommendCoinValidate
:=
recommend_coin_service
.
RecommendCoin
{
PlatformId
:
recommend_coin
.
PlatformId
,
Cid
:
recommend_coin
.
Cid
,
}
total
,
err
:=
recommendCoinValidate
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountRecommendCoin
,
nil
)
return
}
if
(
total
>
0
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrExistRecommendCoin
,
nil
)
return
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
group
:=
auth
.
Group
var
platform_id
int
var
platform_id
int
platform_id
=
auth
.
PlatformId
platform_id
=
auth
.
PlatformId
if
(
"administrator"
==
group
)
{
if
(
"administrator"
==
group
)
{
platform_id
=
recommend_coin
.
PlatformId
if
recommend_coin
.
PlatformId
!=
0
{
platform_id
=
recommend_coin
.
PlatformId
}
}
}
recommendCoinService
:=
recommend_coin_service
.
RecommendCoin
{
recommendCoinService
:=
recommend_coin_service
.
RecommendCoin
{
...
...
routers/api/v1/supported_currency.go
View file @
4c4e7b60
...
@@ -95,15 +95,6 @@ func GetSupportedCurrencies(c *gin.Context) {
...
@@ -95,15 +95,6 @@ func GetSupportedCurrencies(c *gin.Context) {
}
}
func
AddSupportedCurrency
(
c
*
gin
.
Context
)
{
func
AddSupportedCurrency
(
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
}
currency
:=
validate_service
.
SupportedCurrency
{}
currency
:=
validate_service
.
SupportedCurrency
{}
c
.
ShouldBindJSON
(
&
currency
)
c
.
ShouldBindJSON
(
&
currency
)
...
@@ -115,9 +106,37 @@ func AddSupportedCurrency(c *gin.Context) {
...
@@ -115,9 +106,37 @@ func AddSupportedCurrency(c *gin.Context) {
}
}
}
}
currencyService
:=
supported_currency_service
.
SupportedCurrency
{
//自定义验证
supportedCurrencyValidate
:=
supported_currency_service
.
SupportedCurrency
{
PlatformId
:
currency
.
PlatformId
,
PlatformId
:
currency
.
PlatformId
,
CurrencyId
:
currency
.
CurrencyId
,
CurrencyId
:
currency
.
CurrencyId
,
}
total
,
err
:=
supportedCurrencyValidate
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountSupportedCurrency
,
nil
)
return
}
if
(
total
>
0
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrExistSupportedCurrency
,
nil
)
return
}
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
currency
.
PlatformId
!=
0
{
platform_id
=
currency
.
PlatformId
}
}
currencyService
:=
supported_currency_service
.
SupportedCurrency
{
PlatformId
:
platform_id
,
CurrencyId
:
currency
.
CurrencyId
,
Sort
:
currency
.
Sort
,
Sort
:
currency
.
Sort
,
}
}
...
@@ -143,8 +162,6 @@ func EditSupportedCurrency(c *gin.Context) {
...
@@ -143,8 +162,6 @@ func EditSupportedCurrency(c *gin.Context) {
currencyService
:=
supported_currency_service
.
SupportedCurrency
{
currencyService
:=
supported_currency_service
.
SupportedCurrency
{
ID
:
currency
.
Id
,
ID
:
currency
.
Id
,
PlatformId
:
currency
.
PlatformId
,
CurrencyId
:
currency
.
CurrencyId
,
Sort
:
currency
.
Sort
,
Sort
:
currency
.
Sort
,
}
}
...
...
service/supported_currency_service/supported_currency.go
View file @
4c4e7b60
...
@@ -48,9 +48,7 @@ func (c *SupportedCurrency) Add() error {
...
@@ -48,9 +48,7 @@ func (c *SupportedCurrency) Add() error {
func
(
c
*
SupportedCurrency
)
Edit
()
error
{
func
(
c
*
SupportedCurrency
)
Edit
()
error
{
return
models
.
EditSupportedCurrency
(
c
.
ID
,
map
[
string
]
interface
{}{
return
models
.
EditSupportedCurrency
(
c
.
ID
,
map
[
string
]
interface
{}{
"platform_id"
:
c
.
PlatformId
,
"sort"
:
c
.
Sort
,
"currency_id"
:
c
.
CurrencyId
,
"sort"
:
c
.
Sort
,
})
})
}
}
...
@@ -77,6 +75,10 @@ func (c *SupportedCurrency) getMaps() (map[string]interface{}) {
...
@@ -77,6 +75,10 @@ func (c *SupportedCurrency) getMaps() (map[string]interface{}) {
maps
[
"platform_id"
]
=
c
.
PlatformId
maps
[
"platform_id"
]
=
c
.
PlatformId
}
}
if
c
.
CurrencyId
!=
0
{
maps
[
"currency_id"
]
=
c
.
CurrencyId
}
return
maps
return
maps
}
}
...
...
validate_service/supported_currency.go
View file @
4c4e7b60
...
@@ -7,6 +7,6 @@ type SupportedCurrency struct {
...
@@ -7,6 +7,6 @@ type SupportedCurrency struct {
}
}
type
EditSupportedCurrency
struct
{
type
EditSupportedCurrency
struct
{
SupportedCurrency
Id
int
`json:"id" validate:"required"`
Id
int
`json:"id
" validate:"required"`
Sort
int
`json:"sort
" validate:"required"`
}
}
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