feat: update template

This commit is contained in:
2026-08-19 22:05:49 +08:00
parent 0e674e9d56
commit 5a71093b0c
67 changed files with 2070 additions and 585 deletions

View File

@@ -0,0 +1,48 @@
package admin
import (
"net/http"
"server/internal/model/common"
"server/internal/pkg/httputil"
"server/internal/router"
"server/internal/service/admin"
"github.com/go-chi/chi/v5"
)
type AccessLogHandler struct {
accessLogService *admin.AccessLogService
}
var _ router.Registrar = (*AccessLogHandler)(nil)
func NewAccessLogHandler(accessLogService *admin.AccessLogService) *AccessLogHandler {
return &AccessLogHandler{
accessLogService: accessLogService,
}
}
func (h *AccessLogHandler) Register(r chi.Router) {
r.Route("/access-logs", func(r chi.Router) {
r.Get("/", h.List)
})
}
func (h *AccessLogHandler) List(w http.ResponseWriter, r *http.Request) {
pagination := httputil.Pagination(r)
result, err := h.accessLogService.List(r.Context(), pagination)
if err != nil {
httputil.Fail(w, err)
return
}
resp := common.PageResponse{
Page: pagination.Page,
PageSize: pagination.PageSize,
List: result.List,
Total: result.Total,
}
httputil.OkWithPage(w, &resp)
}