|
@@ -2,6 +2,8 @@ package service |
|
@@ -2,6 +2,8 @@ package service |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "time"
|
|
|
6
|
+
|
5
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
6
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
8
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
7
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
9
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
@@ -13,7 +15,6 @@ import ( |
|
@@ -13,7 +15,6 @@ import ( |
13
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
15
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
14
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
16
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
15
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
17
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
16
|
- "time"
|
|
|
17
|
)
|
18
|
)
|
18
|
|
19
|
|
19
|
// 任务服务
|
20
|
// 任务服务
|
|
@@ -908,16 +909,21 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -908,16 +909,21 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
908
|
if err := getTaskQuery.ValidateQuery(); err != nil {
|
909
|
if err := getTaskQuery.ValidateQuery(); err != nil {
|
909
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
910
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
910
|
}
|
911
|
}
|
|
|
912
|
+
|
911
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
913
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
914
|
+
|
912
|
if err != nil {
|
915
|
if err != nil {
|
913
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
916
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
914
|
}
|
917
|
}
|
|
|
918
|
+
|
915
|
if err := transactionContext.StartTransaction(); err != nil {
|
919
|
if err := transactionContext.StartTransaction(); err != nil {
|
916
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
920
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
917
|
}
|
921
|
}
|
|
|
922
|
+
|
918
|
defer func() {
|
923
|
defer func() {
|
919
|
transactionContext.RollbackTransaction()
|
924
|
transactionContext.RollbackTransaction()
|
920
|
}()
|
925
|
}()
|
|
|
926
|
+
|
921
|
var taskRepository domain.TaskRepository
|
927
|
var taskRepository domain.TaskRepository
|
922
|
if value, err := factory.CreateTaskRepository(map[string]interface{}{
|
928
|
if value, err := factory.CreateTaskRepository(map[string]interface{}{
|
923
|
"transactionContext": transactionContext,
|
929
|
"transactionContext": transactionContext,
|
|
@@ -926,14 +932,18 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -926,14 +932,18 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
926
|
} else {
|
932
|
} else {
|
927
|
taskRepository = value
|
933
|
taskRepository = value
|
928
|
}
|
934
|
}
|
|
|
935
|
+
|
929
|
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": getTaskQuery.TaskId})
|
936
|
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": getTaskQuery.TaskId})
|
|
|
937
|
+
|
930
|
if err != nil {
|
938
|
if err != nil {
|
931
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
939
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
932
|
}
|
940
|
}
|
|
|
941
|
+
|
933
|
if task == nil {
|
942
|
if task == nil {
|
934
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId)))
|
943
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId)))
|
935
|
} else {
|
944
|
} else {
|
936
|
var projectBelongRepository domain.ProjectBelongRepository
|
945
|
var projectBelongRepository domain.ProjectBelongRepository
|
|
|
946
|
+
|
937
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
947
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
938
|
"transactionContext": transactionContext,
|
948
|
"transactionContext": transactionContext,
|
939
|
}); err != nil {
|
949
|
}); err != nil {
|
|
@@ -941,7 +951,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -941,7 +951,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
941
|
} else {
|
951
|
} else {
|
942
|
projectBelongRepository = value
|
952
|
projectBelongRepository = value
|
943
|
}
|
953
|
}
|
|
|
954
|
+
|
944
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
955
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
|
|
956
|
+
|
945
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
957
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
946
|
"companyId": task.CompanyId,
|
958
|
"companyId": task.CompanyId,
|
947
|
}); err != nil {
|
959
|
}); err != nil {
|
|
@@ -951,7 +963,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -951,7 +963,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
951
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
963
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
952
|
}
|
964
|
}
|
953
|
}
|
965
|
}
|
|
|
966
|
+
|
954
|
var customerValueRepository domain.CustomerValueRepository
|
967
|
var customerValueRepository domain.CustomerValueRepository
|
|
|
968
|
+
|
955
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
969
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
956
|
"transactionContext": transactionContext,
|
970
|
"transactionContext": transactionContext,
|
957
|
}); err != nil {
|
971
|
}); err != nil {
|
|
@@ -959,7 +973,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -959,7 +973,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
959
|
} else {
|
973
|
} else {
|
960
|
customerValueRepository = value
|
974
|
customerValueRepository = value
|
961
|
}
|
975
|
}
|
|
|
976
|
+
|
962
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
977
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
|
|
978
|
+
|
963
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
979
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
964
|
"companyId": task.CompanyId,
|
980
|
"companyId": task.CompanyId,
|
965
|
}); err != nil {
|
981
|
}); err != nil {
|
|
@@ -969,7 +985,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -969,7 +985,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
969
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
985
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
970
|
}
|
986
|
}
|
971
|
}
|
987
|
}
|
|
|
988
|
+
|
972
|
var taskNatureRepository domain.TaskNatureRepository
|
989
|
var taskNatureRepository domain.TaskNatureRepository
|
|
|
990
|
+
|
973
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
991
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
974
|
"transactionContext": transactionContext,
|
992
|
"transactionContext": transactionContext,
|
975
|
}); err != nil {
|
993
|
}); err != nil {
|
|
@@ -977,7 +995,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -977,7 +995,9 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
977
|
} else {
|
995
|
} else {
|
978
|
taskNatureRepository = value
|
996
|
taskNatureRepository = value
|
979
|
}
|
997
|
}
|
|
|
998
|
+
|
980
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
999
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
|
|
1000
|
+
|
981
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
1001
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
982
|
"companyId": task.CompanyId,
|
1002
|
"companyId": task.CompanyId,
|
983
|
}); err != nil {
|
1003
|
}); err != nil {
|
|
@@ -987,13 +1007,16 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
@@ -987,13 +1007,16 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
987
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
1007
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
988
|
}
|
1008
|
}
|
989
|
}
|
1009
|
}
|
|
|
1010
|
+
|
990
|
taskDto := &dto.TaskDto{}
|
1011
|
taskDto := &dto.TaskDto{}
|
|
|
1012
|
+
|
991
|
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
|
1013
|
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
|
992
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1014
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
993
|
}
|
1015
|
}
|
994
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1016
|
if err := transactionContext.CommitTransaction(); err != nil {
|
995
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1017
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
996
|
}
|
1018
|
}
|
|
|
1019
|
+
|
997
|
return taskDto, nil
|
1020
|
return taskDto, nil
|
998
|
}
|
1021
|
}
|
999
|
}
|
1022
|
}
|