作者 tangxvhui

Merge branch '1.2.4'

... ... @@ -878,3 +878,31 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex
}
return 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
}
... ...
... ... @@ -139,3 +139,14 @@ func (controller *ProjectController) CheckRecipients() {
controller.Response(ruService.CheckRecipients(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)
}
... ...
... ... @@ -21,6 +21,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)
}
... ...