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
1d2a72f7
Commit
1d2a72f7
authored
Mar 03, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推荐币种优化
parent
8965dea6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
43 deletions
+51
-43
go.mod
go.mod
+2
-0
go.sum
go.sum
+8
-0
recommend_coin.go
models/recommend_coin.go
+16
-10
coin.go
routers/api/v1/coin.go
+4
-3
recommend_coin.go
routers/api/v1/recommend_coin.go
+7
-13
recommend_coin.go
service/recommend_coin_service/recommend_coin.go
+10
-12
recommend_coin.go
validate_service/recommend_coin.go
+4
-5
No files found.
go.mod
View file @
1d2a72f7
...
...
@@ -20,12 +20,14 @@ require (
github.com/kr/pretty v0.2.0 // indirect
github.com/labstack/echo v3.3.10+incompatible // indirect
github.com/labstack/gommon v0.3.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/oxequa/interact v0.0.0-20171114182912-f8fb5795b5d7 // indirect
github.com/oxequa/realize v2.0.2+incompatible // indirect
github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a // indirect
github.com/pilu/fresh v0.0.0-20190826141211-0fa698148017 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/valyala/fasttemplate v1.1.0 // indirect
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
gopkg.in/go-playground/validator.v9 v9.29.1
gopkg.in/ini.v1 v1.51.1 // indirect
)
go.sum
View file @
1d2a72f7
...
...
@@ -128,10 +128,14 @@ github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRU
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
...
...
@@ -229,6 +233,10 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg=
...
...
models/recommend_coin.go
View file @
1d2a72f7
package
models
import
(
"github.com/jinzhu/gorm"
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
)
type
RecommendCoin
struct
{
Model
Id
int
`json:"primary_key,omitempty"`
Cid
int
`json:"cid"`
Recommend
int
`json:"recommend"`
PlatformId
int
`json:"platform_id"`
Sort
int
`json:"sort"`
Type
int
`json:"type"`
Id
int
`json:"primary_key,omitempty"`
Cid
int
`json:"cid"`
Sort
int
`json:"sort"`
PlatformId
int
`json:"platform_id"`
CategoryId
uint8
`json:"category_id"`
CoinInfo
*
Coin
`gorm:"foreignkey:Cid"`
}
...
...
@@ -72,10 +71,9 @@ func GetRecommendCoins(pageNum, pageSize int, maps interface{}) ([]*RecommendCoi
func
AddRecommendCoin
(
data
map
[
string
]
interface
{})
(
error
)
{
coinRecommend
:=
RecommendCoin
{
Cid
:
data
[
"cid"
]
.
(
int
),
Recommend
:
data
[
"recommend"
]
.
(
int
),
PlatformId
:
data
[
"platform_id"
]
.
(
int
),
Sort
:
data
[
"sort"
]
.
(
int
),
Type
:
data
[
"type"
]
.
(
int
),
PlatformId
:
data
[
"platform_id"
]
.
(
int
),
CategoryId
:
data
[
"category_id"
]
.
(
uint8
),
}
if
err
:=
db
.
Create
(
&
coinRecommend
)
.
Error
;
err
!=
nil
{
return
err
...
...
@@ -99,3 +97,11 @@ func DeleteRecommendCoin(id int) error {
return
nil
}
func
DeleteByCondition
(
maps
interface
{})
error
{
if
err
:=
db
.
Where
(
maps
)
.
Delete
(
RecommendCoin
{})
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
routers/api/v1/coin.go
View file @
1d2a72f7
...
...
@@ -6,6 +6,7 @@ import (
"bwallet/pkg/util"
"bwallet/service/auth_service"
"bwallet/service/coin_service"
"bwallet/service/recommend_coin_service"
"bwallet/validate_service"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
...
...
@@ -56,7 +57,6 @@ func GetCoins(c *gin.Context) {
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
...
...
@@ -84,7 +84,6 @@ func GetCoins(c *gin.Context) {
platform_id
=
com
.
StrTo
(
c
.
DefaultQuery
(
"platform_id"
,
"1"
))
.
MustInt
()
}
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
...
...
@@ -246,7 +245,6 @@ func DeleteCoin(c *gin.Context) {
return
}
valid
:=
validation
.
Validation
{}
id
:=
com
.
StrTo
(
c
.
Param
(
"id"
))
.
MustInt
()
valid
.
Min
(
id
,
1
,
"id"
)
.
Message
(
"ID必须大于0"
)
...
...
@@ -274,6 +272,9 @@ func DeleteCoin(c *gin.Context) {
return
}
recommendCoinService
:=
recommend_coin_service
.
RecommendCoin
{
Cid
:
id
}
recommendCoinService
.
DeleteByCondition
()
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
...
...
routers/api/v1/recommend_coin.go
View file @
1d2a72f7
...
...
@@ -28,20 +28,14 @@ func GetRecommendCoins(c *gin.Context) {
}
}
var
wallet_type
int
if
arg
:=
c
.
Query
(
"type"
);
arg
!=
""
{
wallet_type
=
com
.
StrTo
(
c
.
Query
(
"type"
))
.
MustInt
()
}
var
recommend
int
if
arg
:=
c
.
Query
(
"recommend"
);
arg
!=
""
{
recommend
=
com
.
StrTo
(
c
.
Query
(
"recommend"
))
.
MustInt
()
var
category_id
uint8
if
arg
:=
c
.
Query
(
"category_id"
);
arg
!=
""
{
category_id
=
com
.
StrTo
(
c
.
Query
(
"category_id"
))
.
MustUint8
()
}
recommendCoinService
:=
recommend_coin_service
.
RecommendCoin
{
PlatformId
:
platform_id
,
Type
:
wallet_type
,
Recommend
:
recommend
,
CategoryId
:
category_id
,
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
...
...
@@ -79,6 +73,7 @@ func AddRecommendCoin(c *gin.Context) {
//自定义验证
recommendCoinValidate
:=
recommend_coin_service
.
RecommendCoin
{
CategoryId
:
recommend_coin
.
CategoryId
,
PlatformId
:
recommend_coin
.
PlatformId
,
Cid
:
recommend_coin
.
Cid
,
}
...
...
@@ -107,10 +102,9 @@ func AddRecommendCoin(c *gin.Context) {
recommendCoinService
:=
recommend_coin_service
.
RecommendCoin
{
Cid
:
recommend_coin
.
Cid
,
Recommend
:
recommend_coin
.
Recommend
,
PlatformId
:
platform_id
,
Sort
:
recommend_coin
.
Sort
,
Type
:
recommend_coin
.
Type
,
PlatformId
:
platform_id
,
CategoryId
:
recommend_coin
.
CategoryId
,
}
if
err
:=
recommendCoinService
.
Add
();
err
!=
nil
{
...
...
service/recommend_coin_service/recommend_coin.go
View file @
1d2a72f7
...
...
@@ -7,10 +7,9 @@ import (
type
RecommendCoin
struct
{
Id
int
Cid
int
Recommend
int
PlatformId
int
Sort
int
Type
int
PlatformId
int
CategoryId
uint8
PageNum
int
PageSize
int
...
...
@@ -40,10 +39,9 @@ func (c *RecommendCoin) GetAll() ([]*models.RecommendCoin, error) {
func
(
c
*
RecommendCoin
)
Add
()
error
{
coinRecommend
:=
map
[
string
]
interface
{}{
"cid"
:
c
.
Cid
,
"recommend"
:
c
.
Recommend
,
"platform_id"
:
c
.
PlatformId
,
"sort"
:
c
.
Sort
,
"type"
:
c
.
Type
,
"platform_id"
:
c
.
PlatformId
,
"category_id"
:
c
.
CategoryId
,
}
if
err
:=
models
.
AddRecommendCoin
(
coinRecommend
);
err
!=
nil
{
...
...
@@ -71,6 +69,10 @@ func (c *RecommendCoin) Delete() error {
return
models
.
DeleteRecommendCoin
(
c
.
Id
)
}
func
(
c
*
RecommendCoin
)
DeleteByCondition
()
error
{
return
models
.
DeleteByCondition
(
c
.
getMaps
())
}
func
(
c
*
RecommendCoin
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
...
...
@@ -82,12 +84,8 @@ func (c *RecommendCoin) getMaps() (map[string]interface{}) {
maps
[
"cid"
]
=
c
.
Cid
}
if
c
.
Type
!=
0
{
maps
[
"type"
]
=
c
.
Type
}
if
c
.
Recommend
!=
0
{
maps
[
"recommend"
]
=
c
.
Recommend
if
c
.
CategoryId
!=
0
{
maps
[
"category_id"
]
=
c
.
CategoryId
}
return
maps
...
...
validate_service/recommend_coin.go
View file @
1d2a72f7
package
validate_service
type
RecommendCoin
struct
{
Cid
int
`json:"cid" validate:"required"`
Recommend
int
`json:"recommend" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
Sort
int
`json:"sort" validate:"required"`
Type
int
`json:"type" validate:"required"`
Cid
int
`json:"cid" validate:"required"`
Sort
int
`json:"sort" validate:"required"`
PlatformId
int
`json:"platform_id" validate:"required"`
CategoryId
uint8
`json:"category_id" validate:"required"`
}
type
EditRecommendCoin
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