42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.10.1
|
|
|
|
package persona
|
|
|
|
import (
|
|
"context"
|
|
|
|
contentops "haixun-backend/internal/model/content_ops/domain/usecase"
|
|
"haixun-backend/internal/svc"
|
|
"haixun-backend/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type CreateKnowledgeSourceLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCreateKnowledgeSourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateKnowledgeSourceLogic {
|
|
return &CreateKnowledgeSourceLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *CreateKnowledgeSourceLogic) CreateKnowledgeSource(req *types.CreateKnowledgeSourceHandlerReq) (resp *types.KnowledgeSourceData, err error) {
|
|
tenantID, uid, err := actorFrom(l.ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
item, err := l.svcCtx.ContentOps.CreateKnowledgeSource(l.ctx, contentops.KnowledgeSourceInput{TenantID: tenantID, OwnerUID: uid, PersonaID: req.ID, SourceType: req.SourceType, Title: req.Title, Filename: req.Filename, Content: req.Content, ContentBase64: req.ContentBase64})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
data := toKnowledgeSourceData(*item)
|
|
return &data, nil
|
|
}
|