device_collection_controller.go 2.6 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/service"
)

type DeviceCollectionController struct {
	beego.BaseController
}

func (controller *DeviceCollectionController) CreateDeviceCollection() {
	deviceCollectionService := service.NewDeviceCollectionService(nil)
	createDeviceCollectionCommand := &command.CreateDeviceCollectionCommand{}
	controller.Unmarshal(createDeviceCollectionCommand)
	data, err := deviceCollectionService.CreateDeviceCollection(createDeviceCollectionCommand)
	controller.Response(data, err)
}

func (controller *DeviceCollectionController) UpdateDeviceCollection() {
	deviceCollectionService := service.NewDeviceCollectionService(nil)
	updateDeviceCollectionCommand := &command.UpdateDeviceCollectionCommand{}
	controller.Unmarshal(updateDeviceCollectionCommand)
	//Id, _ := controller.GetString(":Id")
	//updateDeviceCollectionCommand.Id = Id
	data, err := deviceCollectionService.UpdateDeviceCollection(updateDeviceCollectionCommand)
	controller.Response(data, err)
}

func (controller *DeviceCollectionController) GetDeviceCollection() {
	deviceCollectionService := service.NewDeviceCollectionService(nil)
	getDeviceCollectionQuery := &query.GetDeviceCollectionQuery{}
	//Id, _ := controller.GetString(":Id")
	//getDeviceCollectionQuery.Id = Id
	data, err := deviceCollectionService.GetDeviceCollection(getDeviceCollectionQuery)
	controller.Response(data, err)
}

func (controller *DeviceCollectionController) RemoveDeviceCollection() {
	deviceCollectionService := service.NewDeviceCollectionService(nil)
	removeDeviceCollectionCommand := &command.RemoveDeviceCollectionCommand{}
	controller.Unmarshal(removeDeviceCollectionCommand)
	//Id, _ := controller.GetString(":Id")
	//removeDeviceCollectionCommand.Id = Id
	data, err := deviceCollectionService.RemoveDeviceCollection(removeDeviceCollectionCommand)
	controller.Response(data, err)
}

func (controller *DeviceCollectionController) ListDeviceCollection() {
	deviceCollectionService := service.NewDeviceCollectionService(nil)
	listDeviceCollectionQuery := &query.ListDeviceCollectionQuery{}
	offset, _ := controller.GetInt("offset")
	listDeviceCollectionQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listDeviceCollectionQuery.Limit = limit
	data, err := deviceCollectionService.ListDeviceCollection(listDeviceCollectionQuery)
	controller.Response(data, err)
}