summary_evaluation_controller.go 4.7 KB
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/summary_evaluation/command"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/service"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)

type SummaryEvaluationController struct {
	beego.BaseController
}

func (c *SummaryEvaluationController) GetExecutorCycleList() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryCycleList{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.UserId = int(userReq.UserId)
	data, err := srv.GetExecutorCycleList(paramReq)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetMenu() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryMenu{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	paramReq.UserId = int(userReq.UserId)
	data, err := srv.GetMenu(paramReq)
	c.Response(data, err)

}

func (c *SummaryEvaluationController) GetEvaluationSelf() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryEvaluationInfo{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	paramReq.ExecutorId = int(userReq.UserId)
	data, err := srv.GetEvaluationSelf(paramReq)
	c.Response(data, err)

}

func (c *SummaryEvaluationController) EditEvaluationSelf() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.EditEvaluationValue{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	paramReq.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluationSelf(paramReq)
	c.Response(data, err)

}

func (c *SummaryEvaluationController) GetTargetUserCycleList() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryCycleList{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.UserId = int(userReq.UserId)
	data, err := srv.GetTargetUserCycleList(paramReq)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluation360() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluation360{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.UserId = int(userReq.UserId)
	data, err := srv.GetEvaluation360(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) EditEvaluation360() {
	srv := service.NewSummaryEvaluationService()
	in := &command.EditEvaluationValue{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluation360(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluationHRBP() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluationHRBP{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.UserId = int(userReq.UserId)
	data, err := srv.GetEvaluationHRBP(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) EditEvaluationHRBP() {
	srv := service.NewSummaryEvaluationService()
	in := &command.EditEvaluationValue{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluationHRBP(in)
	c.Response(data, err)
}