Commit 5b550f00 authored by szh's avatar szh

添加接口 版本统计

parent ca42f747
/*
/*
Navicat MySQL Data Transfer
Source Server : localhost
......@@ -126,4 +126,17 @@ CREATE TABLE `rasp_feedback_list` (
`addtime` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `addr` (`addr`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户反馈历史';
\ No newline at end of file
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户反馈历史';
-- ----------------------------
-- Table structure for rasp_dev_version
-- ----------------------------
DROP TABLE IF EXISTS `rasp_dev_version`;
CREATE TABLE `rasp_dev_version` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`addr` varchar(255) NOT NULL DEFAULT '',
`version` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`Id`),
KEY `addr` (`addr`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备版本统计表';
\ No newline at end of file
package models
type RaspDevVersion struct {
//Model
Id int64 `json:"id" gorm:"PRIMARY_KEY"`
Version string `json:"version"`
Addr string `json:"addr"`
}
//
func UpdateDevVersion(params map[string]string) error {
var version RaspDevVersion
err := db.Where(RaspDevVersion{Addr: params["addr"]}).Assign(RaspDevVersion{Version: params["version"]}).FirstOrCreate(&version).Error
if err != nil {
return err
}
return nil
}
......@@ -199,3 +199,36 @@ func GetFeedList(c *gin.Context){
"count":count,
})
}
func GetUploadInfo(c *gin.Context){
appG:=app.Gin{C:c}
err:=appG.C.ShouldBindJSON(&KP)
if err!=nil{
appG.Response(http.StatusOK, e.INVALID_PARAMS, nil)
return
}
if KP["version"] == "" || KP["addr"] == "" {
appG.Response(http.StatusOK, e.INVALID_PARAMS, nil)
return
}
err = models.UpdateDevVersion(KP)
if err != nil {
appG.Response(http.StatusOK, e.ERROR, nil)
return
}
appG.Response(http.StatusOK, e.SUCCESS, nil)
}
func GetUploadTest(c *gin.Context){
appG:=app.Gin{C:c}
err:=appG.C.ShouldBindJSON(&KP)
if err!=nil{
appG.Response(http.StatusOK, e.INVALID_PARAMS, nil)
return
}
logging.Info("uploadtest","report",KP)
appG.Response(http.StatusOK, e.SUCCESS, nil)
}
\ No newline at end of file
......@@ -35,6 +35,8 @@ func InitRouter() *gin.Engine {
apiv1.POST("/feedback",v1.FeedBack)
apiv1.POST("/iscomplete",v1.IsComplete)
apiv1.POST("/getfeedlist",v1.GetFeedList)
apiv1.POST("/uploadinfo",v1.GetUploadInfo)
apiv1.POST("/uploadtest",v1.GetUploadTest)
return r
}
......
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