feat: add ai gateway foundation

This commit is contained in:
2026-07-18 16:05:02 +08:00
parent b7fb1969e6
commit 833d9f094f
3 changed files with 150 additions and 0 deletions

View 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
}