...
|
...
|
@@ -284,8 +284,8 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask |
|
|
}
|
|
|
|
|
|
// 搜索关闭任务记录
|
|
|
func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecord *command.SearchTaskCommand) (interface{}, error) {
|
|
|
if err := searchOffTaskRecord.ValidateCommand(); err != nil {
|
|
|
func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *command.SearchOffTaskRecordCommand) (interface{}, error) {
|
|
|
if err := searchOffTaskRecordCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -306,19 +306,88 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecord *command |
|
|
} else {
|
|
|
taskRepository = value
|
|
|
}
|
|
|
if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchOffTaskRecord)); err != nil {
|
|
|
var offTaskRecordRepository domain.OffTaskRecordRepository
|
|
|
if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
offTaskRecordRepository = value
|
|
|
}
|
|
|
_, tasks, err := taskRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchOffTaskRecordCommand.CompanyId,
|
|
|
"taskStatus": domain.TASK_STATUS_CLOSED,
|
|
|
"taskContentMatch": searchOffTaskRecordCommand.TaskContentMatch,
|
|
|
"taskType": searchOffTaskRecordCommand.TaskType,
|
|
|
"customerValue": searchOffTaskRecordCommand.CustomerValue,
|
|
|
"taskNature": searchOffTaskRecordCommand.TaskNature,
|
|
|
"offset": searchOffTaskRecordCommand.Offset,
|
|
|
"limit": searchOffTaskRecordCommand.Limit,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
fmt.Println(tasks)
|
|
|
var taskIds []int64
|
|
|
for _, task := range tasks {
|
|
|
taskIds = append(taskIds, task.TaskId)
|
|
|
}
|
|
|
if count, offTaskRecords, err := offTaskRecordRepository.Find(map[string]interface{}{
|
|
|
"taskIds": taskIds,
|
|
|
"customerValue": searchOffTaskRecordCommand.CustomerValue,
|
|
|
"offStartTime": searchOffTaskRecordCommand.OffStartTime,
|
|
|
"offEndTime": searchOffTaskRecordCommand.OffEndTime,
|
|
|
"limit": searchOffTaskRecordCommand.Limit,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"count": count,
|
|
|
"tasks": tasks,
|
|
|
"count": count,
|
|
|
"offTaskRecords": offTaskRecords,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回关闭任务记录
|
|
|
func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.GetOffTaskRecordQuery) (interface{}, error) {
|
|
|
if err := getOffTaskRecordQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var offTaskRecordRepository domain.OffTaskRecordRepository
|
|
|
if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
offTaskRecordRepository = value
|
|
|
}
|
|
|
offTaskRecord, err := offTaskRecordRepository.FindOne(map[string]interface{}{"offTaskRecordId": getOffTaskRecordQuery.OffTaskRecordId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if offTaskRecord == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getOffTaskRecordQuery.OffTaskRecordId)))
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return offTaskRecord, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 创建新任务
|
|
|
func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) {
|
|
|
if err := createTaskCommand.ValidateCommand(); err != nil {
|
...
|
...
|
|