orgs_controller.go 2.3 KB
package web_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/service"
)

type OrgsController struct {
	baseController
}

func (controller *OrgsController) OrgAdd() {
	orgsService := service.NewOrgsService(nil)
	orgAddCommand := &command.OrgAddCommand{}
	controller.Unmarshal(orgAddCommand)
	orgAddCommand.Operator = controller.GetOperator()
	data, err := orgsService.OrgAdd(orgAddCommand)
	controller.Response(data, err)
}

func (controller *OrgsController) OrgUpdate() {
	orgsService := service.NewOrgsService(nil)
	orgUpdateCommand := &command.OrgUpdateCommand{}
	controller.Unmarshal(orgUpdateCommand)
	orgId := controller.GetString(":orgId")
	orgUpdateCommand.OrgId = orgId
	orgUpdateCommand.Operator = controller.GetOperator()
	data, err := orgsService.OrgUpdate(orgUpdateCommand)
	controller.Response(data, err)
}

func (controller *OrgsController) OrgList() {
	orgsService := service.NewOrgsService(nil)
	orgListQuery := &query.OrgListQuery{}
	controller.Unmarshal(orgListQuery)
	orgListQuery.Operator = controller.GetOperator()
	data, err := orgsService.OrgList(orgListQuery)
	controller.Response(data, err)
}

func (controller *OrgsController) OrgGet() {
	orgsService := service.NewOrgsService(nil)
	orgGetQuery := &query.OrgGetQuery{}
	orgId := controller.GetString(":orgId")
	orgGetQuery.OrgId = orgId
	orgGetQuery.Operator = controller.GetOperator()
	data, err := orgsService.OrgGet(orgGetQuery)
	controller.Response(data, err)
}

func (controller *OrgsController) OrgEnable() {
	orgsService := service.NewOrgsService(nil)
	orgEnableCommand := &command.OrgEnableCommand{}
	controller.Unmarshal(orgEnableCommand)
	orgEnableCommand.Operator = controller.GetOperator()
	data, err := orgsService.OrgEnable(orgEnableCommand)
	controller.Response(data, err)
}

func (controller *OrgsController) OrgGetSubDepartment() {
	orgsService := service.NewOrgsService(nil)
	orgGetSubDepartmentQuery := &query.OrgGetSubDepartmentQuery{}
	controller.Unmarshal(orgGetSubDepartmentQuery)
	orgGetSubDepartmentQuery.Operator = controller.GetOperator()
	data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery)
	controller.Response(data, err)
}