product_group_controller.go
4.9 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productGroup/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productGroup/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productGroup/service"
)
type ProductGroupController struct {
beego.BaseController
}
func (controller *ProductGroupController) CreateProductGroup() {
productGroupService := service.NewProductGroupService(nil)
createProductGroupCommand := &command.CreateProductGroupCommand{}
Must(controller.Unmarshal(createProductGroupCommand))
data, err := productGroupService.CreateProductGroup(ParseOperateInfo(controller.BaseController), createProductGroupCommand)
controller.Response(data, err)
}
func (controller *ProductGroupController) UpdateProductGroup() {
productGroupService := service.NewProductGroupService(nil)
updateProductGroupCommand := &command.UpdateProductGroupCommand{}
Must(controller.Unmarshal(updateProductGroupCommand))
productGroupId, _ := controller.GetInt(":productGroupId")
updateProductGroupCommand.ProductGroupId = productGroupId
data, err := productGroupService.UpdateProductGroup(updateProductGroupCommand)
controller.Response(data, err)
}
func (controller *ProductGroupController) GetProductGroup() {
productGroupService := service.NewProductGroupService(nil)
getProductGroupQuery := &query.GetProductGroupQuery{}
productGroupId, _ := controller.GetInt(":productGroupId")
getProductGroupQuery.ProductGroupId = productGroupId
data, err := productGroupService.GetProductGroup(getProductGroupQuery)
controller.Response(data, err)
}
func (controller *ProductGroupController) RemoveProductGroup() {
productGroupService := service.NewProductGroupService(nil)
removeProductGroupCommand := &command.RemoveProductGroupCommand{}
controller.Unmarshal(removeProductGroupCommand)
productGroupId, _ := controller.GetInt(":productGroupId")
removeProductGroupCommand.ProductGroupId = productGroupId
data, err := productGroupService.RemoveProductGroup(removeProductGroupCommand)
controller.Response(data, err)
}
func (controller *ProductGroupController) BatchRemoveProductGroup() {
productGroupService := service.NewProductGroupService(nil)
removeProductGroupCommand := &command.BatchRemoveProductGroupCommand{}
Must(controller.Unmarshal(removeProductGroupCommand))
data, err := productGroupService.BatchRemoveProductGroup(removeProductGroupCommand)
controller.Response(data, err)
}
func (controller *ProductGroupController) ListProductGroup() {
productGroupService := service.NewProductGroupService(nil)
listProductGroupQuery := &query.ListProductGroupQuery{}
offset, _ := controller.GetInt("offset")
listProductGroupQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listProductGroupQuery.Limit = limit
data, err := productGroupService.ListProductGroup(listProductGroupQuery)
controller.Response(data, err)
}
func (controller *ProductGroupController) SearchProductGroup() {
productGroupService := service.NewProductGroupService(nil)
cmd := &query.SearchProductGroupQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := productGroupService.SearchProductGroup(ParseOperateInfo(controller.BaseController), cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *ProductGroupController) SearchProductGroupEmployees() {
productGroupService := service.NewProductGroupService(nil)
cmd := &query.SearchProductGroupEmployeesQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
_, data, err := productGroupService.SearchProductGroupEmployeesV2(operateInfo, cmd)
controller.Response(data, err)
}
func (controller *ProductGroupController) GetSignInEmployeeQuery() {
productGroupService := service.NewProductGroupService(nil)
cmd := &query.GetSignInEmployeeQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
data, err := productGroupService.GetSignEmployee(cmd)
controller.Response(data, err)
}
func (controller *ProductGroupController) SelectorProductGroups() {
productGroupService := service.NewProductGroupService(nil)
cmd := &query.SearchProductGroupQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
data, err := productGroupService.SelectorProductGroup(ParseOperateInfo(controller.BaseController), cmd)
controller.Response(data, err)
}