product_section_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
64
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productSection/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productSection/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productSection/service"
)
type ProductSectionController struct {
beego.BaseController
}
func (controller *ProductSectionController) CreateProductSection() {
productSectionService := service.NewProductSectionService(nil)
createProductSectionCommand := &command.CreateProductSectionCommand{}
controller.Unmarshal(createProductSectionCommand)
data, err := productSectionService.CreateProductSection(createProductSectionCommand)
controller.Response(data, err)
}
func (controller *ProductSectionController) UpdateProductSection() {
productSectionService := service.NewProductSectionService(nil)
updateProductSectionCommand := &command.UpdateProductSectionCommand{}
controller.Unmarshal(updateProductSectionCommand)
sectionId, _ := controller.GetInt(":sectionId")
updateProductSectionCommand.SectionId = sectionId
data, err := productSectionService.UpdateProductSection(updateProductSectionCommand)
controller.Response(data, err)
}
func (controller *ProductSectionController) GetProductSection() {
productSectionService := service.NewProductSectionService(nil)
getProductSectionQuery := &query.GetProductSectionQuery{}
sectionId, _ := controller.GetInt(":sectionId")
getProductSectionQuery.SectionId = sectionId
data, err := productSectionService.GetProductSection(getProductSectionQuery)
controller.Response(data, err)
}
func (controller *ProductSectionController) RemoveProductSection() {
productSectionService := service.NewProductSectionService(nil)
removeProductSectionCommand := &command.RemoveProductSectionCommand{}
controller.Unmarshal(removeProductSectionCommand)
sectionId, _ := controller.GetInt(":sectionId")
removeProductSectionCommand.SectionId = sectionId
lineId, _ := controller.GetInt("lineId")
workshopId, _ := controller.GetInt("workshopId")
removeProductSectionCommand.LineId = lineId
removeProductSectionCommand.WorkshopId = workshopId
data, err := productSectionService.RemoveProductSection(removeProductSectionCommand)
controller.Response(data, err)
}
func (controller *ProductSectionController) ListProductSection() {
productSectionService := service.NewProductSectionService(nil)
listProductSectionQuery := &query.ListProductSectionQuery{}
offset, _ := controller.GetInt("offset")
listProductSectionQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listProductSectionQuery.Limit = limit
data, err := productSectionService.ListProductSection(listProductSectionQuery)
controller.Response(data, err)
}