forked from dushixiang/next-terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dushixiang
committed
Feb 28, 2021
1 parent
5ea00d8
commit 1b8ecef
Showing
10 changed files
with
862 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/labstack/echo/v4" | ||
"next-terminal/pkg/model" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func JobCreateEndpoint(c echo.Context) error { | ||
var item model.Job | ||
if err := c.Bind(&item); err != nil { | ||
return err | ||
} | ||
|
||
if err := model.CreateNewJob(&item); err != nil { | ||
return err | ||
} | ||
return Success(c, "") | ||
} | ||
|
||
func JobPagingEndpoint(c echo.Context) error { | ||
pageIndex, _ := strconv.Atoi(c.QueryParam("pageIndex")) | ||
pageSize, _ := strconv.Atoi(c.QueryParam("pageSize")) | ||
name := c.QueryParam("name") | ||
status := c.QueryParam("status") | ||
|
||
items, total, err := model.FindPageJob(pageIndex, pageSize, name, status) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return Success(c, H{ | ||
"total": total, | ||
"items": items, | ||
}) | ||
} | ||
|
||
func JobUpdateEndpoint(c echo.Context) error { | ||
id := c.Param("id") | ||
|
||
var item model.Job | ||
if err := c.Bind(&item); err != nil { | ||
return err | ||
} | ||
|
||
if err := model.UpdateJobById(&item, id); err != nil { | ||
return err | ||
} | ||
|
||
return Success(c, nil) | ||
} | ||
|
||
func JobChangeStatusEndpoint(c echo.Context) error { | ||
id := c.Param("id") | ||
status := c.QueryParam("status") | ||
if err := model.ChangeJobStatusById(id, status); err != nil { | ||
return err | ||
} | ||
return Success(c, "") | ||
} | ||
|
||
func JobDeleteEndpoint(c echo.Context) error { | ||
ids := c.Param("id") | ||
|
||
split := strings.Split(ids, ",") | ||
for i := range split { | ||
jobId := split[i] | ||
if err := model.DeleteJobById(jobId); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return Success(c, nil) | ||
} | ||
|
||
func JobGetEndpoint(c echo.Context) error { | ||
id := c.Param("id") | ||
|
||
item, err := model.FindJobById(id) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return Success(c, item) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.