product_calendar_controller.go 3.8 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{}
	Must(controller.Unmarshal(createProductCalendarCommand))
	data, err := productCalendarService.CreateProductCalendar(ParseOperateInfo(controller.BaseController), createProductCalendarCommand)
	controller.Response(data, err)
}

func (controller *ProductCalendarController) UpdateProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	updateProductCalendarCommand := &command.UpdateProductCalendarCommand{}
	Must(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{}
	Must(controller.Unmarshal(removeProductCalendarCommand))
	productCalendarId, _ := controller.GetInt(":productCalendarId")
	removeProductCalendarCommand.ProductCalendarId = productCalendarId
	data, err := productCalendarService.RemoveProductCalendar(removeProductCalendarCommand)
	controller.Response(data, err)
}

func (controller *ProductCalendarController) BatchRemoveProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	removeProductCalendarCommand := &command.BatchRemoveProductCalendarCommand{}
	Must(controller.Unmarshal(removeProductCalendarCommand))
	data, err := productCalendarService.BatchRemoveProductCalendar(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)
}

func (controller *ProductCalendarController) SearchProductCalendar() {
	productCalendarService := service.NewProductCalendarService(nil)
	cmd := &query.SearchProductCalendarQuery{}
	Must(controller.Unmarshal(cmd))
	operateInfo := ParseOperateInfo(controller.BaseController)
	//cmd.OrgId = operateInfo.OrgId
	cmd.CompanyId = operateInfo.CompanyId
	cmd.InOrgIds = operateInfo.OrgIds
	total, data, err := productCalendarService.SearchProductCalendar(ParseOperateInfo(controller.BaseController), cmd)
	ResponseGrid(controller.BaseController, total, data, err)
}