...
|
...
|
@@ -7,7 +7,6 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
|
|
|
"strconv"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -172,16 +171,14 @@ func (rs *EvaluationProjectService) UpdateTemplateNode(in *command.UpdateProject |
|
|
}
|
|
|
|
|
|
func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interface{}, error) {
|
|
|
// Get 不需要事务
|
|
|
if err := utils.ValidateCommand(in); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
return nil, err
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -201,6 +198,9 @@ func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interfac |
|
|
projectAdapter.TransformRecipientAdapter(users)
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return projectAdapter, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -317,3 +317,52 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf |
|
|
}
|
|
|
return project, nil
|
|
|
}
|
|
|
|
|
|
func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
userIds := make([]int64, 0)
|
|
|
userIdMap := map[int64]int64{}
|
|
|
for i := range projects {
|
|
|
project := projects[i]
|
|
|
for j := range project.Recipients {
|
|
|
userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64)
|
|
|
userIdMap[userId] = userId
|
|
|
}
|
|
|
}
|
|
|
for _, v := range userIdMap {
|
|
|
userIds = append(userIds, v)
|
|
|
}
|
|
|
|
|
|
userTotal := 0
|
|
|
departmentTotal := 0
|
|
|
if len(userIds) > 0 {
|
|
|
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)})
|
|
|
departmentIdMap := map[int]int{}
|
|
|
for i := range users {
|
|
|
user := users[i]
|
|
|
for _, v := range user.DepartmentId {
|
|
|
departmentIdMap[v] = v
|
|
|
}
|
|
|
}
|
|
|
userTotal = len(users)
|
|
|
departmentTotal = len(departmentIdMap)
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil
|
|
|
} |
...
|
...
|
|