unit_conversion_controller.go
4.1 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/service"
)
type UnitConversionController struct {
beego.BaseController
}
func (controller *UnitConversionController) CreateUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
createUnitConversionCommand := &command.CreateUnitConversionCommand{}
Must(controller.Unmarshal(createUnitConversionCommand))
data, err := unitConversionService.CreateUnitConversion(ParseOperateInfo(controller.BaseController), createUnitConversionCommand)
controller.Response(data, err)
}
func (controller *UnitConversionController) UpdateUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
updateUnitConversionCommand := &command.UpdateUnitConversionCommand{}
Must(controller.Unmarshal(updateUnitConversionCommand))
unitConversionId, _ := controller.GetInt(":unitConversionId")
updateUnitConversionCommand.UnitConversionId = unitConversionId
data, err := unitConversionService.UpdateUnitConversion(updateUnitConversionCommand)
controller.Response(data, err)
}
func (controller *UnitConversionController) GetUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
getUnitConversionQuery := &query.GetUnitConversionQuery{}
unitConversionId, _ := controller.GetInt(":unitConversionId")
getUnitConversionQuery.UnitConversionId = unitConversionId
data, err := unitConversionService.GetUnitConversion(getUnitConversionQuery)
controller.Response(data, err)
}
func (controller *UnitConversionController) RemoveUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
removeUnitConversionCommand := &command.RemoveUnitConversionCommand{}
controller.Unmarshal(removeUnitConversionCommand)
unitConversionId, _ := controller.GetInt(":unitConversionId")
removeUnitConversionCommand.UnitConversionId = unitConversionId
data, err := unitConversionService.RemoveUnitConversion(removeUnitConversionCommand)
controller.Response(data, err)
}
func (controller *UnitConversionController) BatchRemoveUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
removeUnitConversionCommand := &command.BatchRemoveUnitConversionCommand{}
Must(controller.Unmarshal(removeUnitConversionCommand))
data, err := unitConversionService.BatchRemoveUnitConversion(removeUnitConversionCommand)
controller.Response(data, err)
}
func (controller *UnitConversionController) ListUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
listUnitConversionQuery := &query.ListUnitConversionQuery{}
offset, _ := controller.GetInt("offset")
listUnitConversionQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listUnitConversionQuery.Limit = limit
data, err := unitConversionService.ListUnitConversion(listUnitConversionQuery)
controller.Response(data, err)
}
func (controller *UnitConversionController) SearchUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
cmd := &query.SearchUnitConversionQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
//cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.InOrgIds = operateInfo.OrgIds
total, data, err := unitConversionService.SearchUnitConversion(ParseOperateInfo(controller.BaseController), cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *UnitConversionController) SearchMaterial() {
unitConversionService := service.NewUnitConversionService(nil)
cmd := &query.SearchMaterialsQuery{}
Must(controller.Unmarshal(cmd))
operateInfo := ParseOperateInfo(controller.BaseController)
cmd.OrgId = operateInfo.OrgId
cmd.CompanyId = operateInfo.CompanyId
cmd.IntelligentWeighingFlag = 1
_, data, err := unitConversionService.SearchMaterial(ParseOperateInfo(controller.BaseController), cmd)
controller.Response(data, err)
}