作者 tangxvhui

Merge branch '1.2.4'

@@ -878,3 +878,31 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex @@ -878,3 +878,31 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex
878 } 878 }
879 return nil 879 return nil
880 } 880 }
  881 +
  882 +// 修复数据用
  883 +func (rs *EvaluationProjectService) FixEvaluationItemUsed(id int) error {
  884 +
  885 + transactionContext, err := factory.CreateTransactionContext(nil)
  886 + if err != nil {
  887 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  888 + }
  889 + if err := transactionContext.StartTransaction(); err != nil {
  890 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  891 + }
  892 + defer func() {
  893 + _ = transactionContext.RollbackTransaction()
  894 + }()
  895 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  896 + project, err := projectRepository.FindOne(map[string]interface{}{"id": id})
  897 + if err != nil {
  898 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  899 + }
  900 + err = rs.generateEvaluationItemUsed(transactionContext, project)
  901 + if err != nil {
  902 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  903 + }
  904 + if err := transactionContext.CommitTransaction(); err != nil {
  905 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  906 + }
  907 + return nil
  908 +}
@@ -139,3 +139,14 @@ func (controller *ProjectController) CheckRecipients() { @@ -139,3 +139,14 @@ func (controller *ProjectController) CheckRecipients() {
139 controller.Response(ruService.CheckRecipients(in)) 139 controller.Response(ruService.CheckRecipients(in))
140 } 140 }
141 } 141 }
  142 +
  143 +func (controller *ProjectController) FixEvaluationItemUsed() {
  144 + ruService := service.NewEvaluationProjectService()
  145 + id, err := controller.GetInt("project_id")
  146 + if err != nil {
  147 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, "id err"))
  148 + }
  149 + err = ruService.FixEvaluationItemUsed(id)
  150 + controller.Response(nil, err)
  151 +
  152 +}
@@ -21,6 +21,8 @@ func init() { @@ -21,6 +21,8 @@ func init() {
21 web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"), 21 web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"),
22 web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"), 22 web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"),
23 web.NSRouter("/resume", &controllers.ProjectController{}, "Post:ResumeProject"), 23 web.NSRouter("/resume", &controllers.ProjectController{}, "Post:ResumeProject"),
  24 + web.NSCtrlGet("/fix/evaluation_item_used", (*controllers.ProjectController).FixEvaluationItemUsed),
24 ) 25 )
  26 +
25 web.AddNamespace(ns) 27 web.AddNamespace(ns)
26 } 28 }