作者 linmadan

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

... ... @@ -494,6 +494,23 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 {
abilityServiceGateway, err := factory.CreateAbilityServiceGateway(nil)
if err != nil {
fmt.Println(err.Error())
} else {
var serials []int64
for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
serials = append(serials, referenceResourceItem.SerialNumber)
}
data, err := abilityServiceGateway.SaveTaskCallback(task.Sponsor.Uid, task.TaskId, serials)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println(data)
}
}
}
return task, nil
}
}
... ... @@ -609,6 +626,23 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 {
abilityServiceGateway, err := factory.CreateAbilityServiceGateway(nil)
if err != nil {
fmt.Println(err.Error())
} else {
var serials []int64
for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
serials = append(serials, referenceResourceItem.SerialNumber)
}
data, err := abilityServiceGateway.SaveTaskCallback(task.Sponsor.Uid, task.TaskId, serials)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println(data)
}
}
}
return task, nil
}
}
... ... @@ -649,6 +683,23 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 {
abilityServiceGateway, err := factory.CreateAbilityServiceGateway(nil)
if err != nil {
fmt.Println(err.Error())
} else {
var serials []int64
for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
serials = append(serials, referenceResourceItem.SerialNumber)
}
data, err := abilityServiceGateway.DeleteTaskCallback(task.Sponsor.Uid, task.TaskId, serials)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println(data)
}
}
}
return task, nil
}
}
... ...
... ... @@ -71,6 +71,34 @@ func (serviceGateway *HttplibAbilityServiceGateway) ReceiverTaskCallback(uid int
return data, err
}
func (serviceGateway *HttplibAbilityServiceGateway) SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "task/saveTaskCallback"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["uid"] = uid
options["taskId"] = taskId
options["serials"] = serials
request.JSONBody(options)
response := make(map[string]interface{})
request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func (serviceGateway *HttplibAbilityServiceGateway) DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "task/deleteTaskCallback"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["uid"] = uid
options["taskId"] = taskId
options["serials"] = serials
request.JSONBody(options)
response := make(map[string]interface{})
request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func NewHttplibAbilityServiceGateway() *HttplibAbilityServiceGateway {
return &HttplibAbilityServiceGateway{
httplibBaseServiceGateway: httplibBaseServiceGateway{
... ...
... ... @@ -7,4 +7,6 @@ type AbilityServiceGateway interface {
CommitQuestionSolution(qid int64, uid int64, solveUid int64, content string, scoreSolve float64, imgs []string, partners []map[string]interface{}) (map[string]interface{}, error)
CloseTaskCallback(taskId int64, referenceResourceIds []int64) (map[string]interface{}, error)
ReceiverTaskCallback(uid int64, taskId int64, referenceResourceIds []int64, operatorId int64, operatorTime time.Time) (map[string]interface{}, error)
}
\ No newline at end of file
SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error)
DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error)
}
... ...