refactor: shorten model and table prefixes
This commit is contained in:
@@ -38,28 +38,28 @@ func NewSessionService(gateway sessionGateway) *SessionService {
|
||||
}
|
||||
|
||||
// List 在项目 owner 校验后返回该项目的会话,内部自增 ID 不离开服务边界。
|
||||
func (s *SessionService) List(userID uint, projectIdentity string) ([]models.SenlinAgentAISession, error) {
|
||||
func (s *SessionService) List(userID uint, projectIdentity string) ([]models.SaAISession, error) {
|
||||
project, err := projects.FindOwnedProject(userID, projectIdentity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var sessions []models.SenlinAgentAISession
|
||||
var sessions []models.SaAISession
|
||||
if err := models.DBService.Preload("Expert").Where("project_id = ?", project.ID).Order("updated_at desc, id desc").Find(&sessions).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if sessions == nil {
|
||||
sessions = []models.SenlinAgentAISession{}
|
||||
sessions = []models.SaAISession{}
|
||||
}
|
||||
return sessions, nil
|
||||
}
|
||||
|
||||
// Create 先校验项目,再限流,最后才选择 provider/key;会话创建不会生成任何正式业务对象。
|
||||
func (s *SessionService) Create(userID uint, projectIdentity, title, context string) (*models.SenlinAgentAISession, error) {
|
||||
func (s *SessionService) Create(userID uint, projectIdentity, title, context string) (*models.SaAISession, error) {
|
||||
return s.CreateWithExpert(userID, projectIdentity, title, context, "")
|
||||
}
|
||||
|
||||
// CreateWithExpert 创建带本地专家角色的项目会话。
|
||||
func (s *SessionService) CreateWithExpert(userID uint, projectIdentity, title, context, expertIdentity string) (*models.SenlinAgentAISession, error) {
|
||||
func (s *SessionService) CreateWithExpert(userID uint, projectIdentity, title, context, expertIdentity string) (*models.SaAISession, error) {
|
||||
title = strings.TrimSpace(title)
|
||||
context = strings.TrimSpace(context)
|
||||
if title == "" {
|
||||
@@ -103,7 +103,7 @@ func (s *SessionService) CreateWithExpert(userID uint, projectIdentity, title, c
|
||||
return nil, err
|
||||
}
|
||||
|
||||
session := models.SenlinAgentAISession{
|
||||
session := models.SaAISession{
|
||||
ProjectID: project.ID,
|
||||
CreatedBy: userID,
|
||||
Title: title,
|
||||
@@ -149,7 +149,7 @@ func selectedAuditMetadata(selected SelectedKey) (string, string) {
|
||||
return provider, keyType
|
||||
}
|
||||
|
||||
func aiSessionStatus(session models.SenlinAgentAISession) string {
|
||||
func aiSessionStatus(session models.SaAISession) string {
|
||||
if status := strings.TrimSpace(session.Status); status != "" {
|
||||
return status
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user