Commit 6b1642d2 authored by YPJ's avatar YPJ

新增versiontest接口

parent 0d78ac63
package models
type RaspVersionTest 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 GetVersionTest(t int32) (string, error) {
var rasp RaspVersionTest
err := db.Model(&RaspVersionTest{}).Where("type = ?",t).Order("id desc").First(&rasp).Error
if err != nil {
return "",err
}
return rasp.Version, nil
}
...@@ -315,3 +315,21 @@ func GetTest(c *gin.Context){ ...@@ -315,3 +315,21 @@ func GetTest(c *gin.Context){
appG.Response(http.StatusOK, e.SUCCESS, nil) appG.Response(http.StatusOK, e.SUCCESS, nil)
} }
func GetVersionTest(c *gin.Context) {
appG:=app.Gin{C:c}
var req pai_service.ReqVersionTest
err := c.ShouldBindJSON(&req)
if err != nil {
appG.Response(http.StatusOK, e.INVALID_PARAMS, nil)
return
}
var v version_service.RaspVersionTest
version,err := v.GetVersionTest(req.Type)
if err != nil {
appG.Response(http.StatusOK, e.ERROR, nil)
return
}
appG.Response(http.StatusOK, e.SUCCESS, version)
}
\ No newline at end of file
...@@ -40,6 +40,7 @@ func InitRouter() *gin.Engine { ...@@ -40,6 +40,7 @@ func InitRouter() *gin.Engine {
apiv1.POST("/uploadinfo",v1.GetUploadInfo) apiv1.POST("/uploadinfo",v1.GetUploadInfo)
apiv1.POST("/uploadtest",v1.GetUploadTest) apiv1.POST("/uploadtest",v1.GetUploadTest)
apiv1.POST("/test",v1.GetTest) apiv1.POST("/test",v1.GetTest)
apiv1.POST("/versiontest",v1.GetVersionTest)
return r return r
} }
......
...@@ -62,6 +62,10 @@ type ReqVersion struct { ...@@ -62,6 +62,10 @@ type ReqVersion struct {
Type int32 `json:"type" binding:"required"` Type int32 `json:"type" binding:"required"`
} }
type ReqVersionTest 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
......
package version_service
import "chain33-pai/models"
type RaspVersionTest struct {
}
func (r *RaspVersionTest) GetVersionTest(t int32) (string,error) {
return models.GetVersionTest(t)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment