mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
refactor: standardization of code structure (#7)
This commit is contained in:
+8
-8
@@ -68,7 +68,7 @@ func ListRules(c *gin.Context) {
|
||||
if err := c.ShouldBind(&mysqlRule); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"result": nil,
|
||||
})
|
||||
return
|
||||
@@ -84,20 +84,20 @@ func ListRules(c *gin.Context) {
|
||||
if err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"result": nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if order != "desc" && order != "asc" {
|
||||
if order != "asc" {
|
||||
order = "desc"
|
||||
}
|
||||
|
||||
if err := db.Order("rank desc").Order("id" + " " + order).Count(&count).Offset((page - 1) * 10).Limit(10).Find(&res).Error; err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
@@ -120,7 +120,7 @@ func UpsertRules(c *gin.Context) {
|
||||
if err := c.ShouldBind(&mysqlRule); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
@@ -133,7 +133,7 @@ func UpsertRules(c *gin.Context) {
|
||||
if err := mysqlRule.CreateOrUpdate(); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
@@ -159,7 +159,7 @@ func DeleteRules(c *gin.Context) {
|
||||
if err := c.ShouldBind(&mysqlRule); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
@@ -168,7 +168,7 @@ func DeleteRules(c *gin.Context) {
|
||||
if err := mysqlRule.Delete(); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
"error": err.Error(),
|
||||
"error": err,
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user