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
d7eeabd7
Commit
d7eeabd7
authored
Mar 20, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a3b1fb01
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
0 deletions
+64
-0
chain.go
models/chain.go
+16
-0
chain.go
routers/api/v1/chain.go
+36
-0
router.go
routers/router.go
+1
-0
chain.go
service/chain_service/chain.go
+11
-0
No files found.
models/chain.go
View file @
d7eeabd7
...
@@ -18,6 +18,11 @@ type Chain struct {
...
@@ -18,6 +18,11 @@ type Chain struct {
BrowerUrl
string
`json:"brower_url"`
//浏览器链接
BrowerUrl
string
`json:"brower_url"`
//浏览器链接
}
}
type
UserChain
struct
{
Id
int
`json:"id"`
Platform
string
`json:"platform"`
//平行链名称
}
func
(
c
Chain
)
TableName
()
string
{
func
(
c
Chain
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_chain"
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_chain"
}
}
...
@@ -71,6 +76,17 @@ func GetChains(pageNum, pageSize int, maps interface{}) ([]*Chain, error) {
...
@@ -71,6 +76,17 @@ func GetChains(pageNum, pageSize int, maps interface{}) ([]*Chain, error) {
return
chains
,
nil
return
chains
,
nil
}
}
func
GetUserChains
(
maps
interface
{})
([]
*
UserChain
,
error
)
{
var
chains
[]
*
UserChain
err
:=
db
.
Select
(
"id, platform"
)
.
Table
(
"wallet_chain"
)
.
Where
(
maps
)
.
Scan
(
&
chains
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
chains
,
nil
}
/**
/**
* 通过id获取指定链信息
* 通过id获取指定链信息
* @param id
* @param id
...
...
routers/api/v1/chain.go
View file @
d7eeabd7
...
@@ -99,6 +99,42 @@ func GetChains(c *gin.Context) {
...
@@ -99,6 +99,42 @@ func GetChains(c *gin.Context) {
handler
.
SendResponse
(
c
,
nil
,
data
)
handler
.
SendResponse
(
c
,
nil
,
data
)
}
}
func
GetUserChains
(
c
*
gin
.
Context
)
{
valid
:=
validation
.
Validation
{}
platform
:=
""
if
arg
:=
c
.
Query
(
"platform"
);
arg
!=
""
{
platform
=
c
.
Query
(
"platform"
)
}
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
}
chainService
:=
chain_service
.
Chain
{
Platform
:
platform
,
}
total
,
err
:=
chainService
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountChain
,
nil
)
return
}
chains
,
err
:=
chainService
.
GetUserChain
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
data
:=
make
(
map
[
string
]
interface
{})
data
[
"items"
]
=
chains
data
[
"total"
]
=
total
handler
.
SendResponse
(
c
,
nil
,
data
)
}
func
AddChain
(
c
*
gin
.
Context
)
{
func
AddChain
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
authService
:=
auth_service
.
Auth
{
Token
:
token
}
...
...
routers/router.go
View file @
d7eeabd7
...
@@ -53,6 +53,7 @@ func InitRouter() *gin.Engine {
...
@@ -53,6 +53,7 @@ func InitRouter() *gin.Engine {
api
.
GET
(
"/chain"
,
v1
.
GetChain
)
api
.
GET
(
"/chain"
,
v1
.
GetChain
)
api
.
PUT
(
"/chain"
,
v1
.
EditChain
)
api
.
PUT
(
"/chain"
,
v1
.
EditChain
)
api
.
DELETE
(
"/chain"
,
v1
.
DeleteChain
)
api
.
DELETE
(
"/chain"
,
v1
.
DeleteChain
)
api
.
GET
(
"/user-chains"
,
v1
.
GetUserChains
)
api
.
GET
(
"/recommend-categories"
,
v1
.
GetWalletRecommendCategories
)
api
.
GET
(
"/recommend-categories"
,
v1
.
GetWalletRecommendCategories
)
api
.
POST
(
"/recommend-category"
,
v1
.
AddWalletRecommendCategory
)
api
.
POST
(
"/recommend-category"
,
v1
.
AddWalletRecommendCategory
)
...
...
service/chain_service/chain.go
View file @
d7eeabd7
...
@@ -36,6 +36,17 @@ func (c *Chain) GetAll() ([]*models.Chain, error) {
...
@@ -36,6 +36,17 @@ func (c *Chain) GetAll() ([]*models.Chain, error) {
return
chains
,
nil
return
chains
,
nil
}
}
func
(
c
*
Chain
)
GetUserChain
()
([]
*
models
.
UserChain
,
error
)
{
var
chains
[]
*
models
.
UserChain
chains
,
err
:=
models
.
GetUserChains
(
c
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
chains
,
nil
}
func
(
c
*
Chain
)
Add
()
error
{
func
(
c
*
Chain
)
Add
()
error
{
chain
:=
map
[
string
]
interface
{}{
chain
:=
map
[
string
]
interface
{}{
"platform"
:
c
.
Platform
,
"platform"
:
c
.
Platform
,
...
...
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