45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package controllers
|
|
|
|
import (
|
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
"github.com/astaxie/beego"
|
|
)
|
|
|
|
type JobController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
// @Title 发布任务
|
|
// @Description 发布任务
|
|
// @Param token header string true "认证token"
|
|
// @Param payload formData string true "job+step 类型"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /PublishJob [post]
|
|
func (c *JobController) PublishJob() {
|
|
c.callPublishJob(func(params *tJobPublishJobParams) (retVal interface{}, errCode string, err error) {
|
|
var job *model.Job
|
|
if err = jxutils.Strings2Objs(params.Payload, &job); err == nil {
|
|
err = cms.PublishJob(params.Ctx, job)
|
|
}
|
|
return retVal, "", err
|
|
})
|
|
}
|
|
|
|
// @Title 查看任务类型
|
|
// @Description 查看任务类型
|
|
// @Param token header string true "认证token"
|
|
// @Param name query string false "分类名"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /GetJobCategories [get]
|
|
func (c *JobController) GetJobCategories() {
|
|
c.callGetJobCategories(func(params *tJobGetJobCategoriesParams) (retVal interface{}, errCode string, err error) {
|
|
retVal, err = dao.GetJobCategories(dao.GetDB(), params.Name)
|
|
return retVal, "", err
|
|
})
|
|
}
|