This commit is contained in:
2025-06-17 11:16:24 +08:00
parent 6c3b4ec367
commit 759863f1aa
24 changed files with 103 additions and 92 deletions

View File

@@ -9,20 +9,20 @@ import (
"management/internal/pkg/render"
)
type App struct {
type app struct {
render render.Renderer
userService v1.UserService
menuService v1.MenuService
loginLogService v1.LoginLogService
}
func NewApp(
func newApp(
render render.Renderer,
userService v1.UserService,
menuService v1.MenuService,
loginLogService v1.LoginLogService,
) *App {
return &App{
) *app {
return &app{
render: render,
userService: userService,
menuService: menuService,
@@ -30,12 +30,12 @@ func NewApp(
}
}
func (a *App) home(w http.ResponseWriter, r *http.Request) {
func (a *app) home(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
a.render.Render(ctx, w, home.Home(ctx))
}
func (a *App) dashboard(w http.ResponseWriter, r *http.Request) {
func (a *app) dashboard(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
auth := mid.GetUser(ctx)
lt, _ := a.loginLogService.LoginTime(ctx, auth.Email)

View File

@@ -18,7 +18,7 @@ type Config struct {
}
func Routes(r chi.Router, cfg Config) {
app := NewApp(cfg.Render, cfg.UserService, cfg.MenuService, cfg.LoginLogService)
app := newApp(cfg.Render, cfg.UserService, cfg.MenuService, cfg.LoginLogService)
r.With(mid.Authorize(cfg.Sm, cfg.MenuService)).Get("/home.html", app.home)
r.With(mid.Authorize(cfg.Sm, cfg.MenuService)).Get("/dashboard", app.dashboard)