feat: add ai gateway foundation
This commit is contained in:
26
backend/internal/ai/sessions.go
Normal file
26
backend/internal/ai/sessions.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package ai
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"senlinai-agent/backend/internal/domain"
|
||||
)
|
||||
|
||||
type SessionService struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewSessionService(database *gorm.DB) *SessionService {
|
||||
return &SessionService{db: database}
|
||||
}
|
||||
|
||||
func (s *SessionService) Create(projectID uint, userID uint, title string) (*domain.AISession, error) {
|
||||
title = strings.TrimSpace(title)
|
||||
if title == "" {
|
||||
return nil, errors.New("session title is required")
|
||||
}
|
||||
session := &domain.AISession{ProjectID: projectID, CreatedBy: userID, Title: title}
|
||||
return session, s.db.Create(session).Error
|
||||
}
|
||||
Reference in New Issue
Block a user