package authority

import (
	"context"

	"kami/internal/service"
	"kami/utility/lib/libErr"

	"kami/api/authority/v1"
)

func (c *ControllerV1) MenuDelete(ctx context.Context, req *v1.MenuDeleteReq) (res *v1.MenuDeleteRes, err error) {
	menu := service.Menu()
	result, err := menu.GetMenuListByID(ctx, req.ID)
	//	通过ID列表删除数据
	if err != nil {
		idList := make([]uint, 0)
		for _, rule := range result {
			idList = append(idList, rule.Id)
		}
		err = menu.DeleteMenuListByID(ctx, idList)
		libErr.ErrIsNil(ctx, err, "删除失败")
	}
	return
}
