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
5346bc7c
Commit
5346bc7c
authored
Mar 24, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取浏览器地址
parent
5d46ef7b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
2 deletions
+74
-2
chain.go
models/chain.go
+21
-1
chain.go
routers/api/app/chain.go
+31
-0
router.go
routers/router.go
+1
-0
chain.go
service/chain_service/chain.go
+21
-1
No files found.
models/chain.go
View file @
5346bc7c
...
...
@@ -17,7 +17,7 @@ type Chain struct {
Token
string
`json:"token"`
//基础代币
Fee
float32
`json:"fee"`
//手续费(基础代币)
BrowerUrl
string
`json:"brower_url"`
//浏览器链接
Icon
string
`json:"icon"`
//
是否允许转币
Icon
string
`json:"icon"`
//
图标
Lock
int
`json:"lock"`
//是否允许转币
}
...
...
@@ -28,6 +28,11 @@ type UserChain struct {
Platform
string
`json:"platform"`
//平行链名称
}
type
Explore
struct
{
BrowerUrl
string
`json:"brower_url"`
//浏览器链接
Icon
string
`json:"icon"`
//图标
}
func
(
c
Chain
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".coin_platform_withhold"
}
...
...
@@ -96,6 +101,21 @@ func GetUserChains(maps interface{}) ([]*UserChain, error) {
return
chains
,
nil
}
func
GetExplore
(
platform
string
)
(
*
Chain
,
error
)
{
var
explore
Chain
err
:=
db
.
Where
(
"platform = ?"
,
platform
)
.
First
(
&
explore
)
.
Error
if
err
!=
nil
{
return
nil
,
err
}
err
=
db
.
Model
(
&
explore
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
&
explore
,
nil
}
/**
* 通过id获取指定链信息
* @param id
...
...
routers/api/app/chain.go
0 → 100644
View file @
5346bc7c
package
app
import
(
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/service/chain_service"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
)
func
Explore
(
c
*
gin
.
Context
)
{
valid
:=
validation
.
Validation
{}
platform
:=
c
.
DefaultQuery
(
"platform"
,
""
)
valid
.
Required
(
platform
,
"platform"
)
.
Message
(
"平台名不能为空"
)
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
valid
.
Errors
[
0
],
nil
)
return
}
chainService
:=
chain_service
.
Chain
{
Platform
:
platform
}
explore
,
err
:=
chainService
.
Explore
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
explore
)
return
}
routers/router.go
View file @
5346bc7c
...
...
@@ -48,6 +48,7 @@ func InitRouter() *gin.Engine {
client
.
GET
(
"/live-banners"
,
app
.
GetLiveBanners
)
client
.
GET
(
"/fees/recommended"
,
app
.
GetTransactionGas
)
client
.
GET
(
"/tokenview/explore"
,
app
.
Explore
)
api
:=
r
.
Group
(
"/api"
)
...
...
service/chain_service/chain.go
View file @
5346bc7c
package
chain_service
import
"bwallet/models"
import
(
"bwallet/models"
)
type
Chain
struct
{
ID
int
...
...
@@ -18,6 +20,11 @@ type Chain struct {
PageSize
int
}
type
Explore
struct
{
BrowerUrl
string
`json:"brower_url,omitempty"`
//浏览器链接
Icon
string
`json:"icon,omitempty"`
//图标
}
func
(
c
*
Chain
)
Get
()
(
*
models
.
Chain
,
error
)
{
chain
,
err
:=
models
.
GetChain
(
c
.
ID
)
if
err
!=
nil
{
...
...
@@ -38,6 +45,19 @@ func (c *Chain) GetAll() ([]*models.Chain, error) {
return
chains
,
nil
}
func
(
c
*
Chain
)
Explore
()
(
*
models
.
Explore
,
error
)
{
tmp
,
err
:=
models
.
GetExplore
(
c
.
Platform
)
if
err
!=
nil
{
return
nil
,
err
}
var
explore
models
.
Explore
explore
.
BrowerUrl
=
tmp
.
BrowerUrl
explore
.
Icon
=
tmp
.
Icon
return
&
explore
,
nil
}
func
(
c
*
Chain
)
GetUserChain
()
([]
*
models
.
UserChain
,
error
)
{
var
chains
[]
*
models
.
UserChain
...
...
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