作者 郑周

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

... ... @@ -313,6 +313,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
// 删除周期
cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.Id})
... ... @@ -337,9 +338,14 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
if _, err := projectRepository.Remove(projects[i]); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 删除项目已生成的周期评估数据
if err := staffRepository.RemoveByProjectId(int(projects[i].Id)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
// 删除周期下的所有任务
// 删除周期下的所有定时任务
tasks, err := taskRepository.Find(map[string]interface{}{"cycleId": in.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -345,6 +345,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
if err != nil {
... ... @@ -354,8 +355,13 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 查看任务过程,移除项目关联的所有任务
tasks, err := taskRepository.Find(map[string]interface{}{"projectId": in.Id})
// 删除项目已生成的周期评估数据
if err := staffRepository.RemoveByProjectId(int(project.Id)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 移除项目关联的所有定时任务
tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...