改进 判断
This commit is contained in:
parent
df831cd6af
commit
1c371738f0
@ -2,6 +2,7 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"leafdev.top/leaf/rag/ent"
|
"leafdev.top/leaf/rag/ent"
|
||||||
"leafdev.top/leaf/rag/ent/library"
|
"leafdev.top/leaf/rag/ent/library"
|
||||||
"leafdev.top/leaf/rag/internal/providers"
|
"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) {
|
func (l *LibraryLogic) CreateLibrary(ctx context.Context, name string) (*ent.Library, error) {
|
||||||
|
// name 不能为空
|
||||||
|
if name == "" {
|
||||||
|
return nil, errors.New("名称不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
return client.Library.Create().
|
return client.Library.Create().
|
||||||
SetName(name).
|
SetName(name).
|
||||||
SetUserID(GetUserId(ctx)).
|
SetUserID(GetUserId(ctx)).
|
||||||
|
Loading…
Reference in New Issue
Block a user