org_controller.go 2.5 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/org/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/org/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/org/service"
)

type OrgController struct {
	beego.BaseController
}

func (controller *OrgController) CreateOrg() {
	orgService := service.NewOrgService(nil)
	createOrgCommand := &command.CreateOrgCommand{}
	controller.Unmarshal(createOrgCommand)
	data, err := orgService.CreateOrg(createOrgCommand)
	controller.Response(data, err)
}

func (controller *OrgController) UpdateOrg() {
	orgService := service.NewOrgService(nil)
	updateOrgCommand := &command.UpdateOrgCommand{}
	controller.Unmarshal(updateOrgCommand)
	orgId, _ := controller.GetInt64(":orgId")
	updateOrgCommand.OrgId = orgId
	data, err := orgService.UpdateOrg(updateOrgCommand)
	controller.Response(data, err)
}

func (controller *OrgController) GetOrg() {
	orgService := service.NewOrgService(nil)
	getOrgQuery := &query.GetOrgQuery{}
	orgId, _ := controller.GetInt64(":orgId")
	getOrgQuery.OrgId = orgId
	data, err := orgService.GetOrg(getOrgQuery)
	controller.Response(data, err)
}

func (controller *OrgController) RemoveOrg() {
	orgService := service.NewOrgService(nil)
	removeOrgCommand := &command.RemoveOrgCommand{}
	controller.Unmarshal(removeOrgCommand)
	orgId, _ := controller.GetInt64(":orgId")
	removeOrgCommand.OrgId = orgId
	data, err := orgService.RemoveOrg(removeOrgCommand)
	controller.Response(data, err)
}

func (controller *OrgController) ListOrg() {
	orgService := service.NewOrgService(nil)
	listOrgQuery := &query.ListOrgQuery{}
	data, err := orgService.ListOrg(listOrgQuery)
	controller.Response(data, err)
}

func (controller *OrgController) GetOrgSubDepartment() {
	orgService := service.NewOrgService(nil)
	getOrgSubDepartmentQuery := &query.GetOrgSubDepartmentQuery{}
	orgId, _ := controller.GetInt64(":orgId")
	getOrgSubDepartmentQuery.OrgId = orgId
	childFlag, _ := controller.GetInt("childFlag")
	getOrgSubDepartmentQuery.ChildFlag = childFlag
	data, err := orgService.GetOrgSubDepartment(getOrgSubDepartmentQuery)
	controller.Response(data, err)
}

func (controller *OrgController) EnableOrg() {
	orgService := service.NewOrgService(nil)
	enableOrgCommand := &command.EnableOrgCommand{}
	controller.Unmarshal(enableOrgCommand)
	data, err := orgService.EnableOrg(enableOrgCommand)
	controller.Response(data, err)
}