package system import ( "net/http" "management/internal/erpserver/handler" v1 "management/internal/erpserver/service/v1" ) type HomeHandler struct { *handler.Handler userService v1.UserService loginLogService v1.LoginLogService } func NewHomeHandler( handler *handler.Handler, userService v1.UserService, loginLogService v1.LoginLogService, ) *HomeHandler { return &HomeHandler{ Handler: handler, userService: userService, loginLogService: loginLogService, } } func (h *HomeHandler) Home(w http.ResponseWriter, r *http.Request) { h.HTML(w, r, "home/home.tmpl", nil) } func (h *HomeHandler) Dashboard(w http.ResponseWriter, r *http.Request) { ctx := r.Context() auth := h.AuthUser(ctx) user, _ := h.userService.Get(ctx, auth.ID) lt, _ := h.loginLogService.LoginTime(ctx, auth.Email) c := h.loginLogService.LoginCount(ctx, auth.Email) h.HTML(w, r, "home/dashboard.tmpl", map[string]any{ "Auth": auth, "User": user, "LoginTime": lt, "LoginCount": c, }) }