feat: add files notes and search

This commit is contained in:
2026-07-18 16:03:06 +08:00
parent 530fc43cca
commit b7fb1969e6
6 changed files with 206 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package notes
import (
"errors"
"strings"
"gorm.io/gorm"
"senlinai-agent/backend/internal/domain"
)
type Service struct {
db *gorm.DB
}
func NewService(database *gorm.DB) *Service {
return &Service{db: database}
}
func (s *Service) CreateNote(projectID uint, userID uint, title string, markdown string) (*domain.Note, error) {
title = strings.TrimSpace(title)
if title == "" {
return nil, errors.New("note title is required")
}
note := &domain.Note{ProjectID: projectID, CreatedBy: userID, Title: title, Markdown: markdown}
return note, s.db.Create(note).Error
}