Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
262665f4
authored
2014-10-08 15:59:26 +0200
by
Jens Bissinger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Remove PaginationController interface and pass context instead. Refs #835.
1 parent
0b3763cc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
20 deletions
controller.go
utils/pagination/controller.go
utils/pagination/doc.go
controller.go
View file @
262665f
...
...
@@ -93,14 +93,6 @@ type ControllerInterface interface {
URLMapping
()
}
func
(
c
*
Controller
)
GetCtx
()
*
context
.
Context
{
return
c
.
Ctx
}
func
(
c
*
Controller
)
GetData
()
map
[
interface
{}]
interface
{}
{
return
c
.
Data
}
// Init generates default values of controller operations.
func
(
c
*
Controller
)
Init
(
ctx
*
context
.
Context
,
controllerName
,
actionName
string
,
app
interface
{})
{
c
.
Layout
=
""
...
...
utils/pagination/controller.go
View file @
262665f
...
...
@@ -18,16 +18,9 @@ import (
"github.com/astaxie/beego/context"
)
type
PaginationController
interface
{
GetCtx
()
*
context
.
Context
GetData
()
map
[
interface
{}]
interface
{}
}
// Instantiates a Paginator and assigns it to controller.Data["paginator"].
func
SetPaginator
(
controller
PaginationController
,
per
int
,
nums
int64
)
(
paginator
*
Paginator
)
{
request
:=
controller
.
GetCtx
()
.
Request
paginator
=
NewPaginator
(
request
,
per
,
nums
)
data
:=
controller
.
GetData
()
data
[
"paginator"
]
=
paginator
// Instantiates a Paginator and assigns it to context.Input.Data["paginator"].
func
SetPaginator
(
context
*
context
.
Context
,
per
int
,
nums
int64
)
(
paginator
*
Paginator
)
{
paginator
=
NewPaginator
(
context
.
Request
,
per
,
nums
)
context
.
Input
.
Data
[
"paginator"
]
=
paginator
return
}
...
...
utils/pagination/doc.go
View file @
262665f
...
...
@@ -18,7 +18,7 @@ In your beego.Controller:
func (this *PostsController) ListAllPosts() {
// sets this.Data["paginator"] with the current offset (from the url query param)
postsPerPage := 20
paginator := pagination.SetPaginator(this, postsPerPage, CountPosts())
paginator := pagination.SetPaginator(this
.Ctx
, postsPerPage, CountPosts())
// fetch the next 20 posts
this.Data["posts"] = ListPostsByOffsetAndLimit(paginator.Offset(), postsPerPage)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment