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 CreateBadgeConfigLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

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

func (l *CreateBadgeConfigLogic) CreateBadgeConfig(req *types.CreateBadgeConfigReq) error {
	_, err := l.svcCtx.PlantRpc.CreateBadgeConfig(l.ctx, &plantPb.CreateBadgeConfigReq{
		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
}
