product_plan_controller.go
4.7 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/service"
)
type ProductPlanController struct {
beego.BaseController
}
func (controller *ProductPlanController) CreateProductPlan() {
productPlanService := service.NewProductPlanService(nil)
cmd := &command.CreateProductPlanCommand{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
cmd.CompanyId = operateInfo.CompanyId
cmd.OrgId = operateInfo.OrgId
data, err := productPlanService.CreateProductPlan(cmd)
controller.Response(data, err)
}
func (controller *ProductPlanController) UpdateProductPlan() {
productPlanService := service.NewProductPlanService(nil)
updateProductPlanCommand := &command.UpdateProductPlanCommand{}
Must(controller.Unmarshal(updateProductPlanCommand))
productPlanId, _ := controller.GetInt(":productPlanId")
updateProductPlanCommand.ProductPlanId = productPlanId
data, err := productPlanService.UpdateProductPlan(updateProductPlanCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) GetProductPlan() {
productPlanService := service.NewProductPlanService(nil)
getProductPlanQuery := &query.GetProductPlanQuery{}
productPlanId, _ := controller.GetInt(":productPlanId")
getProductPlanQuery.ProductPlanId = productPlanId
data, err := productPlanService.GetProductPlan(getProductPlanQuery)
controller.Response(data, err)
}
func (controller *ProductPlanController) RemoveProductPlan() {
productPlanService := service.NewProductPlanService(nil)
removeProductPlanCommand := &command.RemoveProductPlanCommand{}
controller.Unmarshal(removeProductPlanCommand)
productPlanId, _ := controller.GetInt(":productPlanId")
removeProductPlanCommand.ProductPlanId = productPlanId
data, err := productPlanService.RemoveProductPlan(removeProductPlanCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) ListProductPlan() {
productPlanService := service.NewProductPlanService(nil)
listProductPlanQuery := &query.ListProductPlanQuery{}
offset, _ := controller.GetInt("offset")
listProductPlanQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listProductPlanQuery.Limit = limit
data, err := productPlanService.ListProductPlan(listProductPlanQuery)
controller.Response(data, err)
}
func (controller *ProductPlanController) ReceiveMaterial() {
productPlanService := service.NewProductPlanService(nil)
receiveMaterialCommand := &command.ReceiveMaterialCommand{}
Must(controller.Unmarshal(receiveMaterialCommand))
data, err := productPlanService.ReceiveMaterial(receiveMaterialCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) ReturnMaterial() {
productPlanService := service.NewProductPlanService(nil)
returnMaterialCommand := &command.ReturnMaterialCommand{}
Must(controller.Unmarshal(returnMaterialCommand))
data, err := productPlanService.ReturnMaterial(returnMaterialCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) SetOnline() {
productPlanService := service.NewProductPlanService(nil)
setOnlineCommand := &command.SetOnlineCommand{}
Must(controller.Unmarshal(setOnlineCommand))
data, err := productPlanService.SetOnline(setOnlineCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) Switch() {
productPlanService := service.NewProductPlanService(nil)
switchCommand := &command.SwitchCommand{}
Must(controller.Unmarshal(switchCommand))
data, err := productPlanService.Exchange(switchCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) SubmitProductRecord() {
productPlanService := service.NewProductPlanService(nil)
submitProductRecordCommand := &command.SubmitProductRecordCommand{}
Must(controller.Unmarshal(submitProductRecordCommand))
data, err := productPlanService.SubmitProductRecord(submitProductRecordCommand)
controller.Response(data, err)
}
func (controller *ProductPlanController) SearchProductPlan() {
productPlanService := service.NewProductPlanService(nil)
cmd := &query.SearchProductPlanQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := productPlanService.SearchProductPlan(ParseOperateInfo(controller.BaseController), cmd)
ResponseGrid(controller.BaseController, total, data, err)
}