menu_controller.go 2.0 KB
package web_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/custommenu/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/custommenu/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/custommenu/service"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)

type MenuController struct {
	baseController
}

func (controller *MenuController) MenuList() {
	menuService := service.NewMenuService(nil)
	menuListQuery := &query.MenuListQuery{}
	err := controller.Unmarshal(menuListQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	menuListQuery.Operator = controller.GetOperator()
	data, err := menuService.CustomizeMenus(menuListQuery)
	controller.Response(data, err)
}

func (controller *MenuController) MenuUpdate() {
	menuService := service.NewMenuService(nil)
	menuUpdateQuery := &command.MenuUpdateCommand{}
	err := controller.Unmarshal(menuUpdateQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	menuUpdateQuery.Operator = controller.GetOperator()
	data, err := menuService.MenuUpdate(menuUpdateQuery)
	controller.Response(data, err)
}

func (controller *MenuController) MenuFavorite() {
	menuService := service.NewMenuService(nil)
	menuFavoriteCommand := &command.MenuFavoriteCommand{}
	err := controller.Unmarshal(menuFavoriteCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	menuFavoriteCommand.Operator = controller.GetOperator()
	data, err := menuService.MenuFavorite(menuFavoriteCommand)
	controller.Response(data, err)
}

func (controller *MenuController) MenuSearch() {
	menuService := service.NewMenuService(nil)
	menuListQuery := &query.MenuListQuery{}
	err := controller.Unmarshal(menuListQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	menuListQuery.Operator = controller.GetOperator()
	data, err := menuService.MenuSearch(menuListQuery)
	controller.Response(data, err)
}