mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
release revsuit vBeta0.1.0 (#15)
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
+13
-4
@@ -55,12 +55,21 @@ 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(&mysqlRecord); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err,
|
||||
"error": err.Error(),
|
||||
"result": nil,
|
||||
})
|
||||
}
|
||||
@@ -93,7 +102,7 @@ func ListRecords(c *gin.Context) {
|
||||
if err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err,
|
||||
"error": err.Error(),
|
||||
"result": nil,
|
||||
})
|
||||
return
|
||||
@@ -103,10 +112,10 @@ func ListRecords(c *gin.Context) {
|
||||
order = "desc"
|
||||
}
|
||||
|
||||
if err := db.Preload("Files").Order("id" + " " + order).Count(&count).Offset((page - 1) * 10).Limit(10).Find(&res).Error; err != nil {
|
||||
if err := db.Preload("Files").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
|
||||
|
||||
Reference in New Issue
Block a user