product_calendar_controller.go 2.7 KB
package controllers

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

type ProductCalendarController struct {
	beego.BaseController
}

func (controller *ProductCalendarController) CreateProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	createProductCalendarCommand := &command.CreateProductCalendarCommand{}
	controller.Unmarshal(createProductCalendarCommand)
	data, err := productCalendarService.CreateProductCalendar(createProductCalendarCommand)
	controller.Response(data, err)
}

func (controller *ProductCalendarController) UpdateProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	updateProductCalendarCommand := &command.UpdateProductCalendarCommand{}
	controller.Unmarshal(updateProductCalendarCommand)
	productCalendarId, _ := controller.GetInt(":productCalendarId")
	updateProductCalendarCommand.ProductCalendarId = productCalendarId
	data, err := productCalendarService.UpdateProductCalendar(updateProductCalendarCommand)
	controller.Response(data, err)
}

func (controller *ProductCalendarController) GetProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	getProductCalendarQuery := &query.GetProductCalendarQuery{}
	productCalendarId, _ := controller.GetInt(":productCalendarId")
	getProductCalendarQuery.ProductCalendarId = productCalendarId
	data, err := productCalendarService.GetProductCalendar(getProductCalendarQuery)
	controller.Response(data, err)
}

func (controller *ProductCalendarController) RemoveProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	removeProductCalendarCommand := &command.RemoveProductCalendarCommand{}
	controller.Unmarshal(removeProductCalendarCommand)
	productCalendarId, _ := controller.GetInt(":productCalendarId")
	removeProductCalendarCommand.ProductCalendarId = productCalendarId
	data, err := productCalendarService.RemoveProductCalendar(removeProductCalendarCommand)
	controller.Response(data, err)
}

func (controller *ProductCalendarController) ListProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	listProductCalendarQuery := &query.ListProductCalendarQuery{}
	offset, _ := controller.GetInt("offset")
	listProductCalendarQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listProductCalendarQuery.Limit = limit
	data, err := productCalendarService.ListProductCalendar(listProductCalendarQuery)
	controller.Response(data, err)
}