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
9e52d17a
Commit
9e52d17a
authored
Aug 09, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改返回数据内容
parent
034fabaa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
36 deletions
+38
-36
coin.go
models/coin.go
+21
-30
coinRecommend.go
models/coinRecommend.go
+3
-4
coinRecommend.go
routers/api/v1/coinRecommend.go
+14
-1
coinRecommend.go
service/coinRecommend_service/coinRecommend.go
+0
-1
No files found.
models/coin.go
View file @
9e52d17a
...
@@ -7,38 +7,29 @@ import (
...
@@ -7,38 +7,29 @@ import (
type
Coin
struct
{
type
Coin
struct
{
Model
Model
//Id int `gorm:"primary_key"`
Id
int
`json:"primary_key,omitempty"`
Sid
string
`json:"sid"`
Sid
string
`json:"sid,omitempty"`
Name
string
`json:"name"`
Name
string
`json:"name,omitempty"`
OptionalName
string
`json:"optional_name"`
OptionalName
string
`json:"optional_name,omitempty"`
Nickname
string
`json:"nickname"`
Nickname
string
`json:"nickname,omitempty"`
Icon
string
`json:"icon"`
Icon
string
`json:"icon,omitempty"`
Introduce
string
`json:"introduce"`
Introduce
string
`json:"introduce,omitempty"`
Official
string
`json:"official"`
Official
string
`json:"official,omitempty"`
Paper
string
`json:"paper"`
Paper
string
`json:"paper,omitempty"`
Exchange
int
`json:"exchange"`
Exchange
int
`json:"exchange,omitempty"`
Platform
string
`json:"platform"`
Platform
string
`json:"platform,omitempty"`
Chain
string
`json:"chain"`
Chain
string
`json:"chain,omitempty"`
Release
string
`json:"release"`
Release
string
`json:"release,omitempty"`
Price
float64
`json:"price"`
Price
float64
`json:"price,omitempty"`
AreaSearch
string
`json:"area_search"`
AreaSearch
string
`json:"area_search,omitempty"`
PublishCount
float64
`json:"publish_count"`
PublishCount
float64
`json:"publish_count,omitempty"`
CirculateCount
float64
`json:"circulate_count"`
CirculateCount
float64
`json:"circulate_count,omitempty"`
Decimals
int
`json:"decimals"`
Decimals
int
`json:"decimals,omitempty"`
Address
string
`json:"address"`
Address
string
`json:"address,omitempty"`
PlatformId
string
`json:"platform_id"`
PlatformId
string
`json:"platform_id,omitempty"`
Treaty
int
`json:"treaty"`
Treaty
int
`json:"treaty,omitempty"`
//Quotation Quotation `json:"quotation,omitempty"`
}
}
//type Quotation struct {
// Price float64 `json:"price"`
// Dollar float64 `json:"dollar"`
// Publish_Count float64 `json:"publish_count"`
// Circulate_Count float64 `json:"circulate_count"`
//}
func
ExistCoinById
(
id
int
)
(
bool
,
error
)
{
func
ExistCoinById
(
id
int
)
(
bool
,
error
)
{
var
coin
Coin
var
coin
Coin
err
:=
db
.
Select
(
"id"
)
.
Where
(
"id = ?"
,
id
)
.
First
(
&
coin
)
.
Error
err
:=
db
.
Select
(
"id"
)
.
Where
(
"id = ?"
,
id
)
.
First
(
&
coin
)
.
Error
...
...
models/coinRecommend.go
View file @
9e52d17a
...
@@ -7,16 +7,15 @@ import (
...
@@ -7,16 +7,15 @@ import (
type
CoinRecommend
struct
{
type
CoinRecommend
struct
{
Model
Model
Id
int
`json:"id"`
Id
int
`json:"primary_key,omitempty"`
Cid
int
`json:"cid"`
Recommend
int
`json:"recommend"`
Recommend
int
`json:"recommend"`
PlatformId
int
`json:"platform_id"`
PlatformId
int
`json:"platform_id"`
Sort
int
`json:"sort"`
Sort
int
`json:"sort"`
Type
int
`json:"type"`
Type
int
`json:"type"`
Chain
string
`json:"chain"`
Chain
string
`json:"chain"`
//Coin Coin `gorm:"foreignkey:Cid"`
Coin
Coin
`gorm:"foreignkey:Cid"`
Cid
int
`json:"cid" gorm:"index"`
//用于声明这个字段为索引,如果你使用了自动迁移功能则会有所影响,在不使用则无影响
Coin
Coin
`json:"coin"`
//字段,实际是一个嵌套的struct,它利用TagID与Tag模型相互关联,在执行查询的时候,能够达到Article、Tag关联查询的功能
}
}
func
(
c
CoinRecommend
)
TableName
()
string
{
func
(
c
CoinRecommend
)
TableName
()
string
{
...
...
routers/api/v1/coinRecommend.go
View file @
9e52d17a
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"bwallet/pkg/util"
"bwallet/pkg/util"
"bwallet/pkg/setting"
"bwallet/pkg/setting"
"bwallet/service/coinRecommend_service"
"bwallet/service/coinRecommend_service"
"bwallet/service/coin_service"
)
)
type
AddCoinRecommendForm
struct
{
type
AddCoinRecommendForm
struct
{
...
@@ -32,18 +33,30 @@ type EditCoinRecommendForm struct {
...
@@ -32,18 +33,30 @@ type EditCoinRecommendForm struct {
}
}
func
(
cr
*
AddCoinRecommendForm
)
Valid
(
v
*
validation
.
Validation
)
{
func
(
cr
*
AddCoinRecommendForm
)
Valid
(
v
*
validation
.
Validation
)
{
coinService
:=
coin_service
.
Coin
{
Id
:
cr
.
Cid
}
exists
,
_
:=
coinService
.
ExistById
()
if
(
!
exists
)
{
v
.
SetError
(
"Cid"
,
"所推荐币种不存在"
)
}
coinRecommendService
:=
coinRecommend_service
.
CoinRecommend
{
coinRecommendService
:=
coinRecommend_service
.
CoinRecommend
{
Cid
:
cr
.
Cid
,
Cid
:
cr
.
Cid
,
PlatformId
:
cr
.
PlatformId
,
PlatformId
:
cr
.
PlatformId
,
Type
:
cr
.
Type
,
Type
:
cr
.
Type
,
Chain
:
cr
.
Chain
,
Chain
:
cr
.
Chain
,
}
}
total
,
_
:=
coinRecommendService
.
Count
()
total
,
_
:=
coinRecommendService
.
Count
()
if
total
>
0
{
if
total
>
0
{
v
.
SetError
(
"Cid"
,
"推荐币种已经存在"
)
v
.
SetError
(
"Cid"
,
"推荐币种已经存在"
)
}
}
}
func
(
cr
*
EditCoinRecommendForm
)
Valid
(
v
*
validation
.
Validation
)
{
coinService
:=
coin_service
.
Coin
{
Id
:
cr
.
Cid
}
exists
,
_
:=
coinService
.
ExistById
()
if
(
!
exists
)
{
v
.
SetError
(
"Cid"
,
"所推荐币种不存在"
)
}
}
}
func
GetCoinRecommend
(
c
*
gin
.
Context
)
{
func
GetCoinRecommend
(
c
*
gin
.
Context
)
{
...
...
service/coinRecommend_service/coinRecommend.go
View file @
9e52d17a
...
@@ -97,6 +97,5 @@ func (c *CoinRecommend) getMaps() (map[string]interface{}) {
...
@@ -97,6 +97,5 @@ func (c *CoinRecommend) getMaps() (map[string]interface{}) {
maps
[
"chain"
]
=
c
.
Chain
maps
[
"chain"
]
=
c
.
Chain
}
}
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