dictionary_controller.go
1.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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/service"
)
type DictionaryController struct {
beego.BaseController
}
func (controller *DictionaryController) CreateDictionary() {
dictionaryService := service.NewDictionaryService(nil)
createDictionaryCommand := &command.CreateDictionaryCommand{}
_ = controller.Unmarshal(createDictionaryCommand)
data, err := dictionaryService.CreateDictionary(createDictionaryCommand)
controller.Response(data, err)
}
func (controller *DictionaryController) UpdateDictionary() {
dictionaryService := service.NewDictionaryService(nil)
updateDictionaryCommand := &command.UpdateDictionaryCommand{}
_ = controller.Unmarshal(updateDictionaryCommand)
dictionaryId, _ := controller.GetInt64(":dictionaryId")
updateDictionaryCommand.DictionaryId = dictionaryId
data, err := dictionaryService.UpdateDictionary(updateDictionaryCommand)
controller.Response(data, err)
}
func (controller *DictionaryController) GetDictionary() {
dictionaryService := service.NewDictionaryService(nil)
getDictionaryQuery := &query.GetDictionaryQuery{}
dictionaryId, _ := controller.GetInt64(":dictionaryId")
getDictionaryQuery.DictionaryId = dictionaryId
data, err := dictionaryService.GetDictionary(getDictionaryQuery)
controller.Response(data, err)
}
func (controller *DictionaryController) ListDictionary() {
dictionaryService := service.NewDictionaryService(nil)
listDictionaryQuery := &query.ListDictionaryQuery{}
_ = controller.Unmarshal(listDictionaryQuery)
data, err := dictionaryService.ListDictionary(listDictionaryQuery)
controller.Response(data, err)
}