package menu

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

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

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

func (l *CreateMenuLogic) CreateMenu(req *types.MenuReq) error {
	_, err := l.svcCtx.SystemRpc.CreateMenu(l.ctx, &system.MenuReq{
		ParentId: req.ParentId, Category: int32(req.Category), Name: req.Name, Title: req.Title,
		Code: req.Code, Path: req.Path, Permission: req.Permission, Locale: req.Locale,
		Icon: req.Icon, Sort: int32(req.Sort),
	})
	return err
}
