mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[fix] 修复清空删除任务日志
This commit is contained in:
@@ -85,7 +85,7 @@ func (l *JobApi) StartJobForService(rc *restfulx.ReqCtx) {
|
||||
j.OrgId = job.OrgId
|
||||
j.Owner = job.Owner
|
||||
job.EntryId, err = jobs.AddJob(jobs.Crontab, j)
|
||||
biz.ErrIsNil(err, "添加JOB失败")
|
||||
biz.ErrIsNil(err, "添加任务失败,可能任务表达式错误")
|
||||
|
||||
l.JobApp.Update(*job)
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package api
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/apps/job/entity"
|
||||
"pandax/apps/job/services"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type JobLogApi struct {
|
||||
@@ -34,8 +34,8 @@ func (l *JobLogApi) GetJobLogList(rc *restfulx.ReqCtx) {
|
||||
|
||||
// DeleteJobLog 批量删除登录日志
|
||||
func (l *JobLogApi) DeleteJobLog(rc *restfulx.ReqCtx) {
|
||||
logIds := restfulx.QueryParam(rc, "logId")
|
||||
group := utils.IdsStrToIdsIntGroup(logIds)
|
||||
logIds := restfulx.PathParam(rc, "id")
|
||||
group := strings.Split(logIds, ",")
|
||||
l.JobLogApp.Delete(group)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ func InitJobLogRouter(container *restful.Container) {
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{logId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除操作日志信息").Handle(s.DeleteJobLog)
|
||||
}).
|
||||
Doc("删除操作日志信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("logId", "多id 1,2,3").DataType("string")))
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
ws.Route(ws.DELETE("/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("清空操作日志信息").Handle(s.DeleteAll)
|
||||
|
||||
@@ -11,7 +11,7 @@ type (
|
||||
JobLogModel interface {
|
||||
Insert(data entity.JobLog) *entity.JobLog
|
||||
FindListPage(page, pageSize int, data entity.JobLog) (*[]entity.JobLog, int64)
|
||||
Delete(infoId []int64)
|
||||
Delete(infoId []string)
|
||||
DeleteAll()
|
||||
}
|
||||
|
||||
@@ -48,16 +48,16 @@ func (m *JobLogModelImpl) FindListPage(page, pageSize int, data entity.JobLog) (
|
||||
err := db.Count(&total).Error
|
||||
err = db.Order("create_time desc").Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
|
||||
biz.ErrIsNil(err, "查询登录分页日志信息失败")
|
||||
biz.ErrIsNil(err, "查询任务分页日志信息失败")
|
||||
return &list, total
|
||||
}
|
||||
|
||||
func (m *JobLogModelImpl) Delete(logIds []int64) {
|
||||
func (m *JobLogModelImpl) Delete(logIds []string) {
|
||||
err := global.Db.Table(m.table).Delete(&entity.JobLog{}, "id in (?)", logIds).Error
|
||||
biz.ErrIsNil(err, "删除登录日志信息失败")
|
||||
biz.ErrIsNil(err, "删除任务日志信息失败")
|
||||
return
|
||||
}
|
||||
|
||||
func (m *JobLogModelImpl) DeleteAll() {
|
||||
global.Db.Exec("DELETE FROM log_jobs")
|
||||
global.Db.Exec("DELETE FROM job_logs")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user