作者 tangxvhui

调整 任务详情输出

... ... @@ -17,6 +17,7 @@ type TaskInfoAdapter struct {
type UserData struct {
Id int64 `json:"id,string"` // 用户Id
ParentId int64 `json:"parentId,string"`
Account string `json:"account"` // 用户账号
Name string `json:"name"` // 用户姓名
}
... ...
... ... @@ -109,7 +109,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont
Status: domain.TaskRunning,
Level: 0,
LevelName: "",
RelatedUser: []int{},
RelatedUser: []int{int(leaderData.Id), int(leaderData.ParentId)},
RunAt: nowTime.Unix(),
StopAt: 0,
}
... ... @@ -215,9 +215,22 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error())
}
}
_, leaderList, err := userRepo.Find(map[string]interface{}{
"id": taskData.Leader.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询人员失败:"+err.Error())
}
if len(leaderList) == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有查询到人员")
}
leaderData := leaderList[0]
//更新相关人员
taskData.RelatedUser = []int{}
taskData.RelatedUser = []int{int(leaderData.Id), int(leaderData.ParentId)}
for _, val := range relatedUser {
if val.Id == leaderData.Id || val.Id == leaderData.ParentId {
continue
}
taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id))
}
//更新任务名称
... ... @@ -385,7 +398,16 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error())
}
}
_, leaderDataList, err := userRepo.Find(map[string]interface{}{
"ids": taskData.Leader.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error())
}
var leaderData domain.User
if len(leaderDataList) > 0 {
leaderData = *leaderDataList[0]
}
//查询是否已经有每日评估
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -410,6 +432,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
Id: taskData.Leader.Id,
Account: taskData.Leader.Account,
Name: taskData.Leader.Name,
ParentId: leaderData.ParentId,
},
Status: int(taskData.Status),
StatusDescription: taskData.StatusDescription(),
... ... @@ -426,6 +449,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
Id: val.Id,
Account: val.Account,
Name: val.Name,
ParentId: val.ParentId,
})
}
... ...