-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtasks_v1_controller.go
More file actions
151 lines (139 loc) · 4.53 KB
/
tasks_v1_controller.go
File metadata and controls
151 lines (139 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package controllers
import (
"net/http"
"github.com/colibriproject-dev/colibri-sdk-go/pkg/web/restserver"
"github.com/devfullcycle/fc4-arq-multi-tenancy/taskflow-service/src/domain/usecases"
)
type TasksV1Controller struct {
GetAllTaskUsecase usecases.IGetAllTaskUsecase
CreateTaskUsecase usecases.ICreateTaskUsecase
UpdateTaskUsecase usecases.IUpdateTaskUsecase
UpdateTaskStatusUsecase usecases.IUpdateTaskStatusUsecase
DeleteTaskUsecase usecases.IDeleteTaskUsecase
GetAllPaginatedTaskHistoryUsecase usecases.IGetAllPaginatedTaskHistoryUsecase
}
func NewTasksV1Controller() *TasksV1Controller {
return &TasksV1Controller{
GetAllTaskUsecase: usecases.NewGetAllTaskUsecase(),
CreateTaskUsecase: usecases.NewCreateTaskUsecase(),
UpdateTaskUsecase: usecases.NewUpdateTaskUsecase(),
UpdateTaskStatusUsecase: usecases.NewUpdateTaskStatusUsecase(),
DeleteTaskUsecase: usecases.NewDeleteTaskUsecase(),
GetAllPaginatedTaskHistoryUsecase: usecases.NewGetAllPaginatedTaskHistoryUsecase(),
}
}
func (c *TasksV1Controller) Routes() []restserver.Route {
const baseURI = "v1/tasks"
const baseURIWithId = baseURI + "/{id}"
return []restserver.Route{
{
URI: baseURI,
Method: http.MethodGet,
Function: c.GetAllTask,
Prefix: restserver.AuthenticatedApi,
},
{
URI: baseURI,
Method: http.MethodPost,
Function: c.CreateTask,
Prefix: restserver.AuthenticatedApi,
},
{
URI: baseURIWithId,
Method: http.MethodPut,
Function: c.UpdateTask,
Prefix: restserver.AuthenticatedApi,
},
{
URI: baseURIWithId + "/status",
Method: http.MethodPatch,
Function: c.UpdateTaskStatus,
Prefix: restserver.AuthenticatedApi,
},
{
URI: baseURIWithId,
Method: http.MethodDelete,
Function: c.DeleteTask,
Prefix: restserver.AuthenticatedApi,
},
{
URI: baseURIWithId + "/history",
Method: http.MethodGet,
Function: c.GetAllPaginatedTaskHistory,
Prefix: restserver.AuthenticatedApi,
},
}
}
// @Summary Retornar todas as tarefas
// @Tags tasks
// @Accept json
// @Produce json
// @Success 200 {array} models.Task
// @Failure 500
// @Param title query string false "título da tarefa"
// @Router /api/v1/tasks [get]
func (c *TasksV1Controller) GetAllTask(wctx restserver.WebContext) {
wctx.EmptyResponse(http.StatusNotImplemented)
}
// @Summary Criar uma nova tarefa
// @Tags tasks
// @Accept json
// @Produce json
// @Success 201 {object} models.TaskCreated
// @Failure 400
// @Failure 500
// @Param task body models.TaskCreate true "Dados da tarefa a ser criada"
// @Router /api/v1/tasks [post]
func (c *TasksV1Controller) CreateTask(wctx restserver.WebContext) {
wctx.EmptyResponse(http.StatusNotImplemented)
}
// @Summary Atualizar uma tarefa
// @Tags tasks
// @Accept json
// @Produce json
// @Success 204
// @Failure 400
// @Failure 500
// @Param id path string true "ID da tarefa a ser alterada"
// @Param task body models.TaskUpdate true "Dados da tarefa a serem atualizados"
// @Router /api/v1/tasks/{id} [put]
func (c *TasksV1Controller) UpdateTask(wctx restserver.WebContext) {
wctx.EmptyResponse(http.StatusNotImplemented)
}
// @Summary Atualizar o status de uma tarefa
// @Tags tasks
// @Accept json
// @Produce json
// @Success 204
// @Failure 400
// @Failure 500
// @Param id path string true "ID da tarefa a ser alterada"
// @Param taskStatus body models.TaskStatusUpdate true "Dados do status da tarefa a serem atualizados"
// @Router /api/v1/tasks/{id}/status [patch]
func (c *TasksV1Controller) UpdateTaskStatus(wctx restserver.WebContext) {
wctx.EmptyResponse(http.StatusNotImplemented)
}
// @Summary Deletar uma tarefa
// @Tags tasks
// @Accept json
// @Produce json
// @Success 204
// @Failure 400
// @Failure 500
// @Param id path string true "ID da tarefa a ser deletada"
// @Router /api/v1/tasks/{id} [delete]
func (c *TasksV1Controller) DeleteTask(wctx restserver.WebContext) {
wctx.EmptyResponse(http.StatusNotImplemented)
}
// @Summary Retornar histórico de uma determinada tarefa
// @Tags tasks
// @Accept json
// @Produce json
// @Success 200 {object} models.TaskHistoryPage
// @Failure 500
// @Param page query uint16 true "página" minimum(1) default(1)
// @Param pageSize query uint16 true "tamanho da página" minimum(1) default(10)
// @Router /api/v1/tasks/{id}/history [get]
func (c *TasksV1Controller) GetAllPaginatedTaskHistory(wctx restserver.WebContext) {
wctx.EmptyResponse(http.StatusNotImplemented)
}