mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
支持view自定义返回
This commit is contained in:
@@ -25,14 +25,14 @@ func (e *SysJob) RemoveJobForService(c *gin.Context) {
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
db, err := e.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] error:%s", msgID, err)
|
||||
app.Error(c, 500, err, "")
|
||||
return
|
||||
}
|
||||
var v dto.GeneralDelDto
|
||||
err = c.BindUri(&v)
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] 参数验证错误, error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] 参数验证错误, error:%s", msgID, err)
|
||||
app.Error(c, 422, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
@@ -52,14 +52,14 @@ func (e *SysJob) StartJobForService(c *gin.Context) {
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
db, err := e.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] error:%s", msgID, err)
|
||||
app.Error(c, 500, err, "")
|
||||
return
|
||||
}
|
||||
var v dto.GeneralGetDto
|
||||
err = c.BindUri(&v)
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] 参数验证错误, error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] 参数验证错误, error:%s", msgID, err)
|
||||
app.Error(c, 422, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ func registerSysJobRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlew
|
||||
list := make([]models.SysJob, 0)
|
||||
return &list
|
||||
}))
|
||||
r.GET("/:id", actions.PermissionAction(), actions.ViewAction(new(dto.SysJobById)))
|
||||
r.GET("/:id", actions.PermissionAction(), actions.ViewAction(new(dto.SysJobById), func() interface{} {
|
||||
return &dto.SysJobItem{}
|
||||
}))
|
||||
r.POST("", actions.CreateAction(new(dto.SysJobControl)))
|
||||
r.PUT("", actions.PermissionAction(), actions.UpdateAction(new(dto.SysJobControl)))
|
||||
r.DELETE("", actions.PermissionAction(), actions.DeleteAction(new(dto.SysJobById)))
|
||||
|
||||
@@ -26,7 +26,7 @@ func (m *SysJobSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysJobSearch) Bind(ctx *gin.Context) error {
|
||||
err := ctx.Bind(m)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %#v", err)
|
||||
log.Errorf("MsgID[%s] Bind error: %s", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -91,3 +91,17 @@ func (s *SysJobById) Generate() dto.Control {
|
||||
func (s *SysJobById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysJob{}, nil
|
||||
}
|
||||
|
||||
type SysJobItem struct {
|
||||
JobId int `json:"jobId"`
|
||||
JobName string `json:"jobName" validate:"required"` // 名称
|
||||
JobGroup string `json:"jobGroup"` // 任务分组
|
||||
JobType int `json:"jobType"` // 任务类型
|
||||
CronExpression string `json:"cronExpression"` // cron表达式
|
||||
InvokeTarget string `json:"invokeTarget"` // 调用目标
|
||||
Args string `json:"args"` // 目标参数
|
||||
MisfirePolicy int `json:"misfirePolicy"` // 执行策略
|
||||
Concurrent int `json:"concurrent"` // 是否并发
|
||||
Status int `json:"status"` // 状态
|
||||
EntryId int `json:"entryId"` // job启动时返回的id
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (e *SysJob) RemoveJob(c *dto.GeneralDelDto) error {
|
||||
data.JobId = c.Id
|
||||
err = e.Orm.Table(data.TableName()).First(&data).Error
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] db error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
||||
return err
|
||||
}
|
||||
cn := jobs.Remove(data.EntryId)
|
||||
@@ -33,7 +33,7 @@ func (e *SysJob) RemoveJob(c *dto.GeneralDelDto) error {
|
||||
if res {
|
||||
err = e.Orm.Table(data.TableName()).Where("entry_id = ?", data.EntryId).Update("entry_id", 0).Error
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] db error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func (e *SysJob) StartJob(c *dto.GeneralGetDto) error {
|
||||
msgID := e.MsgID
|
||||
err = e.Orm.Table(data.TableName()).First(&data, c.Id).Error
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] db error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
||||
return err
|
||||
}
|
||||
if data.JobType == 1 {
|
||||
@@ -62,7 +62,7 @@ func (e *SysJob) StartJob(c *dto.GeneralGetDto) error {
|
||||
j.Name = data.JobName
|
||||
data.EntryId, err = jobs.AddJob(j)
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] jobs AddJob[HttpJob] error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] jobs AddJob[HttpJob] error:%s", msgID, err)
|
||||
}
|
||||
} else {
|
||||
var j = &jobs.ExecJob{}
|
||||
@@ -73,7 +73,7 @@ func (e *SysJob) StartJob(c *dto.GeneralGetDto) error {
|
||||
j.Args = data.Args
|
||||
data.EntryId, err = jobs.AddJob(j)
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] jobs AddJob[ExecJob] error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] jobs AddJob[ExecJob] error:%s", msgID, err)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -82,7 +82,7 @@ func (e *SysJob) StartJob(c *dto.GeneralGetDto) error {
|
||||
|
||||
err = e.Orm.Table(data.TableName()).Where(c.Id).Updates(&data).Error
|
||||
if err != nil {
|
||||
log.Errorf("msgID[%s] db error:%#v", msgID, err)
|
||||
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user