-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from suyuan32/feat-task-log
Feat: task log
- Loading branch information
Showing
20 changed files
with
1,001 additions
and
304 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import "base.api" | ||
|
||
type ( | ||
// The response data of task log information | TaskLog信息 | ||
TaskLogInfo { | ||
// ID | ||
Id uint64 `json:"id"` | ||
|
||
// StartedAt | ||
StartedAt int64 `json:"startedAt,optional"` | ||
|
||
// FinishedAt | ||
FinishedAt int64 `json:"finishedAt,optional"` | ||
|
||
// Result | ||
Result uint32 `json:"result,optional"` | ||
} | ||
|
||
// The response data of task log list | TaskLog列表数据 | ||
TaskLogListResp { | ||
BaseDataInfo | ||
|
||
// TaskLog list data | TaskLog列表数据 | ||
Data TaskLogListInfo `json:"data"` | ||
} | ||
|
||
// TaskLog list data | TaskLog列表数据 | ||
TaskLogListInfo { | ||
BaseListInfo | ||
|
||
// The API list data | TaskLog列表数据 | ||
Data []TaskLogInfo `json:"data"` | ||
} | ||
|
||
// Get task log list request params | TaskLog列表请求参数 | ||
TaskLogListReq { | ||
PageInfo | ||
|
||
TaskId uint64 `json:"taskId"` | ||
|
||
Result uint32 `json:"result"` | ||
} | ||
|
||
// TaskLog information response | TaskLog信息返回体 | ||
TaskLogInfoResp { | ||
BaseDataInfo | ||
|
||
// TaskLog information | TaskLog数据 | ||
Data TaskLogInfo `json:"data"` | ||
} | ||
) | ||
|
||
@server( | ||
jwt: Auth | ||
group: tasklog | ||
middleware: Authority | ||
) | ||
|
||
service core { | ||
// Create task log information | 创建TaskLog | ||
@handler createTaskLog | ||
post /task_log/create (TaskLogInfo) returns (BaseMsgResp) | ||
|
||
// Update task log information | 更新TaskLog | ||
@handler updateTaskLog | ||
post /task_log/update (TaskLogInfo) returns (BaseMsgResp) | ||
|
||
// Delete task log information | 删除TaskLog信息 | ||
@handler deleteTaskLog | ||
post /task_log/delete (IDsReq) returns (BaseMsgResp) | ||
|
||
// Get task log list | 获取TaskLog列表 | ||
@handler getTaskLogList | ||
post /task_log/list (TaskLogListReq) returns (TaskLogListResp) | ||
|
||
// Get task log by ID | 通过ID获取TaskLog | ||
@handler getTaskLogById | ||
post /task_log (IDReq) returns (TaskLogInfoResp) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,45 @@ | ||
package tasklog | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /task_log/create tasklog CreateTaskLog | ||
// | ||
// Create task log information | 创建TaskLog | ||
// | ||
// Create task log information | 创建TaskLog | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: TaskLogInfo | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func CreateTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.TaskLogInfo | ||
if err := httpx.Parse(r, &req, true); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := tasklog.NewCreateTaskLogLogic(r.Context(), svcCtx) | ||
resp, err := l.CreateTaskLog(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Context(), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
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,45 @@ | ||
package tasklog | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /task_log/delete tasklog DeleteTaskLog | ||
// | ||
// Delete task log information | 删除TaskLog信息 | ||
// | ||
// Delete task log information | 删除TaskLog信息 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: IDsReq | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func DeleteTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.IDsReq | ||
if err := httpx.Parse(r, &req, true); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := tasklog.NewDeleteTaskLogLogic(r.Context(), svcCtx) | ||
resp, err := l.DeleteTaskLog(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Context(), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
api/internal/handler/tasklog/get_task_log_by_id_handler.go
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,45 @@ | ||
package tasklog | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /task_log tasklog GetTaskLogById | ||
// | ||
// Get task log by ID | 通过ID获取TaskLog | ||
// | ||
// Get task log by ID | 通过ID获取TaskLog | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: IDReq | ||
// | ||
// Responses: | ||
// 200: TaskLogInfoResp | ||
|
||
func GetTaskLogByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.IDReq | ||
if err := httpx.Parse(r, &req, true); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := tasklog.NewGetTaskLogByIdLogic(r.Context(), svcCtx) | ||
resp, err := l.GetTaskLogById(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Context(), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
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,45 @@ | ||
package tasklog | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /task_log/list tasklog GetTaskLogList | ||
// | ||
// Get task log list | 获取TaskLog列表 | ||
// | ||
// Get task log list | 获取TaskLog列表 | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: TaskLogListReq | ||
// | ||
// Responses: | ||
// 200: TaskLogListResp | ||
|
||
func GetTaskLogListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.TaskLogListReq | ||
if err := httpx.Parse(r, &req, true); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := tasklog.NewGetTaskLogListLogic(r.Context(), svcCtx) | ||
resp, err := l.GetTaskLogList(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Context(), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
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,45 @@ | ||
package tasklog | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
|
||
"github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" | ||
"github.com/suyuan32/simple-admin-core/api/internal/svc" | ||
"github.com/suyuan32/simple-admin-core/api/internal/types" | ||
) | ||
|
||
// swagger:route post /task_log/update tasklog UpdateTaskLog | ||
// | ||
// Update task log information | 更新TaskLog | ||
// | ||
// Update task log information | 更新TaskLog | ||
// | ||
// Parameters: | ||
// + name: body | ||
// require: true | ||
// in: body | ||
// type: TaskLogInfo | ||
// | ||
// Responses: | ||
// 200: BaseMsgResp | ||
|
||
func UpdateTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.TaskLogInfo | ||
if err := httpx.Parse(r, &req, true); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := tasklog.NewUpdateTaskLogLogic(r.Context(), svcCtx) | ||
resp, err := l.UpdateTaskLog(&req) | ||
if err != nil { | ||
err = svcCtx.Trans.TransError(r.Context(), err) | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
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.