query_set_controller.go 6.2 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/querySet/command"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/querySet/query"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/querySet/service"
)

type QuerySetController struct {
	beego.BaseController
}

func (controller *QuerySetController) CreateQuerySet() {
	querySetService := service.NewQuerySetService(nil)
	createQuerySetCommand := &command.CreateQuerySetCommand{}
	Must(controller.Unmarshal(createQuerySetCommand))
	data, err := querySetService.CreateQuerySet(ParseContext(controller.BaseController), createQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) UpdateQuerySet() {
	querySetService := service.NewQuerySetService(nil)
	updateQuerySetCommand := &command.UpdateQuerySetCommand{}
	Must(controller.Unmarshal(updateQuerySetCommand))
	Id, _ := controller.GetInt(":querySetId")
	updateQuerySetCommand.QuerySetId = Id
	data, err := querySetService.UpdateQuerySet(ParseContext(controller.BaseController), updateQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) PreviewPrepare() {
	querySetService := service.NewQuerySetService(nil)
	updateQuerySetCommand := &command.UpdateQuerySetCommand{}
	Must(controller.Unmarshal(updateQuerySetCommand))
	data, err := querySetService.PreviewPrepare(ParseContext(controller.BaseController), updateQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) CalculateItemPreview() {
	querySetService := service.NewQuerySetService(nil)
	updateQuerySetCommand := &query.CalculateItemPreviewQuery{}
	Must(controller.Unmarshal(updateQuerySetCommand))
	data, err := querySetService.CalculateItemPreview(ParseContext(controller.BaseController), updateQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) CalculateItemExport() {
	querySetService := service.NewQuerySetService(nil)
	updateQuerySetCommand := &query.CalculateItemPreviewQuery{}
	Must(controller.Unmarshal(updateQuerySetCommand))
	data, err := querySetService.CalculateItemExport(ParseContext(controller.BaseController), updateQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) GetQuerySet() {
	querySetService := service.NewQuerySetService(nil)
	getQuerySetQuery := &query.GetQuerySetQuery{}
	Id, _ := controller.GetInt(":querySetId")
	getQuerySetQuery.QuerySetId = Id
	data, err := querySetService.GetQuerySet(ParseContext(controller.BaseController), getQuerySetQuery)
	controller.Response(data, err)
}

func (controller *QuerySetController) RemoveQuerySet() {
	querySetService := service.NewQuerySetService(nil)
	removeQuerySetCommand := &command.RemoveQuerySetCommand{}
	controller.Unmarshal(removeQuerySetCommand)
	Id, _ := controller.GetInt(":querySetId")
	removeQuerySetCommand.QuerySetId = Id
	data, err := querySetService.RemoveQuerySet(ParseContext(controller.BaseController), removeQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) ListQuerySet() {
	querySetService := service.NewQuerySetService(nil)
	listQuerySetQuery := &query.ListQuerySetQuery{}
	offset, _ := controller.GetInt("offset")
	listQuerySetQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listQuerySetQuery.Limit = limit
	data, err := querySetService.ListQuerySet(ParseContext(controller.BaseController), listQuerySetQuery)
	controller.Response(data, err)
}

func (controller *QuerySetController) ChangeStatus() {
	querySetService := service.NewQuerySetService(nil)
	changeStatusCommand := &command.ChangeStatusCommand{}
	Must(controller.Unmarshal(changeStatusCommand))
	data, err := querySetService.ChangeStatus(ParseContext(controller.BaseController), changeStatusCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) Copy() {
	querySetService := service.NewQuerySetService(nil)
	copyCommand := &command.CopyCommand{}
	Must(controller.Unmarshal(copyCommand))
	data, err := querySetService.Copy(ParseContext(controller.BaseController), copyCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) DependencyGraph() {
	querySetService := service.NewQuerySetService(nil)
	dependencyGraphQuery := &query.DependencyGraphQuery{}
	Must(controller.Unmarshal(dependencyGraphQuery))
	data, err := querySetService.DependencyGraph(ParseContext(controller.BaseController), dependencyGraphQuery)
	controller.Response(data, err)
}

func (controller *QuerySetController) Move() {
	querySetService := service.NewQuerySetService(nil)
	moveCommand := &command.MoveCommand{}
	Must(controller.Unmarshal(moveCommand))
	data, err := querySetService.Move(ParseContext(controller.BaseController), moveCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) Rename() {
	querySetService := service.NewQuerySetService(nil)
	renameCommand := &command.RenameCommand{}
	Must(controller.Unmarshal(renameCommand))
	data, err := querySetService.Rename(ParseContext(controller.BaseController), renameCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) SearchQuerySet() {
	querySetService := service.NewQuerySetService(nil)
	searchQuerySetQuery := &query.SearchQuerySetQuery{}
	Must(controller.Unmarshal(searchQuerySetQuery))
	data, err := querySetService.SearchQuerySet(ParseContext(controller.BaseController), searchQuerySetQuery)
	controller.Response(data, err)
}

func (controller *QuerySetController) CalculateSetPreview() {
	querySetService := service.NewQuerySetService(nil)
	updateQuerySetCommand := &command.UpdateQuerySetCommand{}
	Must(controller.Unmarshal(updateQuerySetCommand))
	data, err := querySetService.CalculateSetPreview(ParseContext(controller.BaseController), updateQuerySetCommand)
	controller.Response(data, err)
}

func (controller *QuerySetController) CalculateSetExport() {
	querySetService := service.NewQuerySetService(nil)
	updateQuerySetCommand := &command.UpdateQuerySetCommand{}
	Must(controller.Unmarshal(updateQuerySetCommand))
	data, err := querySetService.CalculateSetExport(ParseContext(controller.BaseController), updateQuerySetCommand)
	controller.Response(data, err)
}