Skip to content

Commit

Permalink
🐛 fix: fix page (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxip authored Aug 19, 2024
1 parent 133fa30 commit 98146b4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion apis/department.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/mss-boot-io/mss-boot/pkg/response/actions"
"github.com/mss-boot-io/mss-boot/pkg/response/controller"
"github.com/mss-boot-io/mss-boot/pkg/search/gorms"
"gorm.io/gorm"
)

/*
Expand Down Expand Up @@ -85,7 +86,9 @@ func (e *Department) List(c *gin.Context) {
Where(fmt.Sprintf("%s.parent_id = ?", m.TableName()), "")

var count int64
if err := query.Limit(-1).Offset(-1).
if err := query.Scopes(func(db *gorm.DB) *gorm.DB {
return db.Limit(-1).Offset(-1)
}).
Count(&count).Error; err != nil {
api.AddError(err).Err(http.StatusInternalServerError)
return
Expand Down
4 changes: 3 additions & 1 deletion apis/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ func (*Menu) List(ctx *gin.Context) {
query = query.Where("hide_in_menu = ?", 0)
}
var count int64
if err := query.Limit(-1).Offset(-1).Count(&count).Error; err != nil {
if err := query.Scopes(func(db *gorm.DB) *gorm.DB {
return db.Limit(-1).Offset(-1)
}).Count(&count).Error; err != nil {
api.AddError(err).Log.Error("get menu list error", "err", err)
api.Err(http.StatusInternalServerError)
return
Expand Down
5 changes: 4 additions & 1 deletion apis/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/mss-boot-io/mss-boot/pkg/response/actions"
"github.com/mss-boot-io/mss-boot/pkg/response/controller"
"github.com/mss-boot-io/mss-boot/pkg/search/gorms"
"gorm.io/gorm"
)

/*
Expand Down Expand Up @@ -85,7 +86,9 @@ func (e *Post) List(c *gin.Context) {
).Where(fmt.Sprintf("%s.parent_id = ?", m.TableName()), "")

var count int64
if err := query.Limit(-1).Offset(-1).
if err := query.Scopes(func(db *gorm.DB) *gorm.DB {
return db.Limit(-1).Offset(-1)
}).
Count(&count).Error; err != nil {
api.AddError(err).Err(http.StatusInternalServerError)
return
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/gorilla/websocket v1.5.3
github.com/grafana/pyroscope-go v1.1.1
github.com/larksuite/oapi-sdk-go/v3 v3.3.1
github.com/mss-boot-io/mss-boot v0.2.7-0.20240814083825-9c11318051a4
github.com/mss-boot-io/mss-boot v0.2.7-0.20240819055506-8ee0e82149e5
github.com/mss-boot-io/redisqueue/v2 v2.0.0-20240222064111-d36e396df7f9
github.com/nsqio/go-nsq v1.1.0
github.com/redis/go-redis/v9 v9.6.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/mss-boot-io/mss-boot v0.2.7-0.20240814083825-9c11318051a4 h1:uLHTKmLSX0pwkY7/MWylxa3giyJiBw8TAJFeYs/9ovc=
github.com/mss-boot-io/mss-boot v0.2.7-0.20240814083825-9c11318051a4/go.mod h1:3uK5dTvEUPuiXOY6idFYlQ82nD1ewl2tcfGulukTL2s=
github.com/mss-boot-io/mss-boot v0.2.7-0.20240819033934-ff0cee039cce h1:n1hb8+dViBunkCZz0b3sVkjd0V8vyUMK9gdXwvwtnBg=
github.com/mss-boot-io/mss-boot v0.2.7-0.20240819033934-ff0cee039cce/go.mod h1:3uK5dTvEUPuiXOY6idFYlQ82nD1ewl2tcfGulukTL2s=
github.com/mss-boot-io/mss-boot v0.2.7-0.20240819055506-8ee0e82149e5 h1:sAPJh7tu1fMw8YjpYWhOw+sYXtj2LIkjfhLc3rCPGjU=
github.com/mss-boot-io/mss-boot v0.2.7-0.20240819055506-8ee0e82149e5/go.mod h1:3uK5dTvEUPuiXOY6idFYlQ82nD1ewl2tcfGulukTL2s=
github.com/mss-boot-io/redisqueue/v2 v2.0.0-20240222064111-d36e396df7f9 h1:/YgpHiqgrxz/0+mKoETXu21c6/fyDt7/j9bdD3UkbdU=
github.com/mss-boot-io/redisqueue/v2 v2.0.0-20240222064111-d36e396df7f9/go.mod h1:f/sISkwvecPq37zygQzWNj5ntJoP/jcoK0kPIjFTWFI=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
Expand Down

0 comments on commit 98146b4

Please # to comment.