作者 tangxvhui

添加路由

@@ -16,7 +16,7 @@ import ( @@ -16,7 +16,7 @@ import (
16 type SummaryEvaluationServeice struct { 16 type SummaryEvaluationServeice struct {
17 } 17 }
18 18
19 -func NewStaffAssessServeice() *SummaryEvaluationServeice { 19 +func NewSummaryEvaluationServeice() *SummaryEvaluationServeice {
20 newService := &SummaryEvaluationServeice{} 20 newService := &SummaryEvaluationServeice{}
21 return newService 21 return newService
22 } 22 }
@@ -411,7 +411,6 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval @@ -411,7 +411,6 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval
411 mValue.Id = v.Id 411 mValue.Id = v.Id
412 } 412 }
413 } 413 }
414 -  
415 nowTime := time.Now() 414 nowTime := time.Now()
416 for _, v := range param.EvaluationItems { 415 for _, v := range param.EvaluationItems {
417 updatedData, ok := evaluationValueMap[v.EvaluationItemId] 416 updatedData, ok := evaluationValueMap[v.EvaluationItemId]
@@ -437,3 +436,5 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval @@ -437,3 +436,5 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval
437 "EvaluationItems": itemValueAdapter, 436 "EvaluationItems": itemValueAdapter,
438 }, nil 437 }, nil
439 } 438 }
  439 +
  440 +//
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/service"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  9 +)
  10 +
  11 +type SummaryEvaluationController struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +func (c *SummaryEvaluationController) GetCycleList() {
  16 + srv := service.NewSummaryEvaluationServeice()
  17 + paramReq := &command.QueryCycleList{}
  18 + err := c.BindJSON(paramReq)
  19 + if err != nil {
  20 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  21 + c.Response(nil, e)
  22 + return
  23 + }
  24 + userReq := middlewares.GetUser(c.Ctx)
  25 +
  26 + paramReq.UserId = int(userReq.UserId)
  27 + data, err := srv.GetCycleList(paramReq)
  28 + c.Response(data, err)
  29 +}
  30 +
  31 +func (c *SummaryEvaluationController) GetMenu() {
  32 + srv := service.NewSummaryEvaluationServeice()
  33 + paramReq := &command.QueryMenu{}
  34 + err := c.BindJSON(paramReq)
  35 + if err != nil {
  36 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  37 + c.Response(nil, e)
  38 + return
  39 + }
  40 + userReq := middlewares.GetUser(c.Ctx)
  41 + paramReq.CompanyId = int(userReq.CompanyId)
  42 + paramReq.UserId = int(userReq.UserId)
  43 + data, err := srv.GetMenu(paramReq)
  44 + c.Response(data, err)
  45 +
  46 +}
  47 +
  48 +func (c *SummaryEvaluationController) GetEvaluationSelf() {
  49 + srv := service.NewSummaryEvaluationServeice()
  50 + paramReq := &command.QueryEvaluationInfo{}
  51 + err := c.BindJSON(paramReq)
  52 + if err != nil {
  53 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  54 + c.Response(nil, e)
  55 + return
  56 + }
  57 + userReq := middlewares.GetUser(c.Ctx)
  58 + paramReq.CompanyId = int(userReq.CompanyId)
  59 + paramReq.ExecutorId = int(userReq.UserId)
  60 + data, err := srv.GetEvaluationSelf(paramReq)
  61 + c.Response(data, err)
  62 +
  63 +}
  64 +
  65 +func (c *SummaryEvaluationController) EditEvaluationSelf() {
  66 + srv := service.NewSummaryEvaluationServeice()
  67 + paramReq := &command.EditEvaluationValue{}
  68 + err := c.BindJSON(paramReq)
  69 + if err != nil {
  70 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  71 + c.Response(nil, e)
  72 + return
  73 + }
  74 + userReq := middlewares.GetUser(c.Ctx)
  75 + paramReq.CompanyId = int(userReq.CompanyId)
  76 + paramReq.ExecutorId = int(userReq.UserId)
  77 + data, err := srv.EditEvaluationSelf(paramReq)
  78 + c.Response(data, err)
  79 +
  80 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "github.com/linmadan/egglib-go/web/beego/filters"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  8 +)
  9 +
  10 +func init() {
  11 + summaryNS := web.NewNamespace("/v1/summary-evaluation",
  12 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  13 + web.NSCtrlPost("/cycle/list", (*controllers.SummaryEvaluationController).GetCycleList),
  14 + web.NSCtrlPost("/cycle/menu", (*controllers.SummaryEvaluationController).GetMenu),
  15 + web.NSCtrlPost("/self", (*controllers.SummaryEvaluationController).GetEvaluationSelf),
  16 + web.NSCtrlPost("/self/edit", (*controllers.SummaryEvaluationController).EditEvaluationSelf),
  17 + )
  18 + web.AddNamespace(summaryNS)
  19 +}