workshop_controller.go
3.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/workshop/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/workshop/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/workshop/service"
)
type WorkshopController struct {
beego.BaseController
}
func (controller *WorkshopController) CreateWorkshop() {
workshopService := service.NewWorkshopService(nil)
createWorkshopCommand := &command.CreateWorkshopCommand{}
Must(controller.Unmarshal(createWorkshopCommand))
data, err := workshopService.CreateWorkshop(ParseOperateInfo(controller.BaseController), createWorkshopCommand)
controller.Response(data, err)
}
func (controller *WorkshopController) UpdateWorkshop() {
workshopService := service.NewWorkshopService(nil)
updateWorkshopCommand := &command.UpdateWorkshopCommand{}
Must(controller.Unmarshal(updateWorkshopCommand))
workshopId, _ := controller.GetInt(":workshopId")
updateWorkshopCommand.WorkshopId = workshopId
data, err := workshopService.UpdateWorkshop(updateWorkshopCommand)
controller.Response(data, err)
}
func (controller *WorkshopController) GetWorkshop() {
workshopService := service.NewWorkshopService(nil)
getWorkshopQuery := &query.GetWorkshopQuery{}
workshopId, _ := controller.GetInt(":workshopId")
getWorkshopQuery.WorkshopId = workshopId
data, err := workshopService.GetWorkshop(getWorkshopQuery)
controller.Response(data, err)
}
func (controller *WorkshopController) RemoveWorkshop() {
workshopService := service.NewWorkshopService(nil)
removeWorkshopCommand := &command.RemoveWorkshopCommand{}
controller.Unmarshal(removeWorkshopCommand)
workshopId, _ := controller.GetInt(":workshopId")
removeWorkshopCommand.WorkshopId = workshopId
data, err := workshopService.RemoveWorkshop(removeWorkshopCommand)
controller.Response(data, err)
}
func (controller *WorkshopController) ListWorkshop() {
workshopService := service.NewWorkshopService(nil)
listWorkshopQuery := &query.ListWorkshopQuery{}
offset, _ := controller.GetInt("offset")
listWorkshopQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listWorkshopQuery.Limit = limit
data, err := workshopService.ListWorkshop(listWorkshopQuery)
controller.Response(data, err)
}
func (controller *WorkshopController) SearchWorkshop() {
workshopService := service.NewWorkshopService(nil)
listWorkshopQuery := &query.SearchWorkshopQuery{}
Must(controller.Unmarshal(listWorkshopQuery))
data, err := workshopService.SearchWorkshop(ParseOperateInfo(controller.BaseController), listWorkshopQuery)
controller.Response(data, err)
}
func (controller *WorkshopController) SelectorWorkshop() {
workshopService := service.NewWorkshopService(nil)
listWorkshopQuery := &query.SearchWorkshopQuery{}
Must(controller.Unmarshal(listWorkshopQuery))
data, err := workshopService.SearchWorkshop(ParseOperateInfo(controller.BaseController), listWorkshopQuery)
controller.Response(data, err)
}
func (controller *WorkshopController) SelectorWorkshopSection() {
workshopService := service.NewWorkshopService(nil)
getWorkshopQuery := &query.GetWorkshopQuery{}
Must(controller.Unmarshal(getWorkshopQuery))
data, err := workshopService.SelectorWorkshopSection(ParseOperateInfo(controller.BaseController), getWorkshopQuery)
controller.Response(data, err)
}