package config

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

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

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

func (l *UpdateBadgeConfigLogic) UpdateBadgeConfig(req *types.UpdateBadgeConfigReq) error {
	_, err := l.svcCtx.PlantRpc.UpdateBadgeConfig(l.ctx, &plantPb.UpdateBadgeConfigReq{
		Id: req.Id, Name: req.Name, Description: req.Description, Dimension: req.Dimension,
		GroupId: req.GroupId, Tier: int32(req.Tier), TargetAction: req.TargetAction,
		Threshold: req.Threshold, RewardSunlight: req.RewardSunlight, IconId: req.IconId, Sort: int32(req.Sort),
	})
	return err
}
