product_material_controller.go
4.0 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
operateInfo := ParseOperateInfo(controller.BaseController)
updateProductMaterialCommand.CompanyId = operateInfo.CompanyId
updateProductMaterialCommand.OrgId = operateInfo.OrgId
data, err := productMaterialService.UpdateProductMaterial(operateInfo, updateProductMaterialCommand)
controller.Response(data, err)
}
func (controller *ProductMaterialController) GetProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
getProductMaterialQuery := &query.GetProductMaterialQuery{}
productMaterialId, _ := controller.GetInt(":productMaterialId")
getProductMaterialQuery.ProductMaterialId = productMaterialId
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productMaterialService.GetProductMaterial(operateInfo, 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
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productMaterialService.RemoveProductMaterial(operateInfo, removeProductMaterialCommand)
controller.Response(data, err)
}
//没用到
func (controller *ProductMaterialController) ListProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
listProductMaterialQuery := &query.ListProductMaterialQuery{}
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productMaterialService.ListProductMaterial(operateInfo, listProductMaterialQuery)
controller.Response(data, err)
}
func (controller *ProductMaterialController) SearchProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
listProductMaterialQuery := &query.ListProductMaterialQuery{}
controller.Unmarshal(listProductMaterialQuery)
operateInfo := ParseOperateInfo(controller.BaseController)
total, data, err := productMaterialService.SearchProductMaterial(operateInfo, listProductMaterialQuery)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *ProductMaterialController) BatchRemoveProductMaterial() {
productMaterialService := service.NewProductMaterialService(nil)
batchremoveProductMaterialCommand := &command.BatchRemoveProductMaterialCommand{}
controller.Unmarshal(batchremoveProductMaterialCommand)
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productMaterialService.BatchRemoveProductMaterial(operateInfo, batchremoveProductMaterialCommand)
controller.Response(data, err)
}