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
3e1b510b
Commit
3e1b510b
authored
Sep 03, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
00ad6c66
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
276 additions
and
15 deletions
+276
-15
fee.go
routers/api/backend/fee.go
+36
-0
trusteeship_coin.go
routers/api/backend/trusteeship_coin.go
+201
-0
router.go
routers/router.go
+8
-15
fee.go
service/fee_service/fee.go
+19
-0
trusteeship_coin.go
validate_service/trusteeship_coin.go
+12
-0
No files found.
routers/api/backend/fee.go
View file @
3e1b510b
...
@@ -11,6 +11,42 @@ import (
...
@@ -11,6 +11,42 @@ import (
"strings"
"strings"
)
)
func
GetTransactionCoins
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
var
platform_id
int
platform_id
=
user
.
UserInfo
.
PlatformId
if
(
"administrator"
==
group
)
{
if
arg
:=
c
.
Query
(
"platform_id"
);
arg
!=
""
{
platform_id
=
com
.
StrTo
(
c
.
Query
(
"platform_id"
))
.
MustInt
()
}
}
feeService
:=
fee_service
.
Fee
{
PlatformId
:
platform_id
,
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
fees
,
err
:=
feeService
.
GetAllCoinName
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
vals
:=
[]
string
{}
for
_
,
value
:=
range
fees
{
if
""
==
value
.
CoinName
{
continue
}
vals
=
append
(
vals
,
value
.
CoinName
)
}
handler
.
SendResponse
(
c
,
nil
,
vals
)
}
func
GetTransactionFees
(
c
*
gin
.
Context
)
{
func
GetTransactionFees
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
...
...
routers/api/backend/trusteeship_coin.go
0 → 100644
View file @
3e1b510b
package
backend
import
(
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/service/coin_service"
"bwallet/service/trusteeship_coin_service"
"bwallet/validate_service"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
"strconv"
"strings"
)
func
GetTrusteeshipCoins
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
var
platform_id
int
platform_id
=
user
.
UserInfo
.
PlatformId
if
(
"administrator"
==
group
)
{
if
arg
:=
c
.
Query
(
"platform_id"
);
arg
!=
""
{
platform_id
=
com
.
StrTo
(
c
.
Query
(
"platform_id"
))
.
MustInt
()
}
}
trusteeshipCoinService
:=
trusteeship_coin_service
.
TrusteeshipCoin
{
PlatformId
:
platform_id
,
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
total
,
err
:=
trusteeshipCoinService
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountCoin
,
nil
)
return
}
coinTrusteeships
,
err
:=
trusteeshipCoinService
.
GetAll
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
data
:=
make
(
map
[
string
]
interface
{})
data
[
"items"
]
=
coinTrusteeships
data
[
"total"
]
=
total
handler
.
SendResponse
(
c
,
nil
,
data
)
}
func
AddTrusteeshipCoin
(
c
*
gin
.
Context
)
{
trusteeship_coin
:=
validate_service
.
TrusteeshipCoin
{}
c
.
ShouldBindJSON
(
&
trusteeship_coin
)
//方法一
if
ok
,
errors
:=
validate_service
.
ValidateInputs
(
trusteeship_coin
);
!
ok
{
for
_
,
err
:=
range
errors
{
handler
.
SendResponse
(
c
,
errno
.
ErrBind
,
strings
.
Join
(
err
,
" "
))
return
}
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
var
platform_id
int
platform_id
=
user
.
UserInfo
.
PlatformId
if
(
"administrator"
==
group
)
{
if
trusteeship_coin
.
PlatformId
!=
0
{
platform_id
=
trusteeship_coin
.
PlatformId
}
}
for
_
,
id
:=
range
strings
.
Split
(
trusteeship_coin
.
Cid
,
","
)
{
if
id
==
""
{
continue
}
coin_id
,
err
:=
strconv
.
Atoi
(
id
)
if
(
nil
!=
err
)
{
continue
}
coinService
:=
coin_service
.
Coin
{
Id
:
coin_id
,
}
exists
,
err
:=
coinService
.
ExistById
()
if
err
!=
nil
||
!
exists
{
continue
}
trusteeshipCoinValidate
:=
trusteeship_coin_service
.
TrusteeshipCoin
{
PlatformId
:
platform_id
,
Cid
:
coin_id
,
}
total
,
err
:=
trusteeshipCoinValidate
.
Count
()
if
err
!=
nil
||
total
>
0
{
continue
}
trusteeshipCoinService
:=
trusteeship_coin_service
.
TrusteeshipCoin
{
Cid
:
coin_id
,
PlatformId
:
platform_id
,
Sort
:
trusteeship_coin
.
Sort
,
}
trusteeshipCoinService
.
Add
()
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
func
EditTrusteeshipCoin
(
c
*
gin
.
Context
)
{
trusteeship_coin
:=
validate_service
.
EditTrusteeshipCoin
{}
c
.
ShouldBindJSON
(
&
trusteeship_coin
)
//方法一
if
ok
,
errors
:=
validate_service
.
ValidateInputs
(
trusteeship_coin
);
!
ok
{
for
_
,
err
:=
range
errors
{
handler
.
SendResponse
(
c
,
errno
.
ErrBind
,
strings
.
Join
(
err
,
" "
))
return
}
}
trusteeshipCoinService
:=
trusteeship_coin_service
.
TrusteeshipCoin
{
Id
:
trusteeship_coin
.
Id
,
Sort
:
trusteeship_coin
.
Sort
,
}
exists
,
err
:=
trusteeshipCoinService
.
ExistById
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
if
!
exists
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
if
(
"administrator"
!=
group
)
{
trusteeship_coin_model
:=
trusteeship_coin_service
.
TrusteeshipCoin
{
Id
:
trusteeship_coin
.
Id
}
trusteeship_coin
,
_
:=
trusteeship_coin_model
.
Get
()
if
trusteeship_coin
.
PlatformId
!=
user
.
UserInfo
.
PlatformId
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
}
if
err
:=
trusteeshipCoinService
.
Edit
();
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrUpdateCoin
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
func
DeleteTrusteeshipCoin
(
c
*
gin
.
Context
)
{
id
:=
com
.
StrTo
(
c
.
DefaultQuery
(
"id"
,
"0"
))
.
MustInt
()
valid
:=
validation
.
Validation
{}
valid
.
Min
(
id
,
1
,
"id"
)
.
Message
(
"ID必须大于0"
)
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
}
trusteeshipCoinService
:=
trusteeship_coin_service
.
TrusteeshipCoin
{
Id
:
id
}
exists
,
err
:=
trusteeshipCoinService
.
ExistById
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
if
!
exists
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
if
(
"administrator"
!=
group
)
{
trusteeship_coin
,
_
:=
trusteeshipCoinService
.
Get
()
if
trusteeship_coin
.
PlatformId
!=
user
.
UserInfo
.
PlatformId
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
}
err
=
trusteeshipCoinService
.
Delete
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrDeleteCoin
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
routers/router.go
View file @
3e1b510b
...
@@ -56,7 +56,7 @@ func InitRouter() *gin.Engine {
...
@@ -56,7 +56,7 @@ func InitRouter() *gin.Engine {
api
:=
r
.
Group
(
"/api"
)
api
:=
r
.
Group
(
"/api"
)
api
.
Use
(
jwt
.
JWT
())
.
Use
(
auth
.
Casbin
())
api
.
Use
(
jwt
.
JWT
())
.
Use
(
auth
.
AUTH
())
api
.
POST
(
"/log"
,
backend
.
AddOperationLog
)
api
.
POST
(
"/log"
,
backend
.
AddOperationLog
)
api
.
GET
(
"/logs"
,
backend
.
GetOperationLogs
)
api
.
GET
(
"/logs"
,
backend
.
GetOperationLogs
)
api
.
Use
(
log
.
LogMiddleware
(
e
.
HandleTableName
))
api
.
Use
(
log
.
LogMiddleware
(
e
.
HandleTableName
))
...
@@ -117,8 +117,14 @@ func InitRouter() *gin.Engine {
...
@@ -117,8 +117,14 @@ func InitRouter() *gin.Engine {
api
.
PUT
(
"/recommend-coin"
,
backend
.
EditRecommendCoin
)
api
.
PUT
(
"/recommend-coin"
,
backend
.
EditRecommendCoin
)
api
.
DELETE
(
"/recommend-coin"
,
backend
.
DeleteRecommendCoin
)
api
.
DELETE
(
"/recommend-coin"
,
backend
.
DeleteRecommendCoin
)
api
.
GET
(
"/transaction-fees"
,
backend
.
GetTransactionFees
)
api
.
GET
(
"/transaction-fees"
,
backend
.
GetTransactionFees
)
api
.
GET
(
"/transaction-coins"
,
backend
.
GetTransactionCoins
)
api
.
PUT
(
"/transaction-fees"
,
backend
.
EditTransactionFees
)
api
.
PUT
(
"/transaction-fees"
,
backend
.
EditTransactionFees
)
api
.
GET
(
"/trusteeship-coins"
,
backend
.
GetTrusteeshipCoins
)
api
.
POST
(
"/trusteeship-coin"
,
backend
.
AddTrusteeshipCoin
)
api
.
PUT
(
"/trusteeship-coin"
,
backend
.
EditTrusteeshipCoin
)
api
.
DELETE
(
"/trusteeship-coin"
,
backend
.
DeleteTrusteeshipCoin
)
api
.
GET
(
"/supported-currencies"
,
backend
.
GetSupportedCurrencies
)
api
.
GET
(
"/supported-currencies"
,
backend
.
GetSupportedCurrencies
)
api
.
POST
(
"/supported-currency"
,
backend
.
AddSupportedCurrency
)
api
.
POST
(
"/supported-currency"
,
backend
.
AddSupportedCurrency
)
api
.
GET
(
"/supported-currency"
,
backend
.
GetSupportedCurrency
)
api
.
GET
(
"/supported-currency"
,
backend
.
GetSupportedCurrency
)
...
@@ -151,23 +157,10 @@ func InitRouter() *gin.Engine {
...
@@ -151,23 +157,10 @@ func InitRouter() *gin.Engine {
api
.
PUT
(
"/live-charge"
,
backend
.
EditLiveCharge
)
api
.
PUT
(
"/live-charge"
,
backend
.
EditLiveCharge
)
api
.
GET
(
"/managers"
,
backend
.
GetManagers
)
api
.
GET
(
"/managers"
,
backend
.
GetManagers
)
//api.GET("/user", backend.GetUser)
api
.
POST
(
"/manager"
,
backend
.
AddManager
)
api
.
POST
(
"/manager"
,
backend
.
AddManager
)
api
.
PUT
(
"/manager"
,
backend
.
EditManager
)
api
.
PUT
(
"/manager"
,
backend
.
EditManager
)
api
.
DELETE
(
"/manager"
,
backend
.
DeleteManager
)
api
.
DELETE
(
"/manager"
,
backend
.
DeleteManager
)
api
.
GET
(
"/roles"
,
backend
.
GetRoles
)
api
.
POST
(
"/role"
,
backend
.
AddRole
)
api
.
PUT
(
"/role"
,
backend
.
EditRole
)
api
.
DELETE
(
"/role"
,
backend
.
DeleteRole
)
api
.
GET
(
"/user-permissions"
,
backend
.
GetPermissions
)
api
.
POST
(
"/user-permission"
,
backend
.
SetPermission
)
api
.
POST
(
"/user-role"
,
backend
.
AddAdminRole
)
api
.
POST
(
"/set-role"
,
backend
.
SetRole
)
api
.
GET
(
"/api-modules"
,
backend
.
GetApiModules
)
api
.
GET
(
"/api-menu"
,
backend
.
GetMenu
)
}
}
return
r
return
r
...
...
service/fee_service/fee.go
View file @
3e1b510b
...
@@ -81,6 +81,25 @@ func (f *Fee) Search() (*models.Fee, error) {
...
@@ -81,6 +81,25 @@ func (f *Fee) Search() (*models.Fee, error) {
return
fee
,
nil
return
fee
,
nil
}
}
func
(
c
*
Fee
)
GetAllCoinName
()
([]
*
models
.
FeeCoinNameResp
,
error
)
{
var
fee
[]
*
models
.
Fee
fee
,
err
:=
models
.
GetFees
(
c
.
PageNum
,
c
.
PageSize
,
c
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
var
records
=
[]
*
models
.
FeeCoinNameResp
{}
for
_
,
value
:=
range
fee
{
record
:=
&
models
.
FeeCoinNameResp
{}
record
.
CoinName
=
value
.
CoinName
records
=
append
(
records
,
record
)
}
return
records
,
nil
}
func
(
c
*
Fee
)
DeleteByCondition
()
error
{
func
(
c
*
Fee
)
DeleteByCondition
()
error
{
return
models
.
DeleteFeeByCondition
(
c
.
getMaps
())
return
models
.
DeleteFeeByCondition
(
c
.
getMaps
())
}
}
...
...
validate_service/trusteeship_coin.go
0 → 100644
View file @
3e1b510b
package
validate_service
type
TrusteeshipCoin
struct
{
Cid
string
`json:"cid" validate:"required"`
Sort
int
`json:"sort" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
}
type
EditTrusteeshipCoin
struct
{
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