25 lines
539 B
Go
25 lines
539 B
Go
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.SaNote, error) {
|
|
title = strings.TrimSpace(title)
|
|
if title == "" {
|
|
return nil, errors.New("note title is required")
|
|
}
|
|
note := &models.SaNote{ProjectID: projectID, CreatedBy: userID, Title: title, Markdown: markdown}
|
|
return note, models.DBService.Create(note).Error
|
|
}
|