refactor: rename AI expert item model
This commit is contained in:
@@ -14,8 +14,8 @@ type ExpertFilter struct {
|
||||
Query string
|
||||
}
|
||||
|
||||
func (s *SessionService) ListExperts(filter ExpertFilter) ([]models.SenlinAgentAIExpert, error) {
|
||||
query := models.DBService.Model(&models.SenlinAgentAIExpert{}).Where("enabled = ?", true)
|
||||
func (s *SessionService) ListExperts(filter ExpertFilter) ([]models.SenlinAgentAIExpertItem, error) {
|
||||
query := models.DBService.Model(&models.SenlinAgentAIExpertItem{}).Where("enabled = ?", true)
|
||||
if category := strings.TrimSpace(filter.Category); category != "" {
|
||||
query = query.Where("category = ?", category)
|
||||
}
|
||||
@@ -26,18 +26,18 @@ func (s *SessionService) ListExperts(filter ExpertFilter) ([]models.SenlinAgentA
|
||||
like, like, like,
|
||||
)
|
||||
}
|
||||
var experts []models.SenlinAgentAIExpert
|
||||
var experts []models.SenlinAgentAIExpertItem
|
||||
if err := query.Order("category asc, id asc").Find(&experts).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if experts == nil {
|
||||
experts = []models.SenlinAgentAIExpert{}
|
||||
experts = []models.SenlinAgentAIExpertItem{}
|
||||
}
|
||||
return experts, nil
|
||||
}
|
||||
|
||||
func (s *SessionService) GetExpert(identity string) (*models.SenlinAgentAIExpert, error) {
|
||||
var expert models.SenlinAgentAIExpert
|
||||
func (s *SessionService) GetExpert(identity string) (*models.SenlinAgentAIExpertItem, error) {
|
||||
var expert models.SenlinAgentAIExpertItem
|
||||
if err := models.DBService.Where("identity = ? AND enabled = ?", strings.TrimSpace(identity), true).First(&expert).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, ErrExpertNotFound
|
||||
@@ -47,11 +47,11 @@ func (s *SessionService) GetExpert(identity string) (*models.SenlinAgentAIExpert
|
||||
return &expert, nil
|
||||
}
|
||||
|
||||
func findExpertByIdentity(tx *gorm.DB, identity string) (*models.SenlinAgentAIExpert, error) {
|
||||
func findExpertByIdentity(tx *gorm.DB, identity string) (*models.SenlinAgentAIExpertItem, error) {
|
||||
if strings.TrimSpace(identity) == "" {
|
||||
return nil, nil
|
||||
}
|
||||
var expert models.SenlinAgentAIExpert
|
||||
var expert models.SenlinAgentAIExpertItem
|
||||
if err := tx.Where("identity = ? AND enabled = ?", identity, true).First(&expert).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, ErrExpertNotFound
|
||||
|
||||
Reference in New Issue
Block a user