作者 linmadan

添加创建,编辑,删除任务时对问题系统得回调

@@ -494,6 +494,23 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -494,6 +494,23 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
494 if err := transactionContext.CommitTransaction(); err != nil { 494 if err := transactionContext.CommitTransaction(); err != nil {
495 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 495 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
496 } 496 }
  497 + if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 {
  498 + abilityServiceGateway, err := factory.CreateAbilityServiceGateway(nil)
  499 + if err != nil {
  500 + fmt.Println(err.Error())
  501 + } else {
  502 + var serials []int64
  503 + for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
  504 + serials = append(serials, referenceResourceItem.SerialNumber)
  505 + }
  506 + data, err := abilityServiceGateway.SaveTaskCallback(task.Sponsor.Uid, task.TaskId, serials)
  507 + if err != nil {
  508 + fmt.Println(err.Error())
  509 + } else {
  510 + fmt.Println(data)
  511 + }
  512 + }
  513 + }
497 return task, nil 514 return task, nil
498 } 515 }
499 } 516 }
@@ -609,6 +626,23 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -609,6 +626,23 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
609 if err := transactionContext.CommitTransaction(); err != nil { 626 if err := transactionContext.CommitTransaction(); err != nil {
610 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 627 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
611 } 628 }
  629 + if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 {
  630 + abilityServiceGateway, err := factory.CreateAbilityServiceGateway(nil)
  631 + if err != nil {
  632 + fmt.Println(err.Error())
  633 + } else {
  634 + var serials []int64
  635 + for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
  636 + serials = append(serials, referenceResourceItem.SerialNumber)
  637 + }
  638 + data, err := abilityServiceGateway.SaveTaskCallback(task.Sponsor.Uid, task.TaskId, serials)
  639 + if err != nil {
  640 + fmt.Println(err.Error())
  641 + } else {
  642 + fmt.Println(data)
  643 + }
  644 + }
  645 + }
612 return task, nil 646 return task, nil
613 } 647 }
614 } 648 }
@@ -649,6 +683,23 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask @@ -649,6 +683,23 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask
649 if err := transactionContext.CommitTransaction(); err != nil { 683 if err := transactionContext.CommitTransaction(); err != nil {
650 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 684 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
651 } 685 }
  686 + if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 {
  687 + abilityServiceGateway, err := factory.CreateAbilityServiceGateway(nil)
  688 + if err != nil {
  689 + fmt.Println(err.Error())
  690 + } else {
  691 + var serials []int64
  692 + for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
  693 + serials = append(serials, referenceResourceItem.SerialNumber)
  694 + }
  695 + data, err := abilityServiceGateway.DeleteTaskCallback(task.Sponsor.Uid, task.TaskId, serials)
  696 + if err != nil {
  697 + fmt.Println(err.Error())
  698 + } else {
  699 + fmt.Println(data)
  700 + }
  701 + }
  702 + }
652 return task, nil 703 return task, nil
653 } 704 }
654 } 705 }
@@ -71,6 +71,34 @@ func (serviceGateway *HttplibAbilityServiceGateway) ReceiverTaskCallback(uid int @@ -71,6 +71,34 @@ func (serviceGateway *HttplibAbilityServiceGateway) ReceiverTaskCallback(uid int
71 return data, err 71 return data, err
72 } 72 }
73 73
  74 +func (serviceGateway *HttplibAbilityServiceGateway) SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
  75 + url := strings.Join([]string{serviceGateway.baseURL, "task/saveTaskCallback"}, "/")
  76 + request := serviceGateway.createRequest(url, "post")
  77 + options := make(map[string]interface{})
  78 + options["uid"] = uid
  79 + options["taskId"] = taskId
  80 + options["serials"] = serials
  81 + request.JSONBody(options)
  82 + response := make(map[string]interface{})
  83 + request.ToJSON(&response)
  84 + data, err := serviceGateway.responseHandle(response)
  85 + return data, err
  86 +}
  87 +
  88 +func (serviceGateway *HttplibAbilityServiceGateway) DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
  89 + url := strings.Join([]string{serviceGateway.baseURL, "task/deleteTaskCallback"}, "/")
  90 + request := serviceGateway.createRequest(url, "post")
  91 + options := make(map[string]interface{})
  92 + options["uid"] = uid
  93 + options["taskId"] = taskId
  94 + options["serials"] = serials
  95 + request.JSONBody(options)
  96 + response := make(map[string]interface{})
  97 + request.ToJSON(&response)
  98 + data, err := serviceGateway.responseHandle(response)
  99 + return data, err
  100 +}
  101 +
74 func NewHttplibAbilityServiceGateway() *HttplibAbilityServiceGateway { 102 func NewHttplibAbilityServiceGateway() *HttplibAbilityServiceGateway {
75 return &HttplibAbilityServiceGateway{ 103 return &HttplibAbilityServiceGateway{
76 httplibBaseServiceGateway: httplibBaseServiceGateway{ 104 httplibBaseServiceGateway: httplibBaseServiceGateway{
@@ -7,4 +7,6 @@ type AbilityServiceGateway interface { @@ -7,4 +7,6 @@ type AbilityServiceGateway interface {
7 CommitQuestionSolution(qid int64, uid int64, solveUid int64, content string, scoreSolve float64, imgs []string, partners []map[string]interface{}) (map[string]interface{}, error) 7 CommitQuestionSolution(qid int64, uid int64, solveUid int64, content string, scoreSolve float64, imgs []string, partners []map[string]interface{}) (map[string]interface{}, error)
8 CloseTaskCallback(taskId int64, referenceResourceIds []int64) (map[string]interface{}, error) 8 CloseTaskCallback(taskId int64, referenceResourceIds []int64) (map[string]interface{}, error)
9 ReceiverTaskCallback(uid int64, taskId int64, referenceResourceIds []int64, operatorId int64, operatorTime time.Time) (map[string]interface{}, error) 9 ReceiverTaskCallback(uid int64, taskId int64, referenceResourceIds []int64, operatorId int64, operatorTime time.Time) (map[string]interface{}, error)
10 -}  
  10 + SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error)
  11 + DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error)
  12 +}