// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package persona

import (
	"context"

	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetPersonaLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetPersonaLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPersonaLogic {
	return &GetPersonaLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetPersonaLogic) GetPersona(req *types.PersonaPath) (resp *types.PersonaData, err error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	item, err := l.svcCtx.Persona.Get(l.ctx, tenantID, uid, req.ID)
	if err != nil {
		return nil, err
	}
	out := toPersonaData(*item)
	return &out, nil
}
