...
|
...
|
@@ -235,6 +235,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT |
|
|
if err := releaseTaskCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -245,6 +246,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var releaseTaskService service.ReleaseTaskService
|
|
|
if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -257,6 +259,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT |
|
|
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -1084,6 +1087,20 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask |
|
|
taskDao = value
|
|
|
}
|
|
|
|
|
|
var releaseTaskService service.ReleaseTaskService
|
|
|
if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
releaseTaskService = value
|
|
|
releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
|
|
|
releaseTaskService.Subscribe(&subscriber.MmmOpenApiServiceServiceSubscriber{
|
|
|
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 找到当前任务
|
|
|
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -1143,6 +1160,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask |
|
|
updateData["assignedPerson"] = &domain.EmployeeInfo{}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// TODO 任务返回错误类型
|
|
|
if err := task.Update(updateData); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -1155,6 +1173,13 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if task.TaskType == domain.TASK_STATUS_EXPIRED {
|
|
|
if _, err := releaseTaskService.Release(task.TaskId, task.Sponsor.Uid); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|