Commit 213d0b62 authored by szh's avatar szh

更新feedlist接口 添加历史接口和表

parent 805b21f9
......@@ -98,4 +98,31 @@ CREATE TABLE `rasp_version` (
`type` tinyint(3) DEFAULT '0' COMMENT '类型 1 bityuan 2 chain33-pai',
`addtime` int(11) DEFAULT NULL COMMENT '添加时间',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='程序版本更新控制';
\ No newline at end of file
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='程序版本更新控制';
-- ----------------------------
-- Table structure for rasp_feedback
-- ----------------------------
DROP TABLE IF EXISTS `rasp_feedback`;
CREATE TABLE `rasp_feedback` (
`id` varchar(25) NOT NULL DEFAULT '',
`description` text,
`complete` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for rasp_feedback_list
-- ----------------------------
DROP TABLE IF EXISTS `rasp_feedback_list`;
CREATE TABLE `rasp_feedback_list` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`addr` varchar(255) NOT NULL DEFAULT '',
`description` text NOT NULL,
`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
package models
import (
"log"
"github.com/jinzhu/gorm"
)
type RaspFeedbackList struct {
Id string `json:"id" gorm:"PRIMARY_KEY"`
Addr string `json:"addr"`
Description string `json:"description"`
Addtime int64 `json:"addtime"`
}
type ReqRaspFeedbackList struct {
Addr string `json:"addr" binding:"required"`
Page int32 `json:"page"`
Pagesize int32 `json:"pagesize"`
}
func AddFeedBackList(fd RaspFeedbackList)bool{
err:=db.Create(&fd)
if err!=nil{
db.Save(&fd)
log.Println(err)
return false
}
return true
}
func GetAddrFeedBackList(req *ReqRaspFeedbackList) ([]*RaspFeedbackList, error) {
var txs []*RaspFeedbackList
maps := map[string]interface{}{"return_addr":req.Addr}
err := db.Where(maps).Order("id "+"desc").Offset((req.Page-1)*req.Pagesize).Limit(req.Pagesize).Find(&txs).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return txs, nil
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import (
"github.com/gin-gonic/gin"
"log"
"net/http"
"time"
)
func GetDevdetail(c *gin.Context) {
......@@ -156,6 +157,10 @@ func FeedBack(c *gin.Context){
Description: KP["description"],
Complete: false,
})
models.AddFeedBackList(models.RaspFeedbackList{
Description: KP["description"],
Addtime:time.Now().Unix(),
})
appG.C.JSON(http.StatusOK,gin.H{
"msg":"ok",
"code":"200",
......@@ -164,4 +169,22 @@ func FeedBack(c *gin.Context){
})
}
func GetFeedList(c *gin.Context){
appG:=app.Gin{C:c}
var req models.ReqRaspFeedbackList
err:=appG.C.ShouldBindJSON(&req)
if err!=nil{
appG.Response(http.StatusOK, e.INVALID_PARAMS, nil)
return
}
list,err := models.GetAddrFeedBackList(&models.ReqRaspFeedbackList{
Addr : req.Addr,
Pagesize:req.Pagesize,
Page:req.Page,
})
if err != nil {
appG.Response(http.StatusOK, e.ERROR, nil)
return
}
appG.Response(http.StatusOK, e.SUCCESS, list)
}
......@@ -34,7 +34,7 @@ func InitRouter() *gin.Engine {
apiv1.POST("/latestversion",v1.GetVersion)
apiv1.POST("/feedback",v1.FeedBack)
apiv1.POST("/iscomplete",v1.IsComplete)
apiv1.POST("/getfeedlist",v1.GetFeedList)
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