PLT-6595-Server: Job Management APIs. (#6931)
* PLT-6595-Server: Job Management APIs. * MANAGE_JOBS Permission * Fix test.
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
5ae701d133
Коммит
6c6f2a1138
21
app/job.go
21
app/job.go
@@ -5,6 +5,7 @@ package app
|
||||
|
||||
import (
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/jobs"
|
||||
)
|
||||
|
||||
func GetJob(id string) (*model.Job, *model.AppError) {
|
||||
@@ -15,6 +16,18 @@ func GetJob(id string) (*model.Job, *model.AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetJobsPage(page int, perPage int) ([]*model.Job, *model.AppError) {
|
||||
return GetJobs(page*perPage, perPage)
|
||||
}
|
||||
|
||||
func GetJobs(offset int, limit int) ([]*model.Job, *model.AppError) {
|
||||
if result := <-Srv.Store.Job().GetAllPage(offset, limit); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
return result.Data.([]*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func GetJobsByTypePage(jobType string, page int, perPage int) ([]*model.Job, *model.AppError) {
|
||||
return GetJobsByType(jobType, page*perPage, perPage)
|
||||
}
|
||||
@@ -26,3 +39,11 @@ func GetJobsByType(jobType string, offset int, limit int) ([]*model.Job, *model.
|
||||
return result.Data.([]*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func CreateJob(job *model.Job) (*model.Job, *model.AppError) {
|
||||
return jobs.CreateJob(job.Type, job.Data)
|
||||
}
|
||||
|
||||
func CancelJob(jobId string) *model.AppError {
|
||||
return jobs.RequestCancellation(jobId)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user