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

package userProfile

import (
	"context"
	"fmt"

	"github.com/zeromicro/go-zero/core/logx"
	"sundynix-micro-go/app/plant/api/internal/svc"
	"sundynix-micro-go/app/plant/rpc/plant"
)

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

// 获取用户资料
func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic {
	return &GetUserProfileLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetUserProfileLogic) GetUserProfile() (interface{}, error) {
	userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
	result, err := l.svcCtx.PlantRpc.GetUserProfile(l.ctx, &plant.GetProfileReq{UserId: userId})
	if err != nil {
		return nil, err
	}
	return result, nil
}
