33 lines
681 B
Go
33 lines
681 B
Go
package note
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories"
|
|
)
|
|
|
|
type saveNoteCommand struct {
|
|
Title string `json:"title"`
|
|
Content string `json:"content"`
|
|
Directory string `json:"directory"`
|
|
Tags []string `json:"tags"`
|
|
}
|
|
|
|
type SaveNoteHandler struct {
|
|
uow *repositories.UnitOfWork
|
|
}
|
|
|
|
func NewSaveNoteHandler() *SaveNoteHandler {
|
|
return &SaveNoteHandler{repositories.NewUnitOfWork()}
|
|
}
|
|
|
|
func (h *SaveNoteHandler) Handle(ctx context.Context, raw json.RawMessage) (any, error) {
|
|
var cmd saveNoteCommand
|
|
|
|
if err := json.Unmarshal(raw, &cmd); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return nil, nil
|
|
}
|