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
a7e14536
Commit
a7e14536
authored
Nov 13, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复添加币种权限
parent
aa31e5ee
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
22 deletions
+45
-22
wallet.go
models/wallet.go
+7
-7
chain.go
routers/api/backend/chain.go
+23
-0
wallet.go
routers/api/backend/wallet.go
+3
-3
wallet.go
service/wallet_service/wallet.go
+9
-9
wallet.go
validate_service/wallet.go
+3
-3
No files found.
models/wallet.go
View file @
a7e14536
package
models
package
models
import
(
import
(
"github.com/jinzhu/gorm"
"bwallet/pkg/setting"
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
)
)
type
Wallet
struct
{
type
Wallet
struct
{
...
@@ -11,9 +11,9 @@ type Wallet struct {
...
@@ -11,9 +11,9 @@ type Wallet struct {
Name
string
`gorm:"size:255;not null;" json:"name"`
Name
string
`gorm:"size:255;not null;" json:"name"`
DownloadUrl
string
`gorm:"not null;" json:"download_url"`
DownloadUrl
string
`gorm:"not null;" json:"download_url"`
Introduce
string
`gorm:"not null;" json:"introduce"`
Introduce
string
`gorm:"not null;" json:"introduce"`
//ChainId int `gorm:"not null;default:0" json:"chain_id
"`
ChainId
int
`gorm:"default:0" json:"chain_id,omitempty
"`
//IssueCharge float32 `gorm:"not null;
default:0.00" json:"issue_charge"`
IssueCharge
float32
`gorm:"
default:0.00" json:"issue_charge"`
//ChargeUnit string `gorm:"not null;
default:BTY" json:"charge_unit"`
ChargeUnit
string
`gorm:"
default:BTY" json:"charge_unit"`
}
}
func
(
w
Wallet
)
TableName
()
string
{
func
(
w
Wallet
)
TableName
()
string
{
...
@@ -73,9 +73,9 @@ func AddWallet(data map[string]interface{}) (error) {
...
@@ -73,9 +73,9 @@ func AddWallet(data map[string]interface{}) (error) {
Name
:
data
[
"name"
]
.
(
string
),
Name
:
data
[
"name"
]
.
(
string
),
DownloadUrl
:
data
[
"download_url"
]
.
(
string
),
DownloadUrl
:
data
[
"download_url"
]
.
(
string
),
Introduce
:
data
[
"introduce"
]
.
(
string
),
Introduce
:
data
[
"introduce"
]
.
(
string
),
//
ChargeUnit: data["charge_unit"].(string),
ChargeUnit
:
data
[
"charge_unit"
]
.
(
string
),
//
IssueCharge: data["issue_charge"].(float32),
IssueCharge
:
data
[
"issue_charge"
]
.
(
float32
),
//
ChainId: data["chain_id"].(int),
ChainId
:
data
[
"chain_id"
]
.
(
int
),
}
}
if
err
:=
db
.
Create
(
&
wallet
)
.
Error
;
err
!=
nil
{
if
err
:=
db
.
Create
(
&
wallet
)
.
Error
;
err
!=
nil
{
return
err
return
err
...
...
routers/api/backend/chain.go
View file @
a7e14536
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"bwallet/pkg/handler"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/pkg/util"
"bwallet/service/chain_service"
"bwallet/service/chain_service"
"bwallet/service/wallet_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"
...
@@ -97,7 +98,29 @@ func GetChains(c *gin.Context) {
...
@@ -97,7 +98,29 @@ func GetChains(c *gin.Context) {
}
}
func
GetUserChains
(
c
*
gin
.
Context
)
{
func
GetUserChains
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
userChainService
:=
chain_service
.
Chain
{}
userChainService
:=
chain_service
.
Chain
{}
if
(
"administrator"
!=
group
)
{
walletService
:=
wallet_service
.
Wallet
{
Id
:
user
.
UserInfo
.
PlatformId
}
exists
,
err
:=
walletService
.
ExistById
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrWalletNotFound
,
nil
)
return
}
if
(
!
exists
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrWalletNotFound
,
nil
)
return
}
wallet
,
err
:=
walletService
.
Get
()
userChainService
=
chain_service
.
Chain
{
ID
:
wallet
.
ChainId
,
}
}
platform_chain
,
err
:=
userChainService
.
GetUserChain
()
platform_chain
,
err
:=
userChainService
.
GetUserChain
()
if
err
!=
nil
{
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
...
...
routers/api/backend/wallet.go
View file @
a7e14536
...
@@ -182,9 +182,9 @@ func AddWallet(c *gin.Context) {
...
@@ -182,9 +182,9 @@ func AddWallet(c *gin.Context) {
Name
:
wallet
.
Name
,
Name
:
wallet
.
Name
,
DownloadUrl
:
wallet
.
DownloadUrl
,
DownloadUrl
:
wallet
.
DownloadUrl
,
Introduce
:
wallet
.
Introduce
,
Introduce
:
wallet
.
Introduce
,
//
ChainId: wallet.ChainId,
ChainId
:
wallet
.
ChainId
,
//
IssueCharge: wallet.IssueCharge,
IssueCharge
:
wallet
.
IssueCharge
,
//
ChargeUnit: wallet.ChargeUnit,
ChargeUnit
:
wallet
.
ChargeUnit
,
}
}
if
err
:=
walletService
.
Add
();
err
!=
nil
{
if
err
:=
walletService
.
Add
();
err
!=
nil
{
...
...
service/wallet_service/wallet.go
View file @
a7e14536
...
@@ -9,9 +9,9 @@ type Wallet struct {
...
@@ -9,9 +9,9 @@ type Wallet struct {
Name
string
Name
string
DownloadUrl
string
DownloadUrl
string
Introduce
string
Introduce
string
//
ChainId int
ChainId
int
//
IssueCharge float32
IssueCharge
float32
//
ChargeUnit string
ChargeUnit
string
PageNum
int
PageNum
int
PageSize
int
PageSize
int
...
@@ -43,9 +43,9 @@ func (w *Wallet) Add() error {
...
@@ -43,9 +43,9 @@ func (w *Wallet) Add() error {
"name"
:
w
.
Name
,
"name"
:
w
.
Name
,
"download_url"
:
w
.
DownloadUrl
,
"download_url"
:
w
.
DownloadUrl
,
"introduce"
:
w
.
Introduce
,
"introduce"
:
w
.
Introduce
,
//
"chain_id": w.ChainId,
"chain_id"
:
w
.
ChainId
,
//
"charge_unit": w.ChargeUnit,
"charge_unit"
:
w
.
ChargeUnit
,
//
"issue_charge": w.IssueCharge,
"issue_charge"
:
w
.
IssueCharge
,
}
}
if
err
:=
models
.
AddWallet
(
wallet
);
err
!=
nil
{
if
err
:=
models
.
AddWallet
(
wallet
);
err
!=
nil
{
...
@@ -60,9 +60,9 @@ func (w *Wallet) Edit() error {
...
@@ -60,9 +60,9 @@ func (w *Wallet) Edit() error {
"name"
:
w
.
Name
,
"name"
:
w
.
Name
,
"download_url"
:
w
.
DownloadUrl
,
"download_url"
:
w
.
DownloadUrl
,
"introduce"
:
w
.
Introduce
,
"introduce"
:
w
.
Introduce
,
//
"chain_id": w.ChainId,
"chain_id"
:
w
.
ChainId
,
//
"issue_charge": w.IssueCharge,
"issue_charge"
:
w
.
IssueCharge
,
//
"charge_unit": w.ChargeUnit,
"charge_unit"
:
w
.
ChargeUnit
,
})
})
}
}
...
...
validate_service/wallet.go
View file @
a7e14536
...
@@ -4,9 +4,9 @@ type Wallet struct {
...
@@ -4,9 +4,9 @@ type Wallet struct {
Name
string
`json:"name" validate:"required"`
Name
string
`json:"name" validate:"required"`
DownloadUrl
string
`json:"download_url" validate:"required,url"`
DownloadUrl
string
`json:"download_url" validate:"required,url"`
Introduce
string
`json:"introduce" validate:"required"`
Introduce
string
`json:"introduce" validate:"required"`
//ChainId int `json:"chain_id" validate:"required
"`
ChainId
int
`json:"chain_id ,omitempty
"`
//IssueCharge float32 `json:"issue_charge" validate:"required
"`
IssueCharge
float32
`json:"issue_charge ,omitempty
"`
//ChargeUnit string `json:"charge_unit" validate:"required
"`
ChargeUnit
string
`json:"charge_unit ,omitempty
"`
}
}
type
EditWallet
struct
{
type
EditWallet
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