作者 郑周

1. 修复 任务操作日志

@@ -205,7 +205,7 @@ func compareStage(u *domain.UserAuth, id int, srcStage []*domain.TaskStage, newS @@ -205,7 +205,7 @@ func compareStage(u *domain.UserAuth, id int, srcStage []*domain.TaskStage, newS
205 } 205 }
206 if it.PlanCompletedAt != v.PlanCompletedAt { 206 if it.PlanCompletedAt != v.PlanCompletedAt {
207 logOpt := createdLogOpt(u, taskId) 207 logOpt := createdLogOpt(u, taskId)
208 - logOpt.OptField = "修改了里程碑" + it.Name + "计划完成时间" 208 + logOpt.OptField = "修改了里程碑" + it.Name + "计划完成时间"
209 if it.PlanCompletedAt == 0 { 209 if it.PlanCompletedAt == 0 {
210 logOpt.OptValue = "未设置时间" 210 logOpt.OptValue = "未设置时间"
211 } else { 211 } else {
@@ -230,15 +230,24 @@ func getUserMap(ids []int) (map[int]*domain.User, error) { @@ -230,15 +230,24 @@ func getUserMap(ids []int) (map[int]*domain.User, error) {
230 if len(ids) == 0 { 230 if len(ids) == 0 {
231 return userMap, nil 231 return userMap, nil
232 } 232 }
233 - transactionContext, err := factory.CreateTransactionContext(nil) 233 +
  234 + transactionContext, err := factory.StartTransaction()
234 if err != nil { 235 if err != nil {
235 return userMap, err 236 return userMap, err
236 } 237 }
  238 + defer func() {
  239 + _ = transactionContext.RollbackTransaction()
  240 + }()
  241 +
237 userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) 242 userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
238 _, users, err := userRepo.Find(map[string]interface{}{"ids": ids, "limit": len(ids)}) 243 _, users, err := userRepo.Find(map[string]interface{}{"ids": ids, "limit": len(ids)})
239 if err != nil { 244 if err != nil {
240 return userMap, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 245 return userMap, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
241 } 246 }
  247 + if err := transactionContext.CommitTransaction(); err != nil {
  248 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  249 + }
  250 +
242 for i := range users { 251 for i := range users {
243 user := users[i] 252 user := users[i]
244 userMap[int(user.Id)] = user 253 userMap[int(user.Id)] = user
@@ -284,7 +284,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand, userReq *dom @@ -284,7 +284,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand, userReq *dom
284 var copyTask = taskData.Copy() 284 var copyTask = taskData.Copy()
285 var copyStageList = make([]*domain.TaskStage, 0) 285 var copyStageList = make([]*domain.TaskStage, 0)
286 for _, v := range stageList { 286 for _, v := range stageList {
287 - copyStageList = append(copyStageList, v) 287 + c := v.Copy()
  288 + copyStageList = append(copyStageList, &c)
288 } 289 }
289 290
290 //更新任务的相关人员 291 //更新任务的相关人员