36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
func (s *AuditService) LogDates(ctx context.Context, month string) (map[string]any, error) {
|
|
items, err := s.uc.LogDates(ctx, month)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out := make([]map[string]any, 0, len(items))
|
|
for _, v := range items {
|
|
out = append(out, map[string]any{"date": v.Date, "fileCount": v.FileCount})
|
|
}
|
|
return map[string]any{"month": month, "dates": out}, nil
|
|
}
|
|
func (s *AuditService) LogFiles(ctx context.Context, date string) (map[string]any, error) {
|
|
items, err := s.uc.LogFiles(ctx, date)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out := make([]map[string]any, 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})
|
|
}
|
|
return map[string]any{"date": date, "files": out}, nil
|
|
}
|
|
func (s *AuditService) LogContent(ctx context.Context, date, path string, cursor *int64) (map[string]any, 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
|
|
}
|