product_line_controller.go
2.4 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productLine/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productLine/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productLine/service"
)
type ProductLineController struct {
beego.BaseController
}
func (controller *ProductLineController) CreateProductLine() {
productLineService := service.NewProductLineService(nil)
createProductLineCommand := &command.CreateProductLineCommand{}
controller.Unmarshal(createProductLineCommand)
data, err := productLineService.CreateProductLine(createProductLineCommand)
controller.Response(data, err)
}
func (controller *ProductLineController) UpdateProductLine() {
productLineService := service.NewProductLineService(nil)
updateProductLineCommand := &command.UpdateProductLineCommand{}
controller.Unmarshal(updateProductLineCommand)
lineId, _ := controller.GetInt(":lineId")
updateProductLineCommand.LineId = lineId
data, err := productLineService.UpdateProductLine(updateProductLineCommand)
controller.Response(data, err)
}
func (controller *ProductLineController) GetProductLine() {
productLineService := service.NewProductLineService(nil)
getProductLineQuery := &query.GetProductLineQuery{}
lineId, _ := controller.GetInt(":lineId")
getProductLineQuery.LineId = lineId
data, err := productLineService.GetProductLine(getProductLineQuery)
controller.Response(data, err)
}
func (controller *ProductLineController) RemoveProductLine() {
productLineService := service.NewProductLineService(nil)
removeProductLineCommand := &command.RemoveProductLineCommand{}
controller.Unmarshal(removeProductLineCommand)
lineId, _ := controller.GetInt(":lineId")
removeProductLineCommand.LineId = lineId
data, err := productLineService.RemoveProductLine(removeProductLineCommand)
controller.Response(data, err)
}
func (controller *ProductLineController) ListProductLine() {
productLineService := service.NewProductLineService(nil)
listProductLineQuery := &query.ListProductLineQuery{}
offset, _ := controller.GetInt("offset")
listProductLineQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listProductLineQuery.Limit = limit
data, err := productLineService.ListProductLine(listProductLineQuery)
controller.Response(data, err)
}