release revsuit vBeta0.1.0 (#15)

Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2021-05-16 12:11:35 +08:00
committed by GitHub
co-authored by E99p1ant
parent b39ee101f9
commit 5b63e90390
98 changed files with 2357 additions and 623 deletions
+13 -4
View File
@@ -47,11 +47,20 @@ func ListRecords(c *gin.Context) {
res []Record
count int64
order = c.Query("order")
pageSize int
)
if c.Query("pageSize") == "" {
pageSize = 10
} else if n, err := strconv.Atoi(c.Query("pageSize")); err == nil {
if n <= 0 || n > 100 {
pageSize = 10
}
}
if err := c.ShouldBind(&dnsRecord); err != nil {
c.JSON(400, gin.H{
"status": "failed",
"error": err,
"error": err.Error(),
"result": nil,
})
}
@@ -74,7 +83,7 @@ func ListRecords(c *gin.Context) {
if err != nil {
c.JSON(400, gin.H{
"status": "failed",
"error": err,
"error": err.Error(),
"result": nil,
})
return
@@ -84,10 +93,10 @@ func ListRecords(c *gin.Context) {
order = "desc"
}
if err := db.Order("id" + " " + order).Count(&count).Offset((page - 1) * 10).Limit(10).Find(&res).Error; err != nil {
if err := db.Order("id" + " " + order).Count(&count).Offset((page - 1) * pageSize).Limit(pageSize).Find(&res).Error; err != nil {
c.JSON(400, gin.H{
"status": "failed",
"error": err,
"error": err.Error(),
"data": nil,
})
return