作者 陈志颖

feat:开放待领取任务编辑

@@ -1023,6 +1023,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1023,6 +1023,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1023 defer func() { 1023 defer func() {
1024 transactionContext.RollbackTransaction() 1024 transactionContext.RollbackTransaction()
1025 }() 1025 }()
  1026 +
1026 var taskRepository domain.TaskRepository 1027 var taskRepository domain.TaskRepository
1027 if value, err := factory.CreateTaskRepository(map[string]interface{}{ 1028 if value, err := factory.CreateTaskRepository(map[string]interface{}{
1028 "transactionContext": transactionContext, 1029 "transactionContext": transactionContext,
@@ -1031,6 +1032,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1031,6 +1032,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1031 } else { 1032 } else {
1032 taskRepository = value 1033 taskRepository = value
1033 } 1034 }
  1035 +
1034 var taskDao *dao.TaskDao 1036 var taskDao *dao.TaskDao
1035 if value, err := factory.CreateTaskDao(map[string]interface{}{ 1037 if value, err := factory.CreateTaskDao(map[string]interface{}{
1036 "transactionContext": transactionContext, 1038 "transactionContext": transactionContext,
@@ -1039,6 +1041,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1039,6 +1041,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1039 } else { 1041 } else {
1040 taskDao = value 1042 taskDao = value
1041 } 1043 }
  1044 +
1042 task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId}) 1045 task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
1043 if err != nil { 1046 if err != nil {
1044 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1047 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1046,6 +1049,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1046,6 +1049,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1046 if task == nil { 1049 if task == nil {
1047 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateTaskCommand.TaskId))) 1050 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateTaskCommand.TaskId)))
1048 } 1051 }
  1052 +
1049 if updateTaskCommand.ReferenceResourceItems != nil && len(updateTaskCommand.ReferenceResourceItems) > 0 { 1053 if updateTaskCommand.ReferenceResourceItems != nil && len(updateTaskCommand.ReferenceResourceItems) > 0 {
1050 var referenceResourceIds []int64 1054 var referenceResourceIds []int64
1051 for _, referenceResourceItem := range updateTaskCommand.ReferenceResourceItems { 1055 for _, referenceResourceItem := range updateTaskCommand.ReferenceResourceItems {
@@ -1068,8 +1072,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1068,8 +1072,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1068 } 1072 }
1069 } 1073 }
1070 } 1074 }
  1075 +
1071 updateData := tool_funs.SimpleStructToMap(updateTaskCommand) 1076 updateData := tool_funs.SimpleStructToMap(updateTaskCommand)
  1077 +
1072 fmt.Println(updateTaskCommand.AssignedPerson != int64(0)) 1078 fmt.Println(updateTaskCommand.AssignedPerson != int64(0))
  1079 +
1073 if task.TaskType == domain.TASK_TYPE_DESIGNATE { 1080 if task.TaskType == domain.TASK_TYPE_DESIGNATE {
1074 if updateTaskCommand.AssignedPerson != int64(0) { 1081 if updateTaskCommand.AssignedPerson != int64(0) {
1075 var employeeRepository domain.EmployeeRepository 1082 var employeeRepository domain.EmployeeRepository
@@ -216,8 +216,65 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error { @@ -216,8 +216,65 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
216 216
217 type UnClaimedStatus struct{} 217 type UnClaimedStatus struct{}
218 218
  219 +// TODO 待领取任务开放编辑
219 func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error { 220 func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
220 - return fmt.Errorf("待领取的任务不允许编辑") 221 + //return fmt.Errorf("待领取的任务不允许编辑")
  222 + if taskName, ok := data["taskName"]; ok {
  223 + task.TaskName = taskName.(string)
  224 + }
  225 + if referenceResourceType, ok := data["referenceResourceType"]; ok {
  226 + task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
  227 + }
  228 + if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
  229 + task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
  230 + }
  231 + if projectBelong, ok := data["projectBelong"]; ok {
  232 + task.ProjectBelong = projectBelong.(int)
  233 + }
  234 + if customerValues, ok := data["customerValues"]; ok {
  235 + task.CustomerValues = customerValues.([]int)
  236 + }
  237 + if taskNature, ok := data["taskNature"]; ok {
  238 + task.TaskNature = taskNature.(int)
  239 + }
  240 + if suMoney, ok := data["suMoney"]; ok {
  241 + task.SuMoney = suMoney.(float64)
  242 + }
  243 + if task.TaskType == TASK_TYPE_BID {
  244 + if bidStartTime, ok := data["bidStartTime"]; ok {
  245 + task.BidInfo.BidStartTime = bidStartTime.(time.Time)
  246 + }
  247 + if bidEndTime, ok := data["bidEndTime"]; ok {
  248 + task.BidInfo.BidEndTime = bidEndTime.(time.Time)
  249 + }
  250 + if isRemind, ok := data["isRemind"]; ok {
  251 + task.BidInfo.IsRemind = isRemind.(bool)
  252 + }
  253 + }
  254 + if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
  255 + task.AcceptanceStandard = acceptanceStandard.(string)
  256 + }
  257 + if taskDescription, ok := data["taskDescription"]; ok {
  258 + task.TaskDescription = taskDescription.(string)
  259 + }
  260 + if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
  261 + task.TaskPictureUrls = taskPictureUrls.([]string)
  262 + }
  263 + if isRewardTake, ok := data["isRewardTake"]; ok {
  264 + task.IsRewardTake = isRewardTake.(bool)
  265 + }
  266 + if task.TaskType == TASK_TYPE_DESIGNATE {
  267 + if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
  268 + task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
  269 + }
  270 + if assignedPerson, ok := data["assignedPerson"]; ok {
  271 + task.AssignedPerson = assignedPerson.(*EmployeeInfo)
  272 + if task.AssignedPerson.Uid == 0 {
  273 + task.AssignedPerson = nil
  274 + }
  275 + }
  276 + }
  277 + return nil
221 } 278 }
222 279
223 func (status *UnClaimedStatus) Release(task *Task) error { 280 func (status *UnClaimedStatus) Release(task *Task) error {