refactor backend packages and global db service

This commit is contained in:
2026-07-18 21:58:15 +08:00
parent 62bd3d0455
commit 7800b07d42
51 changed files with 719 additions and 647 deletions

View File

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