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
b0650fac
Commit
b0650fac
authored
Jan 19, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关系搜索
parent
62790096
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
6 deletions
+57
-6
wallet_coin_relation.go
models/wallet_coin_relation.go
+15
-5
wallet_coin_relation.go
routers/api/v1/wallet_coin_relation.go
+19
-0
wallet_coin_relation.go
service/wallet_coin_relation_service/wallet_coin_relation.go
+23
-1
No files found.
models/wallet_coin_relation.go
View file @
b0650fac
...
@@ -40,11 +40,21 @@ func GetWalletCoinRelationTotal(maps interface{}) (int, error) {
...
@@ -40,11 +40,21 @@ func GetWalletCoinRelationTotal(maps interface{}) (int, error) {
func
GetWalletCoinRelations
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
WalletCoinRelation
,
error
)
{
func
GetWalletCoinRelations
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
WalletCoinRelation
,
error
)
{
var
coins
[]
*
WalletCoinRelation
var
coins
[]
*
WalletCoinRelation
conditions
:=
make
(
map
[
string
]
interface
{})
relation_map
:=
make
(
map
[
string
]
interface
{})
conditions
[
"name"
]
=
"ETH"
coin_map
:=
make
(
map
[
string
]
interface
{})
conditions
[
"sid"
]
=
"ethereum"
for
key
,
value
:=
range
maps
.
(
map
[
string
]
interface
{})
{
conditions
[
"platform"
]
=
"ethereum"
if
(
"platform_id"
==
key
||
"coin_id"
==
key
)
{
err
:=
db
.
Preload
(
"Coin"
,
conditions
)
.
Debug
()
.
Where
(
maps
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
coins
)
.
Error
relation_map
[
key
]
=
value
}
if
(
"condition"
==
key
)
{
for
k
,
v
:=
range
value
.
(
map
[
string
]
interface
{})
{
coin_map
[
k
]
=
v
}
}
}
err
:=
db
.
Preload
(
"Coin"
,
coin_map
)
.
Where
(
relation_map
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
coins
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
return
nil
,
err
}
}
...
...
routers/api/v1/wallet_coin_relation.go
View file @
b0650fac
...
@@ -25,9 +25,28 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
...
@@ -25,9 +25,28 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
}
else
{
}
else
{
platform_id
=
auth
.
PlatformId
platform_id
=
auth
.
PlatformId
}
}
name
:=
""
if
arg
:=
c
.
Query
(
"name"
);
arg
!=
""
{
name
=
c
.
Query
(
"name"
)
}
platform
:=
""
if
arg
:=
c
.
Query
(
"platform"
);
arg
!=
""
{
platform
=
c
.
Query
(
"platform"
)
}
chain
:=
""
if
arg
:=
c
.
Query
(
"chain"
);
arg
!=
""
{
chain
=
c
.
Query
(
"chain"
)
}
walletCoinRelateionService
:=
wallet_coin_relation_service
.
WalletCoinRelation
{
walletCoinRelateionService
:=
wallet_coin_relation_service
.
WalletCoinRelation
{
PlatformId
:
platform_id
,
PlatformId
:
platform_id
,
CoinCondition
:
struct
{
Name
string
Chain
string
Platform
string
}{
Name
:
name
,
Chain
:
chain
,
Platform
:
platform
},
PageNum
:
util
.
GetPage
(
c
),
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
}
...
...
service/wallet_coin_relation_service/wallet_coin_relation.go
View file @
b0650fac
...
@@ -7,12 +7,18 @@ import (
...
@@ -7,12 +7,18 @@ import (
type
WalletCoinRelation
struct
{
type
WalletCoinRelation
struct
{
PlatformId
int
PlatformId
int
CoinId
int
CoinId
int
Coin
Info
models
.
Coi
n
Coin
Condition
CoinConditio
n
PageNum
int
PageNum
int
PageSize
int
PageSize
int
}
}
type
CoinCondition
struct
{
Name
string
Chain
string
Platform
string
}
func
(
w
*
WalletCoinRelation
)
GetAll
()
([]
*
models
.
Coin
,
error
)
{
func
(
w
*
WalletCoinRelation
)
GetAll
()
([]
*
models
.
Coin
,
error
)
{
var
wallet_coin_relations
[]
*
models
.
WalletCoinRelation
var
wallet_coin_relations
[]
*
models
.
WalletCoinRelation
...
@@ -61,6 +67,9 @@ func (c *WalletCoinRelation) Delete() error {
...
@@ -61,6 +67,9 @@ func (c *WalletCoinRelation) Delete() error {
return
models
.
DeleteWalletCoinRelation
(
c
.
PlatformId
,
c
.
CoinId
)
return
models
.
DeleteWalletCoinRelation
(
c
.
PlatformId
,
c
.
CoinId
)
}
}
type
Condition
struct
{
}
func
(
c
*
WalletCoinRelation
)
getMaps
()
(
map
[
string
]
interface
{})
{
func
(
c
*
WalletCoinRelation
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
maps
:=
make
(
map
[
string
]
interface
{})
...
@@ -72,5 +81,18 @@ func (c *WalletCoinRelation) getMaps() (map[string]interface{}) {
...
@@ -72,5 +81,18 @@ func (c *WalletCoinRelation) getMaps() (map[string]interface{}) {
maps
[
"coin_id"
]
=
c
.
CoinId
maps
[
"coin_id"
]
=
c
.
CoinId
}
}
var
condition
=
make
(
map
[
string
]
interface
{})
if
c
.
CoinCondition
.
Name
!=
""
{
condition
[
"name"
]
=
c
.
CoinCondition
.
Name
}
if
c
.
CoinCondition
.
Chain
!=
""
{
condition
[
"chain"
]
=
c
.
CoinCondition
.
Chain
}
if
c
.
CoinCondition
.
Platform
!=
""
{
condition
[
"platform"
]
=
c
.
CoinCondition
.
Platform
}
maps
[
"condition"
]
=
condition
return
maps
return
maps
}
}
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