正在显示
8 个修改的文件
包含
93 行增加
和
41 行删除
| @@ -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 | +} |
| @@ -100,10 +100,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -100,10 +100,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 100 | 100 | ||
| 101 | // 周期模板数据表中插入数据 | 101 | // 周期模板数据表中插入数据 |
| 102 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 102 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 103 | - Id: 0, | ||
| 104 | - Name: v.Name, | ||
| 105 | - Template: v, | ||
| 106 | - CycleId: cycle.Id, | 103 | + Id: 0, |
| 104 | + Name: v.Name, | ||
| 105 | + TemplateCreatedAt: v.CreatedAt, | ||
| 106 | + Template: v, | ||
| 107 | + CycleId: cycle.Id, | ||
| 107 | } | 108 | } |
| 108 | _, err := cycleTemplateRepository.Insert(cycleTemplate) | 109 | _, err := cycleTemplateRepository.Insert(cycleTemplate) |
| 109 | if err != nil { | 110 | if err != nil { |
| @@ -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 | ||
| @@ -188,10 +189,11 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -188,10 +189,11 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 188 | for i := range templates { | 189 | for i := range templates { |
| 189 | v := templates[i] | 190 | v := templates[i] |
| 190 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 191 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 191 | - Id: 0, | ||
| 192 | - Name: v.Name, | ||
| 193 | - Template: v, | ||
| 194 | - CycleId: cycle.Id, | 192 | + Id: 0, |
| 193 | + Name: v.Name, | ||
| 194 | + TemplateCreatedAt: v.CreatedAt, | ||
| 195 | + Template: v, | ||
| 196 | + CycleId: cycle.Id, | ||
| 195 | } | 197 | } |
| 196 | _, err := cycleTemplateRepository.Insert(cycleTemplate) | 198 | _, err := cycleTemplateRepository.Insert(cycleTemplate) |
| 197 | if err != nil { | 199 | if err != nil { |
| @@ -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 { |
| @@ -5,13 +5,14 @@ import ( | @@ -5,13 +5,14 @@ import ( | ||
| 5 | ) | 5 | ) |
| 6 | 6 | ||
| 7 | type EvaluationCycleTemplate struct { | 7 | type EvaluationCycleTemplate struct { |
| 8 | - Id int64 `json:"id,string" comment:"模板ID"` | ||
| 9 | - Name string `json:"name" comment:"模板名称"` | ||
| 10 | - Template *EvaluationTemplate `json:"template" comment:"模板数据"` | ||
| 11 | - CycleId int64 `json:"cycleId,string" comment:"周期ID"` | ||
| 12 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
| 13 | - UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
| 14 | - DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 8 | + Id int64 `json:"id,string" comment:"模板ID"` |
| 9 | + Name string `json:"name" comment:"模板名称"` | ||
| 10 | + TemplateCreatedAt time.Time `json:"templateCreatedAt" comment:"模板创建时间"` | ||
| 11 | + Template *EvaluationTemplate `json:"template" comment:"模板数据"` | ||
| 12 | + CycleId int64 `json:"cycleId,string" comment:"周期ID"` | ||
| 13 | + CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
| 14 | + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
| 15 | + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | type EvaluationCycleTemplateRepository interface { | 18 | type EvaluationCycleTemplateRepository interface { |
| @@ -6,12 +6,13 @@ import ( | @@ -6,12 +6,13 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type EvaluationCycleTemplate struct { | 8 | type EvaluationCycleTemplate struct { |
| 9 | - tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` | ||
| 10 | - Id int64 `comment:"模板ID" pg:"pk:id"` | ||
| 11 | - Name string `comment:"模板名称"` | ||
| 12 | - Template *domain.EvaluationTemplate `comment:"模板数据"` | ||
| 13 | - CycleId int64 `comment:"周期ID"` | ||
| 14 | - CreatedAt time.Time `comment:"创建时间"` | ||
| 15 | - UpdatedAt time.Time `comment:"更新时间"` | ||
| 16 | - DeletedAt *time.Time `comment:"删除时间"` | 9 | + tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` |
| 10 | + Id int64 `comment:"模板ID" pg:"pk:id"` | ||
| 11 | + Name string `comment:"模板名称"` | ||
| 12 | + TemplateCreatedAt time.Time `comment:"模板创建时间"` | ||
| 13 | + Template *domain.EvaluationTemplate `comment:"模板数据"` | ||
| 14 | + CycleId int64 `comment:"周期ID"` | ||
| 15 | + CreatedAt time.Time `comment:"创建时间"` | ||
| 16 | + UpdatedAt time.Time `comment:"更新时间"` | ||
| 17 | + DeletedAt *time.Time `comment:"删除时间"` | ||
| 17 | } | 18 | } |
| @@ -22,25 +22,27 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran | @@ -22,25 +22,27 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran | ||
| 22 | 22 | ||
| 23 | func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate { | 23 | func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate { |
| 24 | return domain.EvaluationCycleTemplate{ | 24 | return domain.EvaluationCycleTemplate{ |
| 25 | - Id: m.Id, | ||
| 26 | - Name: m.Name, | ||
| 27 | - Template: m.Template, | ||
| 28 | - CycleId: m.CycleId, | ||
| 29 | - CreatedAt: m.CreatedAt, | ||
| 30 | - UpdatedAt: m.UpdatedAt, | ||
| 31 | - DeletedAt: m.DeletedAt, | 25 | + Id: m.Id, |
| 26 | + Name: m.Name, | ||
| 27 | + TemplateCreatedAt: m.TemplateCreatedAt, | ||
| 28 | + Template: m.Template, | ||
| 29 | + CycleId: m.CycleId, | ||
| 30 | + CreatedAt: m.CreatedAt, | ||
| 31 | + UpdatedAt: m.UpdatedAt, | ||
| 32 | + DeletedAt: m.DeletedAt, | ||
| 32 | } | 33 | } |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.EvaluationCycleTemplate) models.EvaluationCycleTemplate { | 36 | func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.EvaluationCycleTemplate) models.EvaluationCycleTemplate { |
| 36 | return models.EvaluationCycleTemplate{ | 37 | return models.EvaluationCycleTemplate{ |
| 37 | - Id: d.Id, | ||
| 38 | - Name: d.Name, | ||
| 39 | - Template: d.Template, | ||
| 40 | - CycleId: d.CycleId, | ||
| 41 | - CreatedAt: d.CreatedAt, | ||
| 42 | - UpdatedAt: d.UpdatedAt, | ||
| 43 | - DeletedAt: d.DeletedAt, | 38 | + Id: d.Id, |
| 39 | + Name: d.Name, | ||
| 40 | + TemplateCreatedAt: d.TemplateCreatedAt, | ||
| 41 | + Template: d.Template, | ||
| 42 | + CycleId: d.CycleId, | ||
| 43 | + CreatedAt: d.CreatedAt, | ||
| 44 | + UpdatedAt: d.UpdatedAt, | ||
| 45 | + DeletedAt: d.DeletedAt, | ||
| 44 | } | 46 | } |
| 45 | } | 47 | } |
| 46 | 48 |
| @@ -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 | } |
-
请 注册 或 登录 后发表评论