审查视图

pkg/port/beego/controllers/department_controller.go 858 字节
郑周 authored
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
package controllers

import (
	"github.com/linmadan/egglib-go/core/application"
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/department"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/department/command"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)

type DepartmentController struct {
	beego.BaseController
}

func (controller *DepartmentController) ListAndCount() {
	dService := department.NewDepartmentService()

	in := &command.QueryDepartmentCommand{}
	if err := controller.Unmarshal(in); err != nil {
		controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
	} else {
		ua := middlewares.GetUser(controller.Ctx)
		in.CompanyId = ua.CompanyId
		controller.Response(dService.ListAndCount(in))
	}
}