26 lines
553 B
Go
26 lines
553 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"leafdev.top/leaf/rag/ent"
|
|
"leafdev.top/leaf/rag/ent/document"
|
|
)
|
|
|
|
type DocumentLogic struct {
|
|
}
|
|
|
|
func NewDocumentLogic() *DocumentLogic {
|
|
return &DocumentLogic{}
|
|
}
|
|
|
|
func (DocumentLogic) ListDocument(ctx context.Context) ([]*ent.Document, error) {
|
|
return orm.Document.Query().Where(document.UserIDEQ(GetUserId(ctx))).All(ctx)
|
|
}
|
|
|
|
func (DocumentLogic) CreateDocument(ctx context.Context, name string) (*ent.Document, error) {
|
|
return orm.Document.Create().
|
|
SetName(name).
|
|
SetUserID(GetUserId(ctx)).
|
|
Save(ctx)
|
|
}
|