正在显示
8 个修改的文件
包含
56 行增加
和
4 行删除
| @@ -24,3 +24,11 @@ type StatisticCycleProjectUserCommand struct { | @@ -24,3 +24,11 @@ type StatisticCycleProjectUserCommand struct { | ||
| 24 | func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | 24 | func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { |
| 25 | 25 | ||
| 26 | } | 26 | } |
| 27 | + | ||
| 28 | +type CycleTemplateCommand struct { | ||
| 29 | + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +func (in *CycleTemplateCommand) Valid(*validation.Validation) { | ||
| 33 | + | ||
| 34 | +} |
| @@ -102,6 +102,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -102,6 +102,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 102 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 102 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 103 | Id: 0, | 103 | Id: 0, |
| 104 | Name: v.Name, | 104 | Name: v.Name, |
| 105 | + TemplateCreatedAt: v.CreatedAt, | ||
| 105 | Template: v, | 106 | Template: v, |
| 106 | CycleId: cycle.Id, | 107 | CycleId: cycle.Id, |
| 107 | } | 108 | } |
| @@ -114,7 +115,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -114,7 +115,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 114 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | 115 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ |
| 115 | Id: cycleTemplate.Id, | 116 | Id: cycleTemplate.Id, |
| 116 | Name: cycleTemplate.Name, | 117 | Name: cycleTemplate.Name, |
| 117 | - CreatedAt: cycleTemplate.CreatedAt, | 118 | + CreatedAt: cycleTemplate.TemplateCreatedAt, // 模板创建时间 |
| 118 | }) | 119 | }) |
| 119 | } | 120 | } |
| 120 | 121 | ||
| @@ -190,6 +191,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -190,6 +191,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 190 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 191 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 191 | Id: 0, | 192 | Id: 0, |
| 192 | Name: v.Name, | 193 | Name: v.Name, |
| 194 | + TemplateCreatedAt: v.CreatedAt, | ||
| 193 | Template: v, | 195 | Template: v, |
| 194 | CycleId: cycle.Id, | 196 | CycleId: cycle.Id, |
| 195 | } | 197 | } |
| @@ -220,7 +222,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -220,7 +222,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 220 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | 222 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ |
| 221 | Id: cycleTemplates[i].Id, | 223 | Id: cycleTemplates[i].Id, |
| 222 | Name: cycleTemplates[i].Name, | 224 | Name: cycleTemplates[i].Name, |
| 223 | - CreatedAt: cycleTemplates[i].CreatedAt, | 225 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, |
| 224 | }) | 226 | }) |
| 225 | } | 227 | } |
| 226 | 228 | ||
| @@ -257,7 +259,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, | @@ -257,7 +259,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, | ||
| 257 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | 259 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ |
| 258 | Id: cycleTemplates[i].Id, | 260 | Id: cycleTemplates[i].Id, |
| 259 | Name: cycleTemplates[i].Name, | 261 | Name: cycleTemplates[i].Name, |
| 260 | - CreatedAt: cycleTemplates[i].CreatedAt, | 262 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, |
| 261 | }) | 263 | }) |
| 262 | } | 264 | } |
| 263 | 265 | ||
| @@ -361,3 +363,30 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | @@ -361,3 +363,30 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | ||
| 361 | } | 363 | } |
| 362 | return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | 364 | return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil |
| 363 | } | 365 | } |
| 366 | + | ||
| 367 | +func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCommand) (interface{}, error) { | ||
| 368 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 369 | + if err != nil { | ||
| 370 | + return nil, err | ||
| 371 | + } | ||
| 372 | + defer func() { | ||
| 373 | + transactionContext.RollbackTransaction() | ||
| 374 | + }() | ||
| 375 | + | ||
| 376 | + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 377 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": in.CycleId}, "template") | ||
| 378 | + | ||
| 379 | + list := make([]*domain.TemplateSimple, 0) | ||
| 380 | + for i := range cycleTemplates { | ||
| 381 | + list = append(list, &domain.TemplateSimple{ | ||
| 382 | + Id: cycleTemplates[i].Id, | ||
| 383 | + Name: cycleTemplates[i].Name, | ||
| 384 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, | ||
| 385 | + }) | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 389 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 390 | + } | ||
| 391 | + return map[string]interface{}{"list": list}, nil | ||
| 392 | +} |
| @@ -17,7 +17,7 @@ const ( | @@ -17,7 +17,7 @@ const ( | ||
| 17 | type TemplateSimple struct { | 17 | type TemplateSimple struct { |
| 18 | Id int64 `json:"id,string" comment:"模板ID"` | 18 | Id int64 `json:"id,string" comment:"模板ID"` |
| 19 | Name string `json:"name" comment:"模板名称"` | 19 | Name string `json:"name" comment:"模板名称"` |
| 20 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 20 | + CreatedAt time.Time `json:"createdAt" comment:"模板创建时间"` |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | type EvaluationCycle struct { | 23 | type EvaluationCycle struct { |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | type EvaluationCycleTemplate struct { | 7 | type EvaluationCycleTemplate struct { |
| 8 | Id int64 `json:"id,string" comment:"模板ID"` | 8 | Id int64 `json:"id,string" comment:"模板ID"` |
| 9 | Name string `json:"name" comment:"模板名称"` | 9 | Name string `json:"name" comment:"模板名称"` |
| 10 | + TemplateCreatedAt time.Time `json:"templateCreatedAt" comment:"模板创建时间"` | ||
| 10 | Template *EvaluationTemplate `json:"template" comment:"模板数据"` | 11 | Template *EvaluationTemplate `json:"template" comment:"模板数据"` |
| 11 | CycleId int64 `json:"cycleId,string" comment:"周期ID"` | 12 | CycleId int64 `json:"cycleId,string" comment:"周期ID"` |
| 12 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 13 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
| @@ -9,6 +9,7 @@ type EvaluationCycleTemplate struct { | @@ -9,6 +9,7 @@ type EvaluationCycleTemplate struct { | ||
| 9 | tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` | 9 | tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` |
| 10 | Id int64 `comment:"模板ID" pg:"pk:id"` | 10 | Id int64 `comment:"模板ID" pg:"pk:id"` |
| 11 | Name string `comment:"模板名称"` | 11 | Name string `comment:"模板名称"` |
| 12 | + TemplateCreatedAt time.Time `comment:"模板创建时间"` | ||
| 12 | Template *domain.EvaluationTemplate `comment:"模板数据"` | 13 | Template *domain.EvaluationTemplate `comment:"模板数据"` |
| 13 | CycleId int64 `comment:"周期ID"` | 14 | CycleId int64 `comment:"周期ID"` |
| 14 | CreatedAt time.Time `comment:"创建时间"` | 15 | CreatedAt time.Time `comment:"创建时间"` |
| @@ -24,6 +24,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.Evalu | @@ -24,6 +24,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.Evalu | ||
| 24 | return domain.EvaluationCycleTemplate{ | 24 | return domain.EvaluationCycleTemplate{ |
| 25 | Id: m.Id, | 25 | Id: m.Id, |
| 26 | Name: m.Name, | 26 | Name: m.Name, |
| 27 | + TemplateCreatedAt: m.TemplateCreatedAt, | ||
| 27 | Template: m.Template, | 28 | Template: m.Template, |
| 28 | CycleId: m.CycleId, | 29 | CycleId: m.CycleId, |
| 29 | CreatedAt: m.CreatedAt, | 30 | CreatedAt: m.CreatedAt, |
| @@ -36,6 +37,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.Evalua | @@ -36,6 +37,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.Evalua | ||
| 36 | return models.EvaluationCycleTemplate{ | 37 | return models.EvaluationCycleTemplate{ |
| 37 | Id: d.Id, | 38 | Id: d.Id, |
| 38 | Name: d.Name, | 39 | Name: d.Name, |
| 40 | + TemplateCreatedAt: d.TemplateCreatedAt, | ||
| 39 | Template: d.Template, | 41 | Template: d.Template, |
| 40 | CycleId: d.CycleId, | 42 | CycleId: d.CycleId, |
| 41 | CreatedAt: d.CreatedAt, | 43 | CreatedAt: d.CreatedAt, |
| @@ -87,3 +87,13 @@ func (controller *CycleController) StatisticCycleUser() { | @@ -87,3 +87,13 @@ func (controller *CycleController) StatisticCycleUser() { | ||
| 87 | controller.Response(ruService.StatisticCycleUser(in)) | 87 | controller.Response(ruService.StatisticCycleUser(in)) |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | + | ||
| 91 | +func (controller *CycleController) CycleTemplateList() { | ||
| 92 | + ruService := service.NewEvaluationCycleService() | ||
| 93 | + in := &command.CycleTemplateCommand{} | ||
| 94 | + if err := controller.Unmarshal(in); err != nil { | ||
| 95 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 96 | + } else { | ||
| 97 | + controller.Response(ruService.CycleTemplateList(in)) | ||
| 98 | + } | ||
| 99 | +} |
| @@ -16,6 +16,7 @@ func init() { | @@ -16,6 +16,7 @@ func init() { | ||
| 16 | web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"), | 16 | web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"), |
| 17 | web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), | 17 | web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), |
| 18 | web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), | 18 | web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), |
| 19 | + web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"), | ||
| 19 | ) | 20 | ) |
| 20 | web.AddNamespace(ns) | 21 | web.AddNamespace(ns) |
| 21 | } | 22 | } |
-
请 注册 或 登录 后发表评论