This commit is contained in:
2026-08-15 03:14:56 +08:00
parent a34133cce5
commit 2a3c55bb53
71 changed files with 1445 additions and 1076 deletions
+11 -10
View File
@@ -4,6 +4,7 @@ import (
"context"
"kra/internal/biz"
"kra/internal/service/dto"
)
type LogViewerService struct{ uc *biz.LogViewerUsecase }
@@ -12,32 +13,32 @@ func NewLogViewerService(uc *biz.LogViewerUsecase) *LogViewerService {
return &LogViewerService{uc: uc}
}
func (s *LogViewerService) LogDates(ctx context.Context, month string) (map[string]any, error) {
func (s *LogViewerService) LogDates(ctx context.Context, month string) (*dto.LogDatesResponse, error) {
items, err := s.uc.LogDates(ctx, month)
if err != nil {
return nil, err
}
out := make([]map[string]any, 0, len(items))
out := make([]*dto.LogDateResponse, 0, len(items))
for _, v := range items {
out = append(out, map[string]any{"date": v.Date, "fileCount": v.FileCount})
out = append(out, &dto.LogDateResponse{Date: v.Date, FileCount: v.FileCount})
}
return map[string]any{"month": month, "dates": out}, nil
return &dto.LogDatesResponse{Month: month, Dates: out}, nil
}
func (s *LogViewerService) LogFiles(ctx context.Context, date string) (map[string]any, error) {
func (s *LogViewerService) LogFiles(ctx context.Context, date string) (*dto.LogFilesResponse, error) {
items, err := s.uc.LogFiles(ctx, date)
if err != nil {
return nil, err
}
out := make([]map[string]any, 0, len(items))
out := make([]*dto.LogFileResponse, 0, len(items))
for _, v := range items {
out = append(out, map[string]any{"path": v.Path, "name": v.Name, "size": v.Size, "modifiedAt": v.ModifiedAt})
out = append(out, &dto.LogFileResponse{Path: v.Path, Name: v.Name, Size: v.Size, ModifiedAt: v.ModifiedAt})
}
return map[string]any{"date": date, "files": out}, nil
return &dto.LogFilesResponse{Date: date, Files: out}, nil
}
func (s *LogViewerService) LogContent(ctx context.Context, date, path string, cursor *int64) (map[string]any, error) {
func (s *LogViewerService) LogContent(ctx context.Context, date, path string, cursor *int64) (*dto.LogContentResponse, error) {
v, err := s.uc.LogContent(ctx, date, path, cursor)
if err != nil {
return nil, err
}
return map[string]any{"date": v.Date, "path": v.Path, "content": v.Content, "lineCount": v.LineCount, "nextCursor": v.NextCursor, "hasMore": v.HasMore, "limitedByBytes": v.LimitedByBytes, "size": v.Size, "modifiedAt": v.ModifiedAt}, nil
return &dto.LogContentResponse{Date: v.Date, Path: v.Path, Content: v.Content, LineCount: v.LineCount, NextCursor: v.NextCursor, HasMore: v.HasMore, LimitedByBytes: v.LimitedByBytes, Size: v.Size, ModifiedAt: v.ModifiedAt}, nil
}