mapping_rule_controller.go
3.3 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/mappingRule/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/mappingRule/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/mappingRule/service"
)
type MappingRuleController struct {
beego.BaseController
}
func (controller *MappingRuleController) CreateMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
createMappingRuleCommand := &command.CreateMappingRuleCommand{}
controller.Unmarshal(createMappingRuleCommand)
data, err := mappingRuleService.CreateMappingRule(ParseContext(controller.BaseController), createMappingRuleCommand)
controller.Response(data, err)
}
func (controller *MappingRuleController) UpdateMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
updateMappingRuleCommand := &command.UpdateMappingRuleCommand{}
controller.Unmarshal(updateMappingRuleCommand)
mappingRuleId, _ := controller.GetInt(":mappingRuleId")
updateMappingRuleCommand.MappingRuleId = mappingRuleId
data, err := mappingRuleService.UpdateMappingRule(ParseContext(controller.BaseController), updateMappingRuleCommand)
controller.Response(data, err)
}
func (controller *MappingRuleController) GetMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
getMappingRuleQuery := &query.GetMappingRuleQuery{}
mappingRuleId, _ := controller.GetInt(":mappingRuleId")
getMappingRuleQuery.MappingRuleId = mappingRuleId
data, err := mappingRuleService.GetMappingRule(getMappingRuleQuery)
controller.Response(data, err)
}
func (controller *MappingRuleController) RemoveMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
removeMappingRuleCommand := &command.RemoveMappingRuleCommand{}
controller.Unmarshal(removeMappingRuleCommand)
mappingRuleId, _ := controller.GetInt(":mappingRuleId")
removeMappingRuleCommand.MappingRuleId = mappingRuleId
data, err := mappingRuleService.RemoveMappingRule(removeMappingRuleCommand)
controller.Response(data, err)
}
func (controller *MappingRuleController) ListMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
listMappingRuleQuery := &query.ListMappingRuleQuery{}
offset, _ := controller.GetInt("offset")
listMappingRuleQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listMappingRuleQuery.Limit = limit
data, err := mappingRuleService.ListMappingRule(listMappingRuleQuery)
controller.Response(data, err)
}
func (controller *MappingRuleController) SearchMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
cmd := &command.SearchCommand{}
Must(controller.Unmarshal(cmd))
cmd.Context = ParseContext(controller.BaseController)
data, err := mappingRuleService.Search(cmd)
controller.Response(data, err)
}
func (controller *MappingRuleController) PrepareMappingRule() {
mappingRuleService := service.NewMappingRuleService(nil)
prepareCommand := &command.PrepareCommand{}
//controller.Unmarshal(prepareCommand)
prepareCommand.TableId, _ = controller.GetInt("tableId")
prepareCommand.FileId, _ = controller.GetInt("fileId")
data, err := mappingRuleService.Prepare(prepareCommand)
controller.Response(data, err)
}