Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
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
1
Merge Requests
1
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
szh
chain33-pai
Commits
2a171129
Commit
2a171129
authored
Dec 18, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加程序版本接口
parent
0ade436f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
88 deletions
+73
-88
README.md
README.md
+16
-53
raspVersion.go
models/raspVersion.go
+20
-0
pai.go
routers/api/v1/pai.go
+20
-0
router.go
routers/router.go
+1
-35
pai.go
service/pai_service/pai.go
+4
-0
rasp_version.go
service/version_service/rasp_version.go
+12
-0
No files found.
README.md
View file @
2a171129
# 树莓派 bty主链ticket统计和接口服务
# 树莓派 bty主链ticket统计和接口服务
## Installation
## 接口
```
$ go get chain33-pai
```
## How to run
### Required
-
Mysql
-
Redis
### Ready
### 获取程序最新版本
URL /pai/latestversion
create database raspberry docs/sql/raspberry.sql)
请求方法 post json
### Conf
You should modify
`conf/app.ini`
|参数|类型|是否必填|说明|
|-|-|-|-|
|type|int32|是|1 bityuan 2 chain33-pai|
```
```
[database]
response
Type = mysql
{
User = root
"code":200,
Password =
"msg":"ok",
Host = 127.0.0.1:3306
"data":"0.x.x"
Name = blog
}
TablePrefix = blog_
[redis]
Host = 127.0.0.1:6379
Password =
MaxIdle = 30
MaxActive = 30
IdleTimeout = 200
...
```
```
### Run
## 统计服务
```
由php端统计矿机数据
$ cd $GOPATH/src/chain33-pai
\ No newline at end of file
$ go run ./cmd/api/main.go
$ go run ./cmd/parser/main.go
```
Project information and existing API
```
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET /api/v1/articles --> chain33-pai/routers/api/v1.GetArticles (4 handlers)
```
\ No newline at end of file
models/raspVersion.go
0 → 100644
View file @
2a171129
package
models
type
RaspVersion
struct
{
//Model
Id
int64
`json:"id" gorm:"PRIMARY_KEY"`
Version
string
`json:"version"`
Type
int32
`json:"type"`
Addtime
int64
`json:"addtime"`
}
// GetHeight get lastheight in chain33
func
GetLatestVersion
(
t
int32
)
(
string
,
error
)
{
var
rasp
RaspVersion
err
:=
db
.
Model
(
&
RaspVersion
{})
.
Where
(
"type = ?"
,
t
)
.
Order
(
"id desc"
)
.
First
(
&
rasp
)
.
Error
if
err
!=
nil
{
return
""
,
err
}
return
rasp
.
Version
,
nil
}
routers/api/v1/pai.go
View file @
2a171129
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"chain33-pai/service/stat_service"
"chain33-pai/service/stat_service"
"chain33-pai/pkg/logging"
"chain33-pai/pkg/logging"
"chain33-pai/models"
"chain33-pai/models"
"chain33-pai/service/version_service"
)
)
...
@@ -85,4 +86,22 @@ func RecordMineTime(c *gin.Context) {
...
@@ -85,4 +86,22 @@ func RecordMineTime(c *gin.Context) {
return
return
}
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
nil
)
}
func
GetVersion
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
var
req
pai_service
.
ReqVersion
err
:=
c
.
ShouldBindJSON
(
&
req
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
INVALID_PARAMS
,
nil
)
return
}
var
v
version_service
.
RaspVersion
version
,
err
:=
v
.
GetLatestVersion
(
req
.
Type
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
nil
)
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
version
)
}
}
\ No newline at end of file
routers/router.go
View file @
2a171129
...
@@ -25,47 +25,13 @@ func InitRouter() *gin.Engine {
...
@@ -25,47 +25,13 @@ func InitRouter() *gin.Engine {
r
.
Use
(
gin
.
Logger
())
r
.
Use
(
gin
.
Logger
())
r
.
Use
(
gin
.
Recovery
())
r
.
Use
(
gin
.
Recovery
())
r
.
Use
(
Cors
())
r
.
Use
(
Cors
())
//r.StaticFS("/export", http.Dir(export.GetExcelFullPath()))
//r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
//r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))
//r.GET("/auth", api.GetAuth)
//r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//r.POST("/upload", api.UploadImage)
apiv1
:=
r
.
Group
(
"/pai"
)
apiv1
:=
r
.
Group
(
"/pai"
)
//获取树莓派基本信息
//获取树莓派基本信息
//apiv1.Any("",Cors())
//apiv1.Any("",Cors())
apiv1
.
POST
(
"/ticketinfo"
,
v1
.
GetTicketInfo
)
apiv1
.
POST
(
"/ticketinfo"
,
v1
.
GetTicketInfo
)
apiv1
.
POST
(
"/minetime"
,
v1
.
RecordMineTime
)
apiv1
.
POST
(
"/minetime"
,
v1
.
RecordMineTime
)
//apiv1.Use(jwt.JWT())
apiv1
.
POST
(
"/latestversion"
,
v1
.
GetVersion
)
//{
//
// //获取标签列表
// apiv1.GET("/tags", v1.GetTags)
// //新建标签
// apiv1.POST("/tags", v1.AddTag)
// //更新指定标签
// apiv1.PUT("/tags/:id", v1.EditTag)
// //删除指定标签
// apiv1.DELETE("/tags/:id", v1.DeleteTag)
// //导出标签
// r.POST("/tags/export", v1.ExportTag)
// //导入标签
// r.POST("/tags/import", v1.ImportTag)
//
// //获取文章列表
// apiv1.GET("/articles", v1.GetArticles)
// //获取指定文章
// apiv1.GET("/articles/:id", v1.GetArticle)
// //新建文章
// apiv1.POST("/articles", v1.AddArticle)
// //更新指定文章
// apiv1.PUT("/articles/:id", v1.EditArticle)
// //删除指定文章
// apiv1.DELETE("/articles/:id", v1.DeleteArticle)
// //生成文章海报
// apiv1.POST("/articles/poster/generate", v1.GenerateArticlePoster)
//}
return
r
return
r
}
}
...
...
service/pai_service/pai.go
View file @
2a171129
...
@@ -53,6 +53,10 @@ type ReqMineTime struct {
...
@@ -53,6 +53,10 @@ type ReqMineTime struct {
Flag
string
`json:"flag"`
Flag
string
`json:"flag"`
}
}
type
ReqVersion
struct
{
Type
int32
`json:"type" binding:"required"`
}
func
(
p
*
Pai
)
GetConfig
()
bool
{
func
(
p
*
Pai
)
GetConfig
()
bool
{
if
pai_serial
!=
""
{
if
pai_serial
!=
""
{
p
.
Serial
=
pai_serial
p
.
Serial
=
pai_serial
...
...
service/version_service/rasp_version.go
0 → 100644
View file @
2a171129
package
version_service
import
"chain33-pai/models"
type
RaspVersion
struct
{
}
func
(
r
*
RaspVersion
)
GetLatestVersion
(
t
int32
)
(
string
,
error
)
{
return
models
.
GetLatestVersion
(
t
)
}
\ No newline at end of file
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