summary_evaluation_controller.go 9.3 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.QueryEvaluation{}
	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.GetEvaluationSelfByCycle(paramReq)
	c.Response(data, err)

}

// EditEvaluationSelf 编辑综合自评
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)

}

// GetTargetUserCycleList 根据被评估人获取周期列表
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)
}

// CountEvaluationSelfLevel 获取自评小结
func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryEvaluation{}
	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)
	paramReq.CompanyId = int(userReq.CompanyId)
	data, err := srv.CountEvaluationSelfLevel(paramReq)
	c.Response(data, err)

}

func (c *SummaryEvaluationController) Evaluation360List() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluation360List{}
	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.UserId = int(userReq.UserId)
	data, err := srv.Evaluation360List(in)
	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.CompanyId = int(userReq.CompanyId)
	in.UserId = int(userReq.UserId)
	data, err := srv.GetEvaluation360(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluation360All() {
	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.CompanyId = int(userReq.CompanyId)
	in.UserId = int(userReq.UserId)
	data, err := srv.GetEvaluation360All(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) EvaluationHRBPList() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluationHRList{}
	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.UserId = int(userReq.UserId)
	data, err := srv.EvaluationHRBPList(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)
	in.CompanyId = int(userReq.CompanyId)
	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)
}

// 获取上级评估
func (c *SummaryEvaluationController) GetEvaluationSuper() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryEvaluationSuper{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetEvaluationSuper(param)
	c.Response(data, err)
}

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

// 上级评估列表
func (c *SummaryEvaluationController) ListEvaluationSuper() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryEvaluationList{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	param.ExecutorId = int(userReq.UserId)
	data, err := srv.ListEvaluationSuper(param)
	c.Response(data, err)
}

// 员工确认评估分数
func (c *SummaryEvaluationController) ConfirmScoreSuperEvaluation() {
	srv := service.NewSummaryEvaluationService()
	param := &command.ConfirmScore{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.UserId = int(userReq.UserId)
	err = srv.ConfirmScoreSuperEvaluation(param)
	c.Response(nil, err)
}

// GetTargetUserEvaluationSuper 根据被评估人和周期获取 上级评估
func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryEvaluation{}
	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.GetTargetUserEvaluationSuper(paramReq)
	c.Response(data, err)
}