workshop_controller.go
2.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
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{}
controller.Unmarshal(createWorkshopCommand)
data, err := workshopService.CreateWorkshop(createWorkshopCommand)
controller.Response(data, err)
}
func (controller *WorkshopController) UpdateWorkshop() {
workshopService := service.NewWorkshopService(nil)
updateWorkshopCommand := &command.UpdateWorkshopCommand{}
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)
}