product_job_controller.go 2.8 KB
package controllers

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

type ProductJobController struct {
	beego.BaseController
}

func (controller *ProductJobController) CreateProductJob() {
	productJobService := service.NewProductJobService(nil)
	createProductJobCommand := &command.CreateProductJobCommand{}
	controller.Unmarshal(createProductJobCommand)
	data, err := productJobService.CreateProductJob(ParseOperateInfo(controller.BaseController), createProductJobCommand)
	controller.Response(data, err)
}

func (controller *ProductJobController) UpdateProductJob() {
	productJobService := service.NewProductJobService(nil)
	updateProductJobCommand := &command.UpdateProductJobCommand{}
	controller.Unmarshal(updateProductJobCommand)
	productJobId, _ := controller.GetInt(":productJobId")
	updateProductJobCommand.ProductJobId = productJobId
	data, err := productJobService.UpdateProductJob(updateProductJobCommand)
	controller.Response(data, err)
}

func (controller *ProductJobController) GetProductJob() {
	productJobService := service.NewProductJobService(nil)
	getProductJobQuery := &query.GetProductJobQuery{}
	productJobId, _ := controller.GetInt(":productJobId")
	getProductJobQuery.ProductJobId = productJobId
	data, err := productJobService.GetProductJob(getProductJobQuery)
	controller.Response(data, err)
}

func (controller *ProductJobController) RemoveProductJob() {
	productJobService := service.NewProductJobService(nil)
	removeProductJobCommand := &command.RemoveProductJobCommand{}
	controller.Unmarshal(removeProductJobCommand)
	productJobId, _ := controller.GetInt(":productJobId")
	removeProductJobCommand.ProductJobId = productJobId
	data, err := productJobService.RemoveProductJob(removeProductJobCommand)
	controller.Response(data, err)
}

func (controller *ProductJobController) ListProductJob() {
	productJobService := service.NewProductJobService(nil)
	listProductJobQuery := &query.ListProductJobQuery{}
	offset, _ := controller.GetInt("offset")
	listProductJobQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listProductJobQuery.Limit = limit
	data, err := productJobService.ListProductJob(listProductJobQuery)
	controller.Response(data, err)
}

func (controller *ProductJobController) SearchProductJob() {
	productJobService := service.NewProductJobService(nil)
	listProductJobQuery := &query.SearchProductJobQuery{}
	controller.Unmarshal(listProductJobQuery)
	total, data, err := productJobService.SearchProductJob(ParseOperateInfo(controller.BaseController), listProductJobQuery)
	ResponseGrid(controller.BaseController, total, data, err)
}