diff --git a/internal/logic/library.go b/internal/logic/library.go index 127b40d..4ca297f 100644 --- a/internal/logic/library.go +++ b/internal/logic/library.go @@ -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)).