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
3261dd3b
Commit
3261dd3b
authored
Jul 22, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
94fa7036
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
181 additions
and
136 deletions
+181
-136
redis.go
pkg/gredis/redis.go
+47
-5
news.go
routers/api/app/news.go
+49
-0
chain.go
routers/api/backend/chain.go
+1
-1
coin.go
routers/api/backend/coin.go
+1
-50
news.go
routers/api/backend/news.go
+1
-1
opernation_log.go
routers/api/backend/opernation_log.go
+1
-1
recommend_coin.go
routers/api/backend/recommend_coin.go
+1
-1
supported_chain.go
routers/api/backend/supported_chain.go
+1
-1
supported_currency.go
routers/api/backend/supported_currency.go
+1
-1
trusteeship_coin.go
routers/api/backend/trusteeship_coin.go
+1
-1
upload.go
routers/api/backend/upload.go
+1
-1
wallet.go
routers/api/backend/wallet.go
+1
-1
wallet_coin_relation.go
routers/api/backend/wallet_coin_relation.go
+1
-1
wallet_recommend_category.go
routers/api/backend/wallet_recommend_category.go
+1
-1
router.go
routers/router.go
+69
-66
news.go
validate_service/news.go
+4
-4
No files found.
pkg/gredis/redis.go
View file @
3261dd3b
...
...
@@ -36,6 +36,7 @@ func Setup() error {
return
nil
}
//设置指定 key 的值
func
Set
(
key
string
,
data
interface
{},
time
int
,
db
int
)
error
{
conn
:=
RedisConn
.
Get
()
defer
conn
.
Close
()
...
...
@@ -63,6 +64,24 @@ func Set(key string, data interface{}, time int, db int) error {
return
nil
}
//获取指定 key 的值
func
Get
(
key
string
,
db
int
)
([]
byte
,
error
)
{
conn
:=
RedisConn
.
Get
()
defer
conn
.
Close
()
if
_
,
err
:=
conn
.
Do
(
"SELECT"
,
db
);
err
!=
nil
{
conn
.
Close
()
return
nil
,
err
}
reply
,
err
:=
redis
.
Bytes
(
conn
.
Do
(
"GET"
,
key
))
if
err
!=
nil
{
return
nil
,
err
}
return
reply
,
nil
}
func
Exists
(
key
string
,
db
int
)
bool
{
conn
:=
RedisConn
.
Get
()
defer
conn
.
Close
()
...
...
@@ -80,7 +99,31 @@ func Exists(key string, db int) bool {
return
exists
}
func
Get
(
key
string
,
db
int
)
([]
byte
,
error
)
{
//向有序集合添加一个或多个成员,或者更新已存在成员的分数
func
ZAdd
(
key
string
,
score
int
,
data
interface
{},
db
int
)
error
{
conn
:=
RedisConn
.
Get
()
defer
conn
.
Close
()
value
,
err
:=
json
.
Marshal
(
data
)
if
err
!=
nil
{
return
err
}
if
_
,
err
:=
conn
.
Do
(
"SELECT"
,
db
);
err
!=
nil
{
conn
.
Close
()
return
err
}
_
,
err
=
conn
.
Do
(
"ZADD"
,
key
,
score
,
value
)
if
err
!=
nil
{
return
err
}
return
nil
}
//通过索引区间返回有序集合指定区间内的成员
func
ZRange
(
key
string
,
start
,
stop
int
,
db
int
)
([]
string
,
error
)
{
conn
:=
RedisConn
.
Get
()
defer
conn
.
Close
()
...
...
@@ -89,12 +132,12 @@ func Get(key string, db int) ([]byte, error) {
return
nil
,
err
}
rep
ly
,
err
:=
redis
.
Bytes
(
conn
.
Do
(
"GET"
,
key
))
rep
,
err
:=
redis
.
Strings
(
conn
.
Do
(
"ZRANGE"
,
key
,
start
,
stop
))
if
err
!=
nil
{
return
nil
,
err
}
return
rep
ly
,
nil
return
rep
,
nil
}
func
Delete
(
key
string
,
db
int
)
(
bool
,
error
)
{
...
...
@@ -107,4 +150,4 @@ func Delete(key string, db int) (bool, error) {
}
return
redis
.
Bool
(
conn
.
Do
(
"DEL"
,
key
))
}
\ No newline at end of file
}
routers/api/app/news.go
0 → 100644
View file @
3261dd3b
package
app
import
(
"bwallet/pkg/errno"
"bwallet/pkg/gredis"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/service/news_service"
"fmt"
"github.com/gin-gonic/gin"
"strconv"
)
func
GetOneNews
(
c
*
gin
.
Context
)
{
//gredis.ZAdd("sorted_set", 2020716, "二零二零零七一六", 3)
//gredis.ZAdd("sorted_set", 2020718, "二零二零零七一八", 3)
//gredis.ZAdd("sorted_set", 2020719, "二零二零零七一九", 3)
//gredis.ZAdd("sorted_set", 2020717, "二零二零零七一七", 3)
fmt
.
Println
(
gredis
.
ZRange
(
"sorted_set"
,
1
,
4
,
3
))
}
func
GetNews
(
c
*
gin
.
Context
)
{
platform_id
,
_
:=
strconv
.
Atoi
(
c
.
Request
.
Header
.
Get
(
"FZM-PLATFORM-ID"
))
newsService
:=
news_service
.
News
{
PlatformId
:
platform_id
,
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
total
,
err
:=
newsService
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountNews
,
nil
)
return
}
news
,
err
:=
newsService
.
GetAll
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
data
:=
make
(
map
[
string
]
interface
{})
data
[
"items"
]
=
news
data
[
"total"
]
=
total
handler
.
SendResponse
(
c
,
nil
,
data
)
}
routers/api/
v1
/chain.go
→
routers/api/
backend
/chain.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/coin.go
→
routers/api/
backend
/coin.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/app"
...
...
@@ -8,7 +8,6 @@ import (
"bwallet/pkg/util"
"bwallet/service/auth_service"
"bwallet/service/coin_service"
"bwallet/service/platform_chain_service"
"bwallet/service/recommend_coin_service"
"bwallet/service/trusteeship_coin_service"
"bwallet/validate_service"
...
...
@@ -56,55 +55,7 @@ func GetCoin(c *gin.Context) {
return
}
func
GetUserChainsBak
(
c
*
gin
.
Context
)
{
data
:=
make
(
map
[
string
]
interface
{})
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
authService
:=
auth_service
.
Auth
{
Token
:
token
}
auth
,
_
:=
authService
.
GetUserInfo
()
group
:=
auth
.
Group
coinService
:=
coin_service
.
Coin
{}
if
(
"administrator"
!=
group
)
{
platformChainService
:=
platform_chain_service
.
PlatformChain
{
PlatformId
:
auth
.
PlatformId
,
IsPrimary
:
1
,
}
platform_chain
,
err
:=
platformChainService
.
GetAll
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
var
platform
string
for
_
,
val
:=
range
platform_chain
{
if
nil
!=
val
.
ChainInfo
{
platform
=
val
.
ChainInfo
.
Platform
}
}
if
""
==
platform
{
data
[
"items"
]
=
nil
data
[
"total"
]
=
0
handler
.
SendResponse
(
c
,
nil
,
data
)
return
}
coinService
.
Platform
=
platform
}
platforms
,
err
:=
coinService
.
GetAllPlatform
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
data
[
"items"
]
=
platforms
data
[
"total"
]
=
len
(
platforms
)
handler
.
SendResponse
(
c
,
nil
,
data
)
}
func
GetCoins
(
c
*
gin
.
Context
)
{
//gredis.Set("2020716", "二零二零零七一六", 20, 1)
valid
:=
validation
.
Validation
{}
name
:=
""
...
...
routers/api/
v1
/news.go
→
routers/api/
backend
/news.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/opernation_log.go
→
routers/api/
backend
/opernation_log.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/recommend_coin.go
→
routers/api/
backend
/recommend_coin.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/supported_chain.go
→
routers/api/
backend
/supported_chain.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/supported_currency.go
→
routers/api/
backend
/supported_currency.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/trusteeship_coin.go
→
routers/api/
backend
/trusteeship_coin.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/upload.go
→
routers/api/
backend
/upload.go
View file @
3261dd3b
package
v1
package
backend
import
(
"github.com/gin-gonic/gin"
...
...
routers/api/
v1
/wallet.go
→
routers/api/
backend
/wallet.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/wallet_coin_relation.go
→
routers/api/
backend
/wallet_coin_relation.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/api/
v1
/wallet_recommend_category.go
→
routers/api/
backend
/wallet_recommend_category.go
View file @
3261dd3b
package
v1
package
backend
import
(
"bwallet/pkg/errno"
...
...
routers/router.go
View file @
3261dd3b
...
...
@@ -7,8 +7,8 @@ import (
"bwallet/middleware/auth"
"bwallet/pkg/upload"
"bwallet/routers/api"
"bwallet/routers/api/
v1
"
"bwallet/routers/api
/app
"
"bwallet/routers/api/
backend
"
"net/http"
)
...
...
@@ -22,77 +22,80 @@ func InitRouter() *gin.Engine {
r
.
StaticFS
(
"/upload/file"
,
http
.
Dir
(
upload
.
GetFileFullPath
()))
//r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))
r
.
POST
(
"/auth"
,
api
.
GetAuth
)
r
.
POST
(
"/upload"
,
api
.
UploadFile
)
//
r.POST("/auth", api.GetAuth)
//
r.POST("/upload", api.UploadFile)
//r.POST("/upload", api.UploadImage)
client
:=
r
.
Group
(
"/interface"
)
client
.
GET
(
"/news"
,
app
.
GetNews
)
client
.
GET
(
"/one-news"
,
app
.
GetOneNews
)
api
:=
r
.
Group
(
"/api"
)
api
.
Use
(
auth
.
AUTH
())
api
.
POST
(
"/log"
,
v1
.
AddOperationLog
)
api
.
GET
(
"/logs"
,
v1
.
GetOperationLogs
)
api
.
POST
(
"/log"
,
backend
.
AddOperationLog
)
api
.
GET
(
"/logs"
,
backend
.
GetOperationLogs
)
api
.
Use
(
log
.
LogMiddleware
(
e
.
HandleTableName
))
{
//api.POST("/upload",v1.Upload)
api
.
GET
(
"/coins"
,
v1
.
GetCoins
)
api
.
POST
(
"/coin"
,
v1
.
AddCoin
)
api
.
GET
(
"/coin"
,
v1
.
GetCoin
)
api
.
PUT
(
"/coin"
,
v1
.
EditCoin
)
api
.
DELETE
(
"/coin"
,
v1
.
DeleteCoin
)
api
.
GET
(
"/primary-chains"
,
v1
.
GetCoinChains
)
api
.
GET
(
"/types"
,
v1
.
GetTypes
)
api
.
GET
(
"/coin-relation"
,
v1
.
GetWalletCoinRelationCoinRelations
)
api
.
POST
(
"/coin-relation"
,
v1
.
AddWalletCoinRelationCoinRelation
)
api
.
DELETE
(
"/coin-relation"
,
v1
.
DeleteWalletCoinRelationCoinRelation
)
//api.GET("/get-platform", v1.GetCoinsPlatform)
api
.
GET
(
"/wallets"
,
v1
.
GetWallets
)
api
.
POST
(
"/wallet"
,
v1
.
AddWallet
)
api
.
GET
(
"/wallet"
,
v1
.
GetWallet
)
api
.
PUT
(
"/wallet"
,
v1
.
EditWallet
)
api
.
DELETE
(
"/wallet"
,
v1
.
DeleteWallet
)
api
.
GET
(
"/news"
,
v1
.
GetNews
)
api
.
POST
(
"/news"
,
v1
.
AddNews
)
api
.
GET
(
"/one-news"
,
v1
.
GetOneNews
)
api
.
PUT
(
"/news"
,
v1
.
EditNews
)
api
.
DELETE
(
"/news"
,
v1
.
DeleteNews
)
api
.
GET
(
"/chains"
,
v1
.
GetChains
)
api
.
POST
(
"/chain"
,
v1
.
AddChain
)
api
.
GET
(
"/chain"
,
v1
.
GetChain
)
api
.
PUT
(
"/chain"
,
v1
.
EditChain
)
api
.
DELETE
(
"/chain"
,
v1
.
DeleteChain
)
api
.
GET
(
"/user-chains"
,
v1
.
GetUserChains
)
api
.
GET
(
"/recommend-categories"
,
v1
.
GetWalletRecommendCategories
)
api
.
POST
(
"/recommend-category"
,
v1
.
AddWalletRecommendCategory
)
api
.
GET
(
"/recommend-category"
,
v1
.
GetWalletRecommendCategory
)
api
.
DELETE
(
"/recommend-category"
,
v1
.
DeleteWalletRecommendCategory
)
api
.
PUT
(
"/recommend-category"
,
v1
.
EditWalletRecommendCategory
)
api
.
GET
(
"/recommend-coins"
,
v1
.
GetRecommendCoins
)
api
.
POST
(
"/recommend-coin"
,
v1
.
AddRecommendCoin
)
api
.
PUT
(
"/recommend-coin"
,
v1
.
EditRecommendCoin
)
api
.
DELETE
(
"/recommend-coin"
,
v1
.
DeleteRecommendCoin
)
api
.
GET
(
"/trusteeship-coins"
,
v1
.
GetTrusteeshipCoins
)
api
.
POST
(
"/trusteeship-coin"
,
v1
.
AddTrusteeshipCoin
)
api
.
PUT
(
"/trusteeship-coin"
,
v1
.
EditTrusteeshipCoin
)
api
.
DELETE
(
"/trusteeship-coin"
,
v1
.
DeleteTrusteeshipCoin
)
api
.
GET
(
"/supported-currencies"
,
v1
.
GetSupportedCurrencies
)
api
.
POST
(
"/supported-currency"
,
v1
.
AddSupportedCurrency
)
api
.
GET
(
"/supported-currency"
,
v1
.
GetSupportedCurrency
)
api
.
PUT
(
"/supported-currency"
,
v1
.
EditSupportedCurrency
)
api
.
DELETE
(
"/supported-currency"
,
v1
.
DeleteSupportedCurrency
)
api
.
GET
(
"/currencies"
,
v1
.
GetCurrencies
)
api
.
GET
(
"/supported-chains"
,
v1
.
GetSupportedChains
)
api
.
POST
(
"/supported-chain"
,
v1
.
AddSupportedChain
)
api
.
DELETE
(
"/supported-chain"
,
v1
.
DeleteSupportedChain
)
//api.POST("/upload",backend.Upload)
api
.
GET
(
"/coins"
,
backend
.
GetCoins
)
api
.
POST
(
"/coin"
,
backend
.
AddCoin
)
api
.
GET
(
"/coin"
,
backend
.
GetCoin
)
api
.
PUT
(
"/coin"
,
backend
.
EditCoin
)
api
.
DELETE
(
"/coin"
,
backend
.
DeleteCoin
)
api
.
GET
(
"/primary-chains"
,
backend
.
GetCoinChains
)
api
.
GET
(
"/types"
,
backend
.
GetTypes
)
api
.
GET
(
"/coin-relation"
,
backend
.
GetWalletCoinRelationCoinRelations
)
api
.
POST
(
"/coin-relation"
,
backend
.
AddWalletCoinRelationCoinRelation
)
api
.
DELETE
(
"/coin-relation"
,
backend
.
DeleteWalletCoinRelationCoinRelation
)
//api.GET("/get-platform", backend.GetCoinsPlatform)
api
.
GET
(
"/wallets"
,
backend
.
GetWallets
)
api
.
POST
(
"/wallet"
,
backend
.
AddWallet
)
api
.
GET
(
"/wallet"
,
backend
.
GetWallet
)
api
.
PUT
(
"/wallet"
,
backend
.
EditWallet
)
api
.
DELETE
(
"/wallet"
,
backend
.
DeleteWallet
)
api
.
GET
(
"/news"
,
backend
.
GetNews
)
api
.
POST
(
"/news"
,
backend
.
AddNews
)
api
.
GET
(
"/one-news"
,
backend
.
GetOneNews
)
api
.
PUT
(
"/news"
,
backend
.
EditNews
)
api
.
DELETE
(
"/news"
,
backend
.
DeleteNews
)
api
.
GET
(
"/chains"
,
backend
.
GetChains
)
api
.
POST
(
"/chain"
,
backend
.
AddChain
)
api
.
GET
(
"/chain"
,
backend
.
GetChain
)
api
.
PUT
(
"/chain"
,
backend
.
EditChain
)
api
.
DELETE
(
"/chain"
,
backend
.
DeleteChain
)
api
.
GET
(
"/user-chains"
,
backend
.
GetUserChains
)
api
.
GET
(
"/recommend-categories"
,
backend
.
GetWalletRecommendCategories
)
api
.
POST
(
"/recommend-category"
,
backend
.
AddWalletRecommendCategory
)
api
.
GET
(
"/recommend-category"
,
backend
.
GetWalletRecommendCategory
)
api
.
DELETE
(
"/recommend-category"
,
backend
.
DeleteWalletRecommendCategory
)
api
.
PUT
(
"/recommend-category"
,
backend
.
EditWalletRecommendCategory
)
api
.
GET
(
"/recommend-coins"
,
backend
.
GetRecommendCoins
)
api
.
POST
(
"/recommend-coin"
,
backend
.
AddRecommendCoin
)
api
.
PUT
(
"/recommend-coin"
,
backend
.
EditRecommendCoin
)
api
.
DELETE
(
"/recommend-coin"
,
backend
.
DeleteRecommendCoin
)
api
.
GET
(
"/trusteeship-coins"
,
backend
.
GetTrusteeshipCoins
)
api
.
POST
(
"/trusteeship-coin"
,
backend
.
AddTrusteeshipCoin
)
api
.
PUT
(
"/trusteeship-coin"
,
backend
.
EditTrusteeshipCoin
)
api
.
DELETE
(
"/trusteeship-coin"
,
backend
.
DeleteTrusteeshipCoin
)
api
.
GET
(
"/supported-currencies"
,
backend
.
GetSupportedCurrencies
)
api
.
POST
(
"/supported-currency"
,
backend
.
AddSupportedCurrency
)
api
.
GET
(
"/supported-currency"
,
backend
.
GetSupportedCurrency
)
api
.
PUT
(
"/supported-currency"
,
backend
.
EditSupportedCurrency
)
api
.
DELETE
(
"/supported-currency"
,
backend
.
DeleteSupportedCurrency
)
api
.
GET
(
"/currencies"
,
backend
.
GetCurrencies
)
api
.
GET
(
"/supported-chains"
,
backend
.
GetSupportedChains
)
api
.
POST
(
"/supported-chain"
,
backend
.
AddSupportedChain
)
api
.
DELETE
(
"/supported-chain"
,
backend
.
DeleteSupportedChain
)
}
return
r
...
...
validate_service/news.go
View file @
3261dd3b
package
validate_service
type
News
struct
{
Title
string
`json:"title" validate:"requi
highlight
"`
Content
string
`json:"content" validate:"requi
highlight
"`
Title
string
`json:"title" validate:"requi
red
"`
Content
string
`json:"content" validate:"requi
red
"`
Top
uint8
`json:"top"`
Highlight
uint8
`json:"highlight"`
Status
uint8
`json:"status"`
PlatformId
int
`json:"platform_id"
validate:"requihighlight"
`
PlatformId
int
`json:"platform_id"`
}
type
EditNews
struct
{
News
Id
int
`json:"id" validate:"requi
highlight
"`
Id
int
`json:"id" validate:"requi
red
"`
}
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