product_material_controller.go
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productMaterial/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productMaterial/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productMaterial/service"
)
type ProductMaterialController struct {
beego.BaseController
}
func (controller *ProductMaterialController) CreateProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
cmd := &command.CreateProductMaterialCommand{}
controller.Unmarshal(cmd)
operateInfo := ParseOperateInfo(controller.BaseController)
cmd.CompanyId = operateInfo.CompanyId
cmd.OrgId = operateInfo.OrgId
data, err := productMaterialService.CreateProductMaterial(operateInfo, cmd)
controller.Response(data, err)
}
func (controller *ProductMaterialController) UpdateProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
updateProductMaterialCommand := &command.UpdateProductMaterialCommand{}
controller.Unmarshal(updateProductMaterialCommand)
productMaterialId, _ := controller.GetInt(":productMaterialId")
updateProductMaterialCommand.ProductMaterialId = productMaterialId
data, err := productMaterialService.UpdateProductMaterial(updateProductMaterialCommand)
controller.Response(data, err)
}
func (controller *ProductMaterialController) GetProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
getProductMaterialQuery := &query.GetProductMaterialQuery{}
productMaterialId, _ := controller.GetInt(":productMaterialId")
getProductMaterialQuery.ProductMaterialId = productMaterialId
data, err := productMaterialService.GetProductMaterial(getProductMaterialQuery)
controller.Response(data, err)
}
func (controller *ProductMaterialController) RemoveProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
removeProductMaterialCommand := &command.RemoveProductMaterialCommand{}
controller.Unmarshal(removeProductMaterialCommand)
productMaterialId, _ := controller.GetInt(":productMaterialId")
removeProductMaterialCommand.ProductMaterialId = productMaterialId
data, err := productMaterialService.RemoveProductMaterial(removeProductMaterialCommand)
controller.Response(data, err)
}
func (controller *ProductMaterialController) ListProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
listProductMaterialQuery := &query.ListProductMaterialQuery{}
offset, _ := controller.GetInt("offset")
listProductMaterialQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listProductMaterialQuery.Limit = limit
data, err := productMaterialService.ListProductMaterial(listProductMaterialQuery)
controller.Response(data, err)
}