verstak/wails_service.go

89 lines
2.5 KiB
Go

package main
import (
"context"
"encoding/json"
"fmt"
"verstak/internal/core/nodes"
)
// WailsService exposes core methods to the Wails frontend.
type WailsService struct{}
// ListRootNodes returns root-level nodes.
func (s *WailsService) ListRootNodes(ctx context.Context) string {
// This is a stub — actual implementation will use injected DB
return "[]"
}
// ListChildren returns children of a node.
func (s *WailsService) ListChildren(ctx context.Context, parentID string) string {
return "[]"
}
// CreateNode creates a new node.
func (s *WailsService) CreateNode(ctx context.Context, parentID, nodeType, title, section string) string {
return "{}"
}
// ListFiles returns files for a node.
func (s *WailsService) ListFiles(ctx context.Context, nodeID string) string {
return "[]"
}
// ListActions returns actions for a node.
func (s *WailsService) ListActions(ctx context.Context, nodeID string) string {
return "[]"
}
// ListWorklog returns worklog entries for a node.
func (s *WailsService) ListWorklog(ctx context.Context, nodeID string) string {
return "[]"
}
// Search performs a search query.
func (s *WailsService) Search(ctx context.Context, query string) string {
return "[]"
}
// ListTemplates returns available templates.
func (s *WailsService) ListTemplates(ctx context.Context) string {
return "[]"
}
// ListSections returns available sections.
func (s *WailsService) ListSections(ctx context.Context) string {
sections := []map[string]string{
{"id": "today", "label": "Сегодня"},
{"id": "inbox", "label": "Неразобранное"},
{"id": "clients", "label": "Клиенты"},
{"id": "projects", "label": "Проекты"},
{"id": "recipes", "label": "Рецепты"},
{"id": "documents", "label": "Документы"},
{"id": "archive", "label": "Архив"},
}
data, _ := json.Marshal(sections)
return string(data)
}
// GetCurrentSelection returns current selection state.
func (s *WailsService) GetCurrentSelection(ctx context.Context) string {
sel := map[string]string{"kind": "section", "section": "today"}
data, _ := json.Marshal(sel)
return string(data)
}
// OpenFile opens a file with the system application.
func (s *WailsService) OpenFile(ctx context.Context, fileID string) string {
return fmt.Sprintf("opened file %s", fileID)
}
// OpenFolder opens a folder in the system file manager.
func (s *WailsService) OpenFolder(ctx context.Context, nodeID string) string {
return fmt.Sprintf("opened folder %s", nodeID)
}
// Silence unused import.
var _ = nodes.TypeCase