package backend

import (
	"bwallet/pkg/errno"
	"bwallet/pkg/handler"
	"bwallet/service/api_module_service"
	"github.com/gin-gonic/gin"
)

func GetApiModules(c *gin.Context) {
	//token := c.Request.Header.Get("Token")
	//user, _ := util.ParseToken(token)
	//
	//if ("administrator" != user.UserInfo.Group) {
	//	handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
	//	return
	//}

	apiModuleService := api_module_service.ApiModule{}
	moudles, err := apiModuleService.GetAll()
	if err != nil {
		handler.SendResponse(c, errno.InternalServerError, nil)
		return
	}

	handler.SendResponse(c, nil, moudles)
}

func GetMenu(c *gin.Context) {
	apiModuleService := api_module_service.ApiModule{}
	moudles := apiModuleService.GetMenu()

	handler.SendResponse(c, nil, moudles)
}