作者 陈志颖

feat:开放待领取任务编辑

... ... @@ -1023,6 +1023,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1031,6 +1032,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
} else {
taskRepository = value
}
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1039,6 +1041,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
} else {
taskDao = value
}
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1046,6 +1049,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
if task == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateTaskCommand.TaskId)))
}
if updateTaskCommand.ReferenceResourceItems != nil && len(updateTaskCommand.ReferenceResourceItems) > 0 {
var referenceResourceIds []int64
for _, referenceResourceItem := range updateTaskCommand.ReferenceResourceItems {
... ... @@ -1068,8 +1072,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
}
}
}
updateData := tool_funs.SimpleStructToMap(updateTaskCommand)
fmt.Println(updateTaskCommand.AssignedPerson != int64(0))
if task.TaskType == domain.TASK_TYPE_DESIGNATE {
if updateTaskCommand.AssignedPerson != int64(0) {
var employeeRepository domain.EmployeeRepository
... ...
... ... @@ -216,8 +216,65 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
type UnClaimedStatus struct{}
// TODO 待领取任务开放编辑
func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("待领取的任务不允许编辑")
//return fmt.Errorf("待领取的任务不允许编辑")
if taskName, ok := data["taskName"]; ok {
task.TaskName = taskName.(string)
}
if referenceResourceType, ok := data["referenceResourceType"]; ok {
task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
}
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if projectBelong, ok := data["projectBelong"]; ok {
task.ProjectBelong = projectBelong.(int)
}
if customerValues, ok := data["customerValues"]; ok {
task.CustomerValues = customerValues.([]int)
}
if taskNature, ok := data["taskNature"]; ok {
task.TaskNature = taskNature.(int)
}
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
}
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
if isRemind, ok := data["isRemind"]; ok {
task.BidInfo.IsRemind = isRemind.(bool)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
task.AcceptanceStandard = acceptanceStandard.(string)
}
if taskDescription, ok := data["taskDescription"]; ok {
task.TaskDescription = taskDescription.(string)
}
if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
task.TaskPictureUrls = taskPictureUrls.([]string)
}
if isRewardTake, ok := data["isRewardTake"]; ok {
task.IsRewardTake = isRewardTake.(bool)
}
if task.TaskType == TASK_TYPE_DESIGNATE {
if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
}
if assignedPerson, ok := data["assignedPerson"]; ok {
task.AssignedPerson = assignedPerson.(*EmployeeInfo)
if task.AssignedPerson.Uid == 0 {
task.AssignedPerson = nil
}
}
}
return nil
}
func (status *UnClaimedStatus) Release(task *Task) error {
... ...