修改curd基本写法
This commit is contained in:
1 parent
55496078f0
commit
ca98fd873c
3 files changed
+43
-84
No files matched your search
+23
-23
@@ -20,10 +20,10 @@ func GetSysJobList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize,err = tools.StringToInt(size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex,err = tools.StringToInt(index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
var v dto.SysJobSearch
|
||||
@@ -43,10 +43,10 @@ func GetSysJob(c *gin.Context) {
|
||||
err := c.BindUri(&v)
|
||||
tools.HasError(err, "", 500)
|
||||
data.JobId, _ = tools.StringToInt(v.Id)
|
||||
result, err := data.Get()
|
||||
err = data.Get(data.JobId)
|
||||
tools.HasError(err, "抱歉未找到相关信息", -1)
|
||||
|
||||
app.OK(c, result, "")
|
||||
app.OK(c, data, "")
|
||||
}
|
||||
|
||||
func InsertSysJob(c *gin.Context) {
|
||||
@@ -54,9 +54,9 @@ func InsertSysJob(c *gin.Context) {
|
||||
err := c.ShouldBindJSON(&data)
|
||||
data.CreateBy = tools.GetUserIdStr(c)
|
||||
tools.HasError(err, "", 500)
|
||||
result, err := data.Create()
|
||||
err = data.Create()
|
||||
tools.HasError(err, "", -1)
|
||||
app.OK(c, result, "")
|
||||
app.OK(c, data, "")
|
||||
}
|
||||
|
||||
func UpdateSysJob(c *gin.Context) {
|
||||
@@ -64,10 +64,10 @@ func UpdateSysJob(c *gin.Context) {
|
||||
err := c.ShouldBindJSON(&data)
|
||||
tools.HasError(err, "数据解析失败", -1)
|
||||
data.UpdateBy = tools.GetUserIdStr(c)
|
||||
result, err := data.Update(data.JobId)
|
||||
_, err = data.Update(data.JobId)
|
||||
tools.HasError(err, "", -1)
|
||||
|
||||
app.OK(c, result, "")
|
||||
app.OK(c, data, "")
|
||||
}
|
||||
|
||||
func DeleteSysJob(c *gin.Context) {
|
||||
@@ -78,7 +78,7 @@ func DeleteSysJob(c *gin.Context) {
|
||||
tools.HasError(err, "", 500)
|
||||
data.UpdateBy = tools.GetUserIdStr(c)
|
||||
IDS := tools.IdsStrToIdsIntGroupStr(v.Id)
|
||||
_, err = data.BatchDelete(IDS)
|
||||
err = data.BatchDelete(IDS)
|
||||
tools.HasError(err, msg.DeletedFail, 500)
|
||||
app.OK(c, nil, msg.DeletedSuccess)
|
||||
}
|
||||
@@ -89,14 +89,14 @@ func RemoveJob(c *gin.Context) {
|
||||
err := c.BindUri(&v)
|
||||
tools.HasError(err, "", 500)
|
||||
data.JobId, _ = tools.StringToInt(v.Id)
|
||||
result, err := data.Get()
|
||||
err = data.Get(data.JobId)
|
||||
tools.HasError(err, "", 500)
|
||||
cn := jobs.Remove(result.EntryId)
|
||||
cn := jobs.Remove(data.EntryId)
|
||||
|
||||
select {
|
||||
case res := <-cn:
|
||||
if res {
|
||||
_, _ = data.RemoveEntryID(result.EntryId)
|
||||
_, _ = data.RemoveEntryID(data.EntryId)
|
||||
app.OK(c, nil, msg.DeletedSuccess)
|
||||
}
|
||||
case <-time.After(time.Second * 1):
|
||||
@@ -111,22 +111,22 @@ func StartJob(c *gin.Context) {
|
||||
err := c.BindUri(&v)
|
||||
tools.HasError(err, "", 500)
|
||||
data.JobId, _ = tools.StringToInt(v.Id)
|
||||
result, err := data.Get()
|
||||
err = data.Get(data.JobId)
|
||||
tools.HasError(err, "", 500)
|
||||
if result.JobType == 1 {
|
||||
if data.JobType == 1 {
|
||||
var j = &jobs.HttpJob{}
|
||||
j.InvokeTarget = result.InvokeTarget
|
||||
j.CronExpression = result.CronExpression
|
||||
j.JobId = result.JobId
|
||||
j.Name = result.JobName
|
||||
j.InvokeTarget = data.InvokeTarget
|
||||
j.CronExpression = data.CronExpression
|
||||
j.JobId = data.JobId
|
||||
j.Name = data.JobName
|
||||
data.EntryId, err = jobs.AddJob(j)
|
||||
} else {
|
||||
var j = &jobs.ExecJob{}
|
||||
j.InvokeTarget = result.InvokeTarget
|
||||
j.CronExpression = result.CronExpression
|
||||
j.JobId = result.JobId
|
||||
j.Name = result.JobName
|
||||
j.Args = result.Args
|
||||
j.InvokeTarget = data.InvokeTarget
|
||||
j.CronExpression = data.CronExpression
|
||||
j.JobId = data.JobId
|
||||
j.Name = data.JobName
|
||||
j.Args = data.Args
|
||||
data.EntryId, err = jobs.AddJob(j)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user