product_group_controller.go
3.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
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{}
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{}
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) 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)
listProductGroupQuery := &query.SearchProductGroupQuery{}
controller.Unmarshal(listProductGroupQuery)
total, data, err := productGroupService.SearchProductGroup(ParseOperateInfo(controller.BaseController), listProductGroupQuery)
ResponseGrid(controller.BaseController, total, data, err)
}