Index: query sort/order
This commit is contained in:
parent
e171731d62
commit
d992c30346
@ -12,6 +12,14 @@ const (
|
|||||||
TPL_AUTHORS = "author.html"
|
TPL_AUTHORS = "author.html"
|
||||||
TPL_SERIES = "series.html"
|
TPL_SERIES = "series.html"
|
||||||
TPL_INDEX = "index.html"
|
TPL_INDEX = "index.html"
|
||||||
|
|
||||||
|
PARAM_LIST = "list"
|
||||||
|
PARAM_ORDER = "order"
|
||||||
|
PARAM_SORT = "sort"
|
||||||
|
|
||||||
|
LIST_AUTHORS = "authors"
|
||||||
|
LIST_SERIES = "series"
|
||||||
|
LIST_BOOKS = "books"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bouquins struct {
|
type Bouquins struct {
|
||||||
@ -146,7 +154,17 @@ func (app *Bouquins) IndexPage(res http.ResponseWriter, req *http.Request) {
|
|||||||
log.Print(err)
|
log.Print(err)
|
||||||
}
|
}
|
||||||
model := NewIndexModel("", count)
|
model := NewIndexModel("", count)
|
||||||
model.Books, err = app.BooksAdv(0, 0, "", "")
|
order, sort := req.URL.Query().Get(PARAM_ORDER), req.URL.Query().Get(PARAM_SORT)
|
||||||
|
switch req.URL.Query().Get(PARAM_LIST) {
|
||||||
|
case LIST_AUTHORS:
|
||||||
|
model.Authors, err = app.AuthorsAdv(0, 0, sort, order)
|
||||||
|
case LIST_SERIES:
|
||||||
|
model.Series, err = app.SeriesAdv(0, 0, sort, order)
|
||||||
|
case LIST_BOOKS:
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
model.Books, err = app.BooksAdv(0, 0, sort, order)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
}
|
}
|
||||||
|
@ -196,6 +196,12 @@ func (app *Bouquins) BookCount() (int64, error) {
|
|||||||
err := row.Scan(&count)
|
err := row.Scan(&count)
|
||||||
return count, err
|
return count, err
|
||||||
}
|
}
|
||||||
|
func (app *Bouquins) SeriesAdv(limit, offset int, sort, order string) ([]*SeriesAdv, error) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
func (app *Bouquins) AuthorsAdv(limit, offset int, sort, order string) ([]*AuthorAdv, error) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func (app *Bouquins) BooksAdv(limit, offset int, sort, order string) ([]*BookAdv, error) {
|
func (app *Bouquins) BooksAdv(limit, offset int, sort, order string) ([]*BookAdv, error) {
|
||||||
if limit == 0 {
|
if limit == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user