...
|
...
|
@@ -2,6 +2,8 @@ package service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"time"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
...
|
...
|
@@ -13,7 +15,6 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
// 任务服务
|
...
|
...
|
@@ -908,16 +909,21 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
if err := getTaskQuery.ValidateQuery(); 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())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var taskRepository domain.TaskRepository
|
|
|
if value, err := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -926,14 +932,18 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
} else {
|
|
|
taskRepository = value
|
|
|
}
|
|
|
|
|
|
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": getTaskQuery.TaskId})
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if task == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId)))
|
|
|
} else {
|
|
|
var projectBelongRepository domain.ProjectBelongRepository
|
|
|
|
|
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -941,7 +951,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
} else {
|
|
|
projectBelongRepository = value
|
|
|
}
|
|
|
|
|
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
|
|
|
|
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -951,7 +963,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var customerValueRepository domain.CustomerValueRepository
|
|
|
|
|
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -959,7 +973,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
} else {
|
|
|
customerValueRepository = value
|
|
|
}
|
|
|
|
|
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
|
|
|
|
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -969,7 +985,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var taskNatureRepository domain.TaskNatureRepository
|
|
|
|
|
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -977,7 +995,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
} else {
|
|
|
taskNatureRepository = value
|
|
|
}
|
|
|
|
|
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
|
|
|
|
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -987,13 +1007,16 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
|
|
}
|
|
|
}
|
|
|
|
|
|
taskDto := &dto.TaskDto{}
|
|
|
|
|
|
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); 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())
|
|
|
}
|
|
|
|
|
|
return taskDto, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
|