改进 判断

This commit is contained in:
ivamp 2024-07-16 02:07:10 +08:00
parent df831cd6af
commit 1c371738f0

View File

@ -2,6 +2,7 @@ package logic
import (
"context"
"errors"
"leafdev.top/leaf/rag/ent"
"leafdev.top/leaf/rag/ent/library"
"leafdev.top/leaf/rag/internal/providers"
@ -21,6 +22,11 @@ func (l *LibraryLogic) ListLibrary(ctx context.Context) ([]*ent.Library, error)
}
func (l *LibraryLogic) CreateLibrary(ctx context.Context, name string) (*ent.Library, error) {
// name 不能为空
if name == "" {
return nil, errors.New("名称不能为空")
}
return client.Library.Create().
SetName(name).
SetUserID(GetUserId(ctx)).