device_collection_controller.go
2.9 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/service"
"strconv"
)
type DeviceCollectionController struct {
beego.BaseController
}
func (controller *DeviceCollectionController) CreateDeviceCollection() {
deviceCollectionService := service.NewDeviceCollectionService(nil)
createDeviceCollectionCommand := &command.CreateDeviceCollectionCommand{}
controller.Unmarshal(createDeviceCollectionCommand)
data, err := deviceCollectionService.CreateDeviceCollection(createDeviceCollectionCommand)
controller.Response(data, err)
}
func (controller *DeviceCollectionController) UpdateDeviceCollection() {
deviceCollectionService := service.NewDeviceCollectionService(nil)
updateDeviceCollectionCommand := &command.UpdateDeviceCollectionCommand{}
controller.Unmarshal(updateDeviceCollectionCommand)
//Id, _ := controller.GetString(":Id")
//updateDeviceCollectionCommand.Id = Id
Id := controller.GetString(":Id")
deviceCollectionId,_:= strconv.Atoi(Id)
updateDeviceCollectionCommand.DeviceCollectionId = int64(deviceCollectionId)
data, err := deviceCollectionService.UpdateDeviceCollection(updateDeviceCollectionCommand)
controller.Response(data, err)
}
func (controller *DeviceCollectionController) GetDeviceCollection() {
deviceCollectionService := service.NewDeviceCollectionService(nil)
getDeviceCollectionQuery := &query.GetDeviceCollectionQuery{}
//Id, _ := controller.GetString(":Id")
//getDeviceCollectionQuery.Id = Id
Id := controller.GetString(":Id")
deviceCollectionId,_:= strconv.Atoi(Id)
getDeviceCollectionQuery.DeviceCollectionId = int64(deviceCollectionId)
data, err := deviceCollectionService.GetDeviceCollection(getDeviceCollectionQuery)
controller.Response(data, err)
}
func (controller *DeviceCollectionController) RemoveDeviceCollection() {
deviceCollectionService := service.NewDeviceCollectionService(nil)
removeDeviceCollectionCommand := &command.RemoveDeviceCollectionCommand{}
controller.Unmarshal(removeDeviceCollectionCommand)
Id := controller.GetString(":Id")
deviceCollectionId,_:= strconv.Atoi(Id)
removeDeviceCollectionCommand.DeviceCollectionId = int64(deviceCollectionId)
data, err := deviceCollectionService.RemoveDeviceCollection(removeDeviceCollectionCommand)
controller.Response(data, err)
}
func (controller *DeviceCollectionController) ListDeviceCollection() {
deviceCollectionService := service.NewDeviceCollectionService(nil)
listDeviceCollectionQuery := &query.ListDeviceCollectionQuery{}
_ = controller.Unmarshal(listDeviceCollectionQuery)
data, err := deviceCollectionService.ListDeviceCollection(listDeviceCollectionQuery)
controller.Response(data, err)
}