作者 郑周

1. 删除周期和项目时, 想关联的已生成的周期项目任务 一并删除

@@ -313,6 +313,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf @@ -313,6 +313,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
313 cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) 313 cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
314 projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) 314 projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
315 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) 315 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
  316 + staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
316 317
317 // 删除周期 318 // 删除周期
318 cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.Id}) 319 cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.Id})
@@ -337,9 +338,14 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf @@ -337,9 +338,14 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
337 if _, err := projectRepository.Remove(projects[i]); err != nil { 338 if _, err := projectRepository.Remove(projects[i]); err != nil {
338 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 339 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
339 } 340 }
  341 +
  342 + // 删除项目已生成的周期评估数据
  343 + if err := staffRepository.RemoveByProjectId(int(projects[i].Id)); err != nil {
  344 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  345 + }
340 } 346 }
341 347
342 - // 删除周期下的所有任务 348 + // 删除周期下的所有定时任务
343 tasks, err := taskRepository.Find(map[string]interface{}{"cycleId": in.Id}) 349 tasks, err := taskRepository.Find(map[string]interface{}{"cycleId": in.Id})
344 if err != nil { 350 if err != nil {
345 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 351 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -345,6 +345,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in @@ -345,6 +345,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
345 345
346 projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) 346 projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
347 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) 347 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
  348 + staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
348 349
349 project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) 350 project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
350 if err != nil { 351 if err != nil {
@@ -354,8 +355,13 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in @@ -354,8 +355,13 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
354 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 355 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
355 } 356 }
356 357
357 - // 查看任务过程,移除项目关联的所有任务  
358 - tasks, err := taskRepository.Find(map[string]interface{}{"projectId": in.Id}) 358 + // 删除项目已生成的周期评估数据
  359 + if err := staffRepository.RemoveByProjectId(int(project.Id)); err != nil {
  360 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  361 + }
  362 +
  363 + // 移除项目关联的所有定时任务
  364 + tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id})
359 if err != nil { 365 if err != nil {
360 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 366 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
361 } 367 }