dictionary_controller.go 1.9 KB
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)
}