作者 郑周

1增加周期下的模板列表

2增加周期下的模板详情
@@ -9,6 +9,20 @@ type QueryCycleCommand struct { @@ -9,6 +9,20 @@ type QueryCycleCommand struct {
9 PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 9 PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
10 } 10 }
11 11
  12 +type StatisticCycleProjectUserCommand struct {
  13 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  14 + CycleId int64 `cname:"周期ID" json:"cycleId,string"`
  15 +}
  16 +
  17 +type CycleTemplateListCommand struct {
  18 + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  19 +}
  20 +
  21 +type CycleTemplateCommand struct {
  22 + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  23 + TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"`
  24 +}
  25 +
12 func (in *QueryCycleCommand) Valid(validation *validation.Validation) { 26 func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
13 if in.CompanyId == 0 { 27 if in.CompanyId == 0 {
14 validation.SetError("companyId", "公司ID无效") 28 validation.SetError("companyId", "公司ID无效")
@@ -16,17 +30,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { @@ -16,17 +30,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
16 } 30 }
17 } 31 }
18 32
19 -type StatisticCycleProjectUserCommand struct {  
20 - CompanyId int64 `cname:"公司ID" json:"companyId"`  
21 - CycleId int64 `cname:"周期ID" json:"cycleId,string"`  
22 -}  
23 -  
24 func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { 33 func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) {
25 34
26 } 35 }
27 36
28 -type CycleTemplateCommand struct {  
29 - CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` 37 +func (in *CycleTemplateListCommand) Valid(*validation.Validation) {
  38 +
30 } 39 }
31 40
32 func (in *CycleTemplateCommand) Valid(*validation.Validation) { 41 func (in *CycleTemplateCommand) Valid(*validation.Validation) {
@@ -364,7 +364,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP @@ -364,7 +364,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
364 return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil 364 return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil
365 } 365 }
366 366
367 -func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCommand) (interface{}, error) { 367 +func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateListCommand) (interface{}, error) {
368 transactionContext, err := factory.ValidateStartTransaction(in) 368 transactionContext, err := factory.ValidateStartTransaction(in)
369 if err != nil { 369 if err != nil {
370 return nil, err 370 return nil, err
@@ -375,6 +375,9 @@ func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCom @@ -375,6 +375,9 @@ func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCom
375 375
376 cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) 376 cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
377 _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": in.CycleId}, "template") 377 _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": in.CycleId}, "template")
  378 + if err != nil {
  379 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  380 + }
378 381
379 list := make([]*domain.TemplateSimple, 0) 382 list := make([]*domain.TemplateSimple, 0)
380 for i := range cycleTemplates { 383 for i := range cycleTemplates {
@@ -390,3 +393,23 @@ func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCom @@ -390,3 +393,23 @@ func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCom
390 } 393 }
391 return map[string]interface{}{"list": list}, nil 394 return map[string]interface{}{"list": list}, nil
392 } 395 }
  396 +
  397 +func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand) (interface{}, error) {
  398 + transactionContext, err := factory.ValidateStartTransaction(in)
  399 + if err != nil {
  400 + return nil, err
  401 + }
  402 + defer func() {
  403 + transactionContext.RollbackTransaction()
  404 + }()
  405 +
  406 + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
  407 + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId})
  408 + if err != nil {
  409 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  410 + }
  411 + if err := transactionContext.CommitTransaction(); err != nil {
  412 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  413 + }
  414 + return cycleTemplate.Template, nil
  415 +}
@@ -90,10 +90,20 @@ func (controller *CycleController) StatisticCycleUser() { @@ -90,10 +90,20 @@ func (controller *CycleController) StatisticCycleUser() {
90 90
91 func (controller *CycleController) CycleTemplateList() { 91 func (controller *CycleController) CycleTemplateList() {
92 ruService := service.NewEvaluationCycleService() 92 ruService := service.NewEvaluationCycleService()
93 - in := &command.CycleTemplateCommand{} 93 + in := &command.CycleTemplateListCommand{}
94 if err := controller.Unmarshal(in); err != nil { 94 if err := controller.Unmarshal(in); err != nil {
95 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) 95 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
96 } else { 96 } else {
97 controller.Response(ruService.CycleTemplateList(in)) 97 controller.Response(ruService.CycleTemplateList(in))
98 } 98 }
99 } 99 }
  100 +
  101 +func (controller *CycleController) CycleTemplate() {
  102 + ruService := service.NewEvaluationCycleService()
  103 + in := &command.CycleTemplateCommand{}
  104 + if err := controller.Unmarshal(in); err != nil {
  105 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  106 + } else {
  107 + controller.Response(ruService.CycleTemplate(in))
  108 + }
  109 +}