package myPlant

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

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

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

func (l *AddGrowthRecordLogic) AddGrowthRecord(req *types.GrowthRecordReq) error {
	userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
	_, err := l.svcCtx.PlantRpc.AddGrowthRecord(l.ctx, &plant.AddGrowthRecordReq{
		UserId: userId, PlantId: req.PlantId, Content: req.Content, ImgIds: req.ImgIds,
	})
	return err
}
