63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
package backend
|
|
|
|
import (
|
|
"cron_admin/app/constants/errorcode"
|
|
"cron_admin/app/http/controllers"
|
|
"cron_admin/app/http/entities/backend"
|
|
cmd_services "cron_admin/app/services/cmd_service"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func CmdList(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdListRequest)
|
|
count, list, err := cmd_services.GetListByWhere(request, request.Page, request.Limit)
|
|
if err != nil {
|
|
controllers.HandRes(c, nil, errorcode.NotFound)
|
|
} else {
|
|
cmdList, err := cmd_services.ListToRep(list)
|
|
controllers.HandRes(c, gin.H{"data": cmdList, "count": count}, err)
|
|
}
|
|
}
|
|
|
|
func CmdAdd(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdAddRequest)
|
|
err := cmd_services.Add(request)
|
|
controllers.HandRes(c, nil, err)
|
|
}
|
|
|
|
func CmdEdit(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdEditRequest)
|
|
err := cmd_services.Edit(request)
|
|
controllers.HandRes(c, nil, err)
|
|
}
|
|
|
|
func CmdDel(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdDeleteRequest)
|
|
err := cmd_services.Del(request)
|
|
controllers.HandRes(c, nil, err)
|
|
}
|
|
|
|
func CmdStop(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdStopRequest)
|
|
err := cmd_services.Stop(request)
|
|
controllers.HandRes(c, nil, err)
|
|
}
|
|
|
|
func CmdStart(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdStartRequest)
|
|
err := cmd_services.Start(request)
|
|
controllers.HandRes(c, nil, err)
|
|
}
|
|
|
|
func CmdTestRead(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdTestReadRequest)
|
|
result, time_duration, err := cmd_services.TestRead(request)
|
|
controllers.HandRes(c, gin.H{"result": result, "time_duration": time_duration}, err)
|
|
}
|
|
|
|
func CmdTestWrite(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.CmdTestWriteRequest)
|
|
time_duration, err := cmd_services.TestWrite(request)
|
|
controllers.HandRes(c, gin.H{"time_duration": time_duration}, err)
|
|
}
|