Use handler config.
This commit is contained in:
parent
eaa37a0745
commit
271e252c53
2 changed files with 10 additions and 12 deletions
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"entgo.io/ent/entc/gen"
|
"entgo.io/ent/entc/gen"
|
||||||
"entgo.io/ent/entc/load"
|
"entgo.io/ent/entc/load"
|
||||||
|
|
@ -24,10 +25,9 @@ const entityContextKey = "admin:entity"
|
||||||
const entityIDContextKey = "admin:entity_id"
|
const entityIDContextKey = "admin:entity_id"
|
||||||
|
|
||||||
type Admin struct {
|
type Admin struct {
|
||||||
orm *ent.Client
|
orm *ent.Client
|
||||||
graph *gen.Graph
|
graph *gen.Graph
|
||||||
admin *admin.Handler
|
admin *admin.Handler
|
||||||
itemsPerPage int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -35,10 +35,13 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Admin) Init(c *services.Container) error {
|
func (h *Admin) Init(c *services.Container) error {
|
||||||
h.itemsPerPage = 25
|
|
||||||
h.graph = c.Graph
|
h.graph = c.Graph
|
||||||
h.orm = c.ORM
|
h.orm = c.ORM
|
||||||
h.admin = admin.NewHandler(h.orm, h.itemsPerPage)
|
h.admin = admin.NewHandler(h.orm, admin.HandlerConfig{
|
||||||
|
ItemsPerPage: 25,
|
||||||
|
PageQueryKey: pager.QueryKey,
|
||||||
|
TimeFormat: time.DateTime,
|
||||||
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +99,7 @@ func (h *Admin) EntityList(n *gen.Type) echo.HandlerFunc {
|
||||||
return pages.AdminEntityList(ctx, pages.AdminEntityListParams{
|
return pages.AdminEntityList(ctx, pages.AdminEntityListParams{
|
||||||
EntityType: n,
|
EntityType: n,
|
||||||
EntityList: list,
|
EntityList: list,
|
||||||
Pager: pager.NewPager(ctx, h.itemsPerPage),
|
Pager: pager.NewPager(ctx, h.admin.Config.ItemsPerPage),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,4 @@ func TestNewContainer(t *testing.T) {
|
||||||
assert.NotNil(t, c.Mail)
|
assert.NotNil(t, c.Mail)
|
||||||
assert.NotNil(t, c.Auth)
|
assert.NotNil(t, c.Auth)
|
||||||
assert.NotNil(t, c.Tasks)
|
assert.NotNil(t, c.Tasks)
|
||||||
|
|
||||||
g := c.Graph
|
|
||||||
if g == nil {
|
|
||||||
//c.ORM.User.Create().
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue