作者 郑周

周期模板添加

@@ -11,7 +11,7 @@ type CreateCycleCommand struct { @@ -11,7 +11,7 @@ type CreateCycleCommand struct {
11 Name string `cname:"周期名称" json:"name" valid:"Required"` 11 Name string `cname:"周期名称" json:"name" valid:"Required"`
12 TimeStart *time.Time `cname:"起始时间" json:"timeStart"` 12 TimeStart *time.Time `cname:"起始时间" json:"timeStart"`
13 TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` 13 TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"`
14 - KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` 14 + KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"`
15 TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` 15 TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"`
16 } 16 }
17 17
@@ -62,6 +62,9 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf @@ -62,6 +62,9 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
62 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 62 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
63 } 63 }
64 64
  65 + ctAdapter := &adapter.CycleTemplateAdapter{}
  66 + ctAdapter.EvaluationCycle = cycle
  67 +
65 for i := range templates { 68 for i := range templates {
66 v := templates[i] 69 v := templates[i]
67 cycleTemplate := &domain.EvaluationCycleTemplate{ 70 cycleTemplate := &domain.EvaluationCycleTemplate{
@@ -74,12 +77,18 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf @@ -74,12 +77,18 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
74 if err != nil { 77 if err != nil {
75 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 78 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
76 } 79 }
  80 +
  81 + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
  82 + Id: v.Id,
  83 + Name: v.Name,
  84 + CreatedAt: v.CreatedAt,
  85 + })
77 } 86 }
78 87
79 if err := transactionContext.CommitTransaction(); err != nil { 88 if err := transactionContext.CommitTransaction(); err != nil {
80 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 89 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
81 } 90 }
82 - return cycle, nil 91 + return ctAdapter, nil
83 92
84 } 93 }
85 94
@@ -166,10 +175,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf @@ -166,10 +175,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
166 if err != nil { 175 if err != nil {
167 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 176 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
168 } 177 }
  178 +
  179 + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": cycle.Id}, "template")
  180 + if err != nil {
  181 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  182 + }
  183 +
  184 + ctAdapter := &adapter.CycleTemplateAdapter{}
  185 + ctAdapter.EvaluationCycle = cycle
  186 + for i := range cycleTemplates {
  187 + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
  188 + Id: cycleTemplates[i].Id,
  189 + Name: cycleTemplates[i].Name,
  190 + CreatedAt: cycleTemplates[i].CreatedAt,
  191 + })
  192 + }
  193 +
169 if err := transactionContext.CommitTransaction(); err != nil { 194 if err := transactionContext.CommitTransaction(); err != nil {
170 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 195 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
171 } 196 }
172 - return cycle, nil 197 + return ctAdapter, nil
173 } 198 }
174 199
175 func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { 200 func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) {
@@ -4,6 +4,16 @@ import ( @@ -4,6 +4,16 @@ import (
4 "time" 4 "time"
5 ) 5 )
6 6
  7 +const (
  8 + KpiCycleDay int = 1 // 考核周期-日
  9 + KpiCycleWeek int = 2 // 考核周期-周
  10 + KpiCycleOneMonth int = 3 // 考核周期-月
  11 + KpiCycleTwoMonth int = 4 // 考核周期-双月
  12 + KpiCycleThreeMonth int = 5 // 考核周期-季度
  13 + KpiCycleSixMonth int = 6 // 考核周期-半年
  14 + KpiCycleYear int = 7 // 考核周期-年
  15 +)
  16 +
7 type TemplateSimple struct { 17 type TemplateSimple struct {
8 Id int64 `json:"id,string" comment:"模板ID"` 18 Id int64 `json:"id,string" comment:"模板ID"`
9 Name string `json:"name" comment:"模板名称"` 19 Name string `json:"name" comment:"模板名称"`
@@ -17,7 +27,7 @@ type EvaluationCycle struct { @@ -17,7 +27,7 @@ type EvaluationCycle struct {
17 TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` 27 TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"`
18 CompanyId int64 `json:"companyId,string" comment:"公司ID"` 28 CompanyId int64 `json:"companyId,string" comment:"公司ID"`
19 CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` 29 CreatorId int64 `json:"creatorId,string" comment:"创建人ID"`
20 - KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` 30 + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"`
21 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 31 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
22 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` 32 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
23 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` 33 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
@@ -24,16 +24,6 @@ const ( @@ -24,16 +24,6 @@ const (
24 24
25 ) 25 )
26 26
27 -const (  
28 - KpiCycleDay int = 1 // 考核周期-日  
29 - KpiCycleWeek int = 2 // 考核周期-周  
30 - KpiCycleOneMonth int = 3 // 考核周期-月  
31 - KpiCycleTwoMonth int = 4 // 考核周期-双月  
32 - KpiCycleThreeMonth int = 5 // 考核周期-季度  
33 - KpiCycleSixMonth int = 6 // 考核周期-半年  
34 - KpiCycleYear int = 7 // 考核周期-年  
35 -)  
36 -  
37 type EntryItem struct { 27 type EntryItem struct {
38 Title string `json:"title" comment:"填写标题"` 28 Title string `json:"title" comment:"填写标题"`
39 HintText string `json:"hintText" comment:"文本内容提示"` 29 HintText string `json:"hintText" comment:"文本内容提示"`
  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 + ns := web.NewNamespace("/v1/evaluation-cycle",
  12 + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()),
  13 + web.NSRouter("/", &controllers.CycleController{}, "Post:CreateCycle"),
  14 + web.NSRouter("/", &controllers.CycleController{}, "Put:UpdateCycle"),
  15 + web.NSRouter("/", &controllers.CycleController{}, "Delete:RemoveCycle"),
  16 + web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"),
  17 + web.NSRouter("/list", &controllers.CycleController{}, "Post:ListRuleRelCreator"),
  18 + )
  19 + web.AddNamespace(ns)
  20 +}