swirl/controller/event.go

41 lines
884 B
Go
Raw Normal View History

2017-09-26 12:50:09 +00:00
package controller
import (
"github.com/cuigh/auxo/net/web"
"github.com/cuigh/swirl/biz"
"github.com/cuigh/swirl/model"
)
2017-10-11 03:26:03 +00:00
// EventController is a controller of user events
2017-09-26 12:50:09 +00:00
type EventController struct {
List web.HandlerFunc `path:"/" name:"event.list" authorize:"!" desc:"event list page"`
}
2017-10-11 03:26:03 +00:00
// Event creates an instance of EventController
2017-09-26 12:50:09 +00:00
func Event() (c *EventController) {
2017-10-11 03:26:03 +00:00
return &EventController{
List: eventList,
}
}
2017-09-26 12:50:09 +00:00
2017-10-11 03:26:03 +00:00
func eventList(ctx web.Context) error {
args := &model.EventListArgs{}
err := ctx.Bind(args)
if err != nil {
return err
}
args.PageSize = model.PageSize
if args.PageIndex == 0 {
args.PageIndex = 1
}
2017-09-26 12:50:09 +00:00
2017-10-11 03:26:03 +00:00
events, totalCount, err := biz.Event.List(args)
if err != nil {
return err
2017-09-26 12:50:09 +00:00
}
2017-10-11 03:26:03 +00:00
m := newPagerModel(ctx, totalCount, model.PageSize, args.PageIndex).
2017-11-08 10:36:13 +00:00
Set("Events", events).Set("Args", args)
2017-10-11 03:26:03 +00:00
return ctx.Render("system/event/list", m)
2017-09-26 12:50:09 +00:00
}