【更新】更新restful

This commit is contained in:
PandaGoAdmin
2022-08-03 17:21:07 +08:00
parent 249ddd80b2
commit 518a3de903
18 changed files with 68 additions and 892 deletions

View File

@@ -14,16 +14,6 @@ type JobApi struct {
JobApp services.JobModel
}
// @Summary 添加任务
// @Description 获取JSON
// @Tags 任务
// @Accept application/json
// @Product application/json
// @Param data body entity.SysJob true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /job/job [post]
// @Security X-TOKEN
func (j *JobApi) CreateJob(rc *restfulx.ReqCtx) {
var job entity.SysJob
restfulx.BindQuery(rc, &job)
@@ -32,17 +22,6 @@ func (j *JobApi) CreateJob(rc *restfulx.ReqCtx) {
j.JobApp.Insert(job)
}
// @Summary job列表
// @Description 获取JSON
// @Tags 任务
// @Param status query string false "status"
// @Param jobName query string false "jobName"
// @Param jobGroup query string false "jobGroup"
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /job/list [get]
// @Security
func (j *JobApi) GetJobList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
@@ -59,66 +38,29 @@ func (j *JobApi) GetJobList(rc *restfulx.ReqCtx) {
}
}
// @Summary 获取一个job
// @Description 获取JSON
// @Tags 任务
// @Param jobId path int true "jobId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /job/{jobId} [get]
// @Security
func (j *JobApi) GetJob(rc *restfulx.ReqCtx) {
jobId := restfulx.PathParamInt(rc, "jobId")
rc.ResData = j.JobApp.FindOne(int64(jobId))
}
// @Summary 修改JOB
// @Description 获取JSON
// @Tags 任务
// @Accept application/json
// @Product application/json
// @Param data body entity.SysJob true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /job [put]
// @Security X-TOKEN
func (l *JobApi) UpdateJob(rc *restfulx.ReqCtx) {
var job entity.SysJob
restfulx.BindQuery(rc, &job)
l.JobApp.Update(job)
}
// @Summary 批量删除JOB
// @Description 删除数据
// @Tags 任务
// @Param infoId path string true "以逗号(,分割的infoId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /job/{jobId} [delete]
func (l *JobApi) DeleteJob(rc *restfulx.ReqCtx) {
jobIds := restfulx.PathParam(rc, "jobId")
group := utils.IdsStrToIdsIntGroup(jobIds)
l.JobApp.Delete(group)
}
// @Summary 停止JOB
// @Description 停止Job
// @Tags 任务
// @Param jobId path int true "jobId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /job/stop/{jobId} [get]
func (l *JobApi) StopJobForService(rc *restfulx.ReqCtx) {
jobId := restfulx.PathParamInt(rc, "jobId")
job := l.JobApp.FindOne(int64(jobId))
jobs.Remove(jobs.Crontab, job.EntryId)
}
// @Summary 开始JOB
// @Description 开始Job
// @Tags 任务
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /job/stop/{jobId} [get]
func (l *JobApi) StartJobForService(rc *restfulx.ReqCtx) {
jobId := restfulx.PathParamInt(rc, "jobId")
job := l.JobApp.FindOne(int64(jobId))
@@ -152,16 +94,6 @@ func (l *JobApi) StartJobForService(rc *restfulx.ReqCtx) {
l.JobApp.Update(*job)
}
// @Summary 修改JOB状态
// @Description 获取JSON
// @Tags 任务
// @Accept application/json
// @Product application/json
// @Param data body from.JobStatus true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /job/changeStatus [put]
// @Security X-TOKEN
func (l *JobApi) UpdateStatusJob(rc *restfulx.ReqCtx) {
var job from.JobStatus
restfulx.BindQuery(rc, &job)