Skip to content

Commit

Permalink
Merge pull request #84 from suyuan32/feat-task-log
Browse files Browse the repository at this point in the history
Feat: task log
  • Loading branch information
suyuan32 authored Mar 19, 2023
2 parents 27b555c + 233024b commit 5a3ed08
Show file tree
Hide file tree
Showing 20 changed files with 1,001 additions and 304 deletions.
3 changes: 2 additions & 1 deletion api/desc/all.api
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ import "department.api"
import "position.api"
import "dictionary_detail.api"
import "menu_param.api"
import "task.api"
import "task.api"
import "task_log.api"
79 changes: 79 additions & 0 deletions api/desc/task_log.api
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)
}
35 changes: 35 additions & 0 deletions api/internal/handler/routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions api/internal/handler/tasklog/create_task_log_handler.go
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)
}
}
}
45 changes: 45 additions & 0 deletions api/internal/handler/tasklog/delete_task_log_handler.go
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 api/internal/handler/tasklog/get_task_log_by_id_handler.go
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)
}
}
}
45 changes: 45 additions & 0 deletions api/internal/handler/tasklog/get_task_log_list_handler.go
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)
}
}
}
45 changes: 45 additions & 0 deletions api/internal/handler/tasklog/update_task_log_handler.go
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)
}
}
}
7 changes: 6 additions & 1 deletion api/internal/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@
"updateTask": "Update the task",
"deleteTask": "Delete tasks",
"getTaskList": "Get task list",
"getTaskById": "Get task by ID"
"getTaskById": "Get task by ID",
"createTaskLog": "Create a task log",
"updateTaskLog": "Update the task log",
"deleteTaskLog": "Delete task logs",
"getTaskListLog": "Get task log list",
"getTaskByIdLog": "Get task log by ID"
},
"route": {
"dashboard": "Dashboard",
Expand Down
7 changes: 6 additions & 1 deletion api/internal/i18n/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@
"updateTask": "更新任务",
"deleteTask": "删除一个任务",
"getTaskList": "获取任务列表",
"getTaskById": "通过ID获取任务信息"
"getTaskById": "通过ID获取任务信息",
"createTaskLog": "创建任务日志",
"updateTaskLog": "更新任务日志",
"deleteTaskLog": "删除任务日志",
"getTaskListLog": "获取任务日志列表",
"getTaskByIdLog": "通过ID获取任务日志"
},
"route": {
"dashboard": "控制台",
Expand Down
Loading

0 comments on commit 5a3ed08

Please sign in to comment.