Skip to content

Commit

Permalink
fix(pkg): fix the conflict between rank field and built-in function (#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
TardC authored Dec 22, 2021
1 parent 830dde3 commit a59540d
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *Server) UpdateRules() error {
db := database.DB.Model(new(Rule))
defer s.rulesLock.Unlock()
s.rulesLock.Lock()
return errors.Wrap(db.Order("rank desc").Find(&s.rules).Error, "DNS update rules error")
return errors.Wrap(db.Order("`rank` desc").Find(&s.rules).Error, "DNS update rules error")
}

func newSet(_rule *Rule, name, value, ip string, _type newdns.Type) []newdns.Set {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dns/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func ListRules(c *gin.Context) {
order = "desc"
}

if err := db.Order("rank desc").Order("id" + " " + order).Count(&count).Offset((page - 1) * pageSize).Limit(pageSize).Find(&res).Error; err != nil {
if err := db.Order("`rank` desc").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(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/ftp/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Server) UpdateRules() error {
db := database.DB.Model(new(Rule))
defer s.rulesLock.Unlock()
s.rulesLock.Lock()
return errors.Wrap(db.Order("rank desc").Find(&s.rules).Error, "FTP update rules error")
return errors.Wrap(db.Order("`rank` desc").Find(&s.rules).Error, "FTP update rules error")
}

func getClientPasvConnAddress(ip, port string) string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ftp/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func ListRules(c *gin.Context) {
order = "desc"
}

if err := db.Order("rank desc").Order("id" + " " + order).Count(&count).Offset((page - 1) * pageSize).Limit(pageSize).Find(&res).Error; err != nil {
if err := db.Order("`rank` desc").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(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (s *Server) UpdateRules() error {
db := database.DB.Model(new(Rule))
defer s.rulesLock.Unlock()
s.rulesLock.Lock()
return errors.Wrap(db.Order("rank desc").Find(&s.rules).Error, "MySQL update rules error")
return errors.Wrap(db.Order("`rank` desc").Find(&s.rules).Error, "MySQL update rules error")
}

// NewConnection is part of the mysql.Handler interface.
Expand Down
2 changes: 1 addition & 1 deletion pkg/mysql/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func ListRules(c *gin.Context) {
order = "desc"
}

if err := db.Order("rank desc").Order("id" + " " + order).Count(&count).Offset((page - 1) * pageSize).Limit(pageSize).Find(&res).Error; err != nil {
if err := db.Order("`rank` desc").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(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/rhttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Server) UpdateRules() error {
db := database.DB.Model(new(Rule))
defer s.rulesLock.Unlock()
s.rulesLock.Lock()
return db.Order("rank desc").Find(&s.rules).Error
return db.Order("`rank` desc").Find(&s.rules).Error
}

func (s *Server) startHttpServer() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/rhttp/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func ListRules(c *gin.Context) {
order = "desc"
}

if err := db.Order("rank desc").Order("id" + " " + order).Count(&count).Offset((page - 1) * pageSize).Limit(pageSize).Find(&res).Error; err != nil {
if err := db.Order("`rank` desc").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(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/rmi/rmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *Server) UpdateRules() error {
db := database.DB.Model(new(Rule))
defer s.rulesLock.Unlock()
s.rulesLock.Lock()
return errors.Wrap(db.Order("rank desc").Find(&s.rules).Error, "RMI update rules error")
return errors.Wrap(db.Order("`rank` desc").Find(&s.rules).Error, "RMI update rules error")
}

func (s *Server) handleConnection(conn net.Conn) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/rmi/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func ListRules(c *gin.Context) {
order = "desc"
}

if err := db.Order("rank desc").Order("id" + " " + order).Count(&count).Offset((page - 1) * pageSize).Limit(pageSize).Find(&res).Error; err != nil {
if err := db.Order("`rank` desc").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(),
Expand Down

0 comments on commit a59540d

Please sign in to comment.