作者 tangxvhui

Merge branch 'master' into test

... ... @@ -959,3 +959,31 @@ outerLoop:
return map[string]interface{}{"indicatorTypeTask": indicatorTypeTask}, nil
}
// 修复数据用
func (rs *EvaluationProjectService) FixEvaluationItemUsed(id int) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": id})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = rs.generateEvaluationItemUsed(transactionContext, project)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil
}
... ...
... ... @@ -149,3 +149,14 @@ func (controller *ProjectController) CheckTaskTemplate() {
controller.Response(ruService.CheckTaskTemplate(in))
}
}
func (controller *ProjectController) FixEvaluationItemUsed() {
ruService := service.NewEvaluationProjectService()
id, err := controller.GetInt("project_id")
if err != nil {
controller.Response(nil, application.ThrowError(application.ARG_ERROR, "id err"))
}
err = ruService.FixEvaluationItemUsed(id)
controller.Response(nil, err)
}
... ...
... ... @@ -22,6 +22,8 @@ func init() {
web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"),
web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"),
web.NSRouter("/resume", &controllers.ProjectController{}, "Post:ResumeProject"),
web.NSCtrlGet("/fix/evaluation_item_used", (*controllers.ProjectController).FixEvaluationItemUsed),
)
web.AddNamespace(ns)
}
... ...