From 83357f3100df575d97c2ae944db07c717c20b21b Mon Sep 17 00:00:00 2001 From: hantmac Date: Sun, 3 May 2020 19:50:35 +0800 Subject: [PATCH 1/2] add swagger docs for 'tasks' --- backend/docs/docs.go | 535 +++++++++++++++++++++++++++++++++++++- backend/docs/swagger.json | 533 +++++++++++++++++++++++++++++++++++++ backend/docs/swagger.yaml | 355 +++++++++++++++++++++++++ backend/routes/task.go | 111 ++++++++ 4 files changed, 1533 insertions(+), 1 deletion(-) diff --git a/backend/docs/docs.go b/backend/docs/docs.go index bd40f33a..0a3c620d 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-05-01 23:10:59.173446 +0800 CST m=+0.074737526 +// 2020-05-03 19:45:55.093832 +0800 CST m=+0.085718059 package docs @@ -2172,6 +2172,505 @@ var doc = `{ } } }, + "/task/{id}": { + "delete": { + "description": "Delete task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Delete task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks": { + "get": { + "description": "Get task list", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "req data", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.TaskListRequestData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Put task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete tasks", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Delete tasks", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}": { + "get": { + "description": "Get task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/cancel": { + "post": { + "description": "Cancel task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Cancel task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/error-log": { + "delete": { + "description": "Get task error log", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task error log", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/log": { + "delete": { + "description": "Get task log", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task log", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/restart": { + "post": { + "description": "Restart task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Restart task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/results": { + "get": { + "description": "Get task list", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "req data", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.TaskResultsRequestData" + } + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/results/download": { + "get": { + "description": "Get task results", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task results", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks_by_status": { + "delete": { + "description": "Delete task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Delete task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task status", + "name": "status", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/version": { "get": { "description": "Get version", @@ -2764,6 +3263,40 @@ var doc = `{ "type": "string" } } + }, + "routes.TaskListRequestData": { + "type": "object", + "properties": { + "nodeId": { + "type": "string" + }, + "pageNum": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "scheduleId": { + "type": "string" + }, + "spiderId": { + "type": "string" + }, + "status": { + "type": "string" + } + } + }, + "routes.TaskResultsRequestData": { + "type": "object", + "properties": { + "pageNum": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } } } }` diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 8ed42bcd..f82d1ba8 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -2151,6 +2151,505 @@ } } }, + "/task/{id}": { + "delete": { + "description": "Delete task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Delete task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks": { + "get": { + "description": "Get task list", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "req data", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.TaskListRequestData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Put task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete tasks", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Delete tasks", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}": { + "get": { + "description": "Get task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/cancel": { + "post": { + "description": "Cancel task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Cancel task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/error-log": { + "delete": { + "description": "Get task error log", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task error log", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/log": { + "delete": { + "description": "Get task log", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task log", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/restart": { + "post": { + "description": "Restart task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Restart task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/results": { + "get": { + "description": "Get task list", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "req data", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.TaskResultsRequestData" + } + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks/{id}/results/download": { + "get": { + "description": "Get task results", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Get task results", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/tasks_by_status": { + "delete": { + "description": "Delete task", + "produces": [ + "application/json" + ], + "tags": [ + "task" + ], + "summary": "Delete task", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "task status", + "name": "status", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/version": { "get": { "description": "Get version", @@ -2743,6 +3242,40 @@ "type": "string" } } + }, + "routes.TaskListRequestData": { + "type": "object", + "properties": { + "nodeId": { + "type": "string" + }, + "pageNum": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "scheduleId": { + "type": "string" + }, + "spiderId": { + "type": "string" + }, + "status": { + "type": "string" + } + } + }, + "routes.TaskResultsRequestData": { + "type": "object", + "properties": { + "pageNum": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } } } } \ No newline at end of file diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 0ced87e0..129aa4a1 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -381,6 +381,28 @@ definitions: path: type: string type: object + routes.TaskListRequestData: + properties: + nodeId: + type: string + pageNum: + type: integer + pageSize: + type: integer + scheduleId: + type: string + spiderId: + type: string + status: + type: string + type: object + routes.TaskResultsRequestData: + properties: + pageNum: + type: integer + pageSize: + type: integer + type: object info: contact: {} license: {} @@ -1822,6 +1844,339 @@ paths: summary: Upload spider by id tags: - spider + /task/{id}: + delete: + description: Delete task + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete task + tags: + - task + /tasks: + delete: + description: Delete tasks + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete tasks + tags: + - task + get: + description: Get task list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: req data + in: body + name: data + required: true + schema: + $ref: '#/definitions/routes.TaskListRequestData' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task list + tags: + - task + put: + description: Put task + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Put task + tags: + - task + /tasks/{id}: + get: + description: Get task + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task + tags: + - task + /tasks/{id}/cancel: + post: + description: Cancel task + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Cancel task + tags: + - task + /tasks/{id}/error-log: + delete: + description: Get task error log + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task error log + tags: + - task + /tasks/{id}/log: + delete: + description: Get task log + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task log + tags: + - task + /tasks/{id}/restart: + post: + description: Restart task + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Restart task + tags: + - task + /tasks/{id}/results: + get: + description: Get task list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: req data + in: body + name: data + required: true + schema: + $ref: '#/definitions/routes.TaskResultsRequestData' + type: object + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task list + tags: + - task + /tasks/{id}/results/download: + get: + description: Get task results + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task results + tags: + - task + /tasks_by_status: + delete: + description: Delete task + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: task status + in: query + name: status + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete task + tags: + - task /version: get: description: Get version diff --git a/backend/routes/task.go b/backend/routes/task.go index 2484b300..6f3f2182 100644 --- a/backend/routes/task.go +++ b/backend/routes/task.go @@ -26,6 +26,15 @@ type TaskResultsRequestData struct { PageSize int `form:"page_size"` } +// @Summary Get task list +// @Description Get task list +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param data body routes.TaskListRequestData true "req data" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks [get] func GetTaskList(c *gin.Context) { // 绑定数据 data := TaskListRequestData{} @@ -81,6 +90,15 @@ func GetTaskList(c *gin.Context) { }) } +// @Summary Get task +// @Description Get task +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id} [get] func GetTask(c *gin.Context) { id := c.Param("id") @@ -92,6 +110,14 @@ func GetTask(c *gin.Context) { HandleSuccessData(c, result) } +// @Summary Put task +// @Description Put task +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks [put] func PutTask(c *gin.Context) { type TaskRequestBody struct { SpiderId bson.ObjectId `json:"spider_id"` @@ -177,6 +203,15 @@ func PutTask(c *gin.Context) { HandleSuccessData(c, taskIds) } +// @Summary Delete task +// @Description Delete task +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param status query string true "task status" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks_by_status [delete] func DeleteTaskByStatus(c *gin.Context) { status := c.Query("status") @@ -196,6 +231,15 @@ func DeleteTaskByStatus(c *gin.Context) { } // 删除多个任务 + +// @Summary Delete tasks +// @Description Delete tasks +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks [delete] func DeleteSelectedTask(c *gin.Context) { ids := make(map[string][]string) if err := c.ShouldBindJSON(&ids); err != nil { @@ -217,6 +261,16 @@ func DeleteSelectedTask(c *gin.Context) { } // 删除单个任务 + +// @Summary Delete task +// @Description Delete task +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /task/{id} [delete] func DeleteTask(c *gin.Context) { id := c.Param("id") @@ -233,6 +287,15 @@ func DeleteTask(c *gin.Context) { HandleSuccess(c) } +// @Summary Get task log +// @Description Get task log +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id}/log [delete] func GetTaskLog(c *gin.Context) { type RequestData struct { PageNum int `form:"page_num"` @@ -258,6 +321,15 @@ func GetTaskLog(c *gin.Context) { }) } +// @Summary Get task error log +// @Description Get task error log +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id}/error-log [delete] func GetTaskErrorLog(c *gin.Context) { id := c.Param("id") u := services.GetCurrentUser(c) @@ -273,6 +345,16 @@ func GetTaskErrorLog(c *gin.Context) { }) } +// @Summary Get task list +// @Description Get task list +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param data body routes.TaskResultsRequestData true "req data" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id}/results [get] func GetTaskResults(c *gin.Context) { id := c.Param("id") @@ -305,6 +387,16 @@ func GetTaskResults(c *gin.Context) { }) } + +// @Summary Get task results +// @Description Get task results +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id}/results/download [get] func DownloadTaskResultsCsv(c *gin.Context) { id := c.Param("id") @@ -374,6 +466,16 @@ func DownloadTaskResultsCsv(c *gin.Context) { c.Data(http.StatusOK, "text/csv", bytesBuffer.Bytes()) } + +// @Summary Cancel task +// @Description Cancel task +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id}/cancel [post] func CancelTask(c *gin.Context) { id := c.Param("id") @@ -384,6 +486,15 @@ func CancelTask(c *gin.Context) { HandleSuccess(c) } +// @Summary Restart task +// @Description Restart task +// @Tags task +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "task id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tasks/{id}/restart [post] func RestartTask(c *gin.Context) { id := c.Param("id") From eee81c57c6c7954dcf0f6d63b761bde9cb1c9671 Mon Sep 17 00:00:00 2001 From: hantmac Date: Mon, 4 May 2020 07:48:02 +0800 Subject: [PATCH 2/2] add swagger for system --- backend/docs/docs.go | 427 +++++++++++++++++++++++++++++++++++++- backend/docs/swagger.json | 425 ++++++++++++++++++++++++++++++++++++- backend/docs/swagger.yaml | 287 ++++++++++++++++++++++++- backend/routes/system.go | 77 +++++++ 4 files changed, 1206 insertions(+), 10 deletions(-) diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 0a3c620d..21b2c79a 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-05-03 19:45:55.093832 +0800 CST m=+0.085718059 +// 2020-05-04 07:44:51.372978 +0800 CST m=+0.135701027 package docs @@ -186,6 +186,279 @@ var doc = `{ } } }, + "/nodes/{id}/deps": { + "get": { + "description": "Get dep list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get dep list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "dep name", + "name": "dep_name", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/deps/install": { + "post": { + "description": "Install dep", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Install dep", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/deps/installed": { + "get": { + "description": "Get installed dep list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get installed dep list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/deps/uninstall": { + "post": { + "description": "Uninstall dep", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Uninstall dep", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/langs": { + "get": { + "description": "Get language list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get language list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/langs/install": { + "post": { + "description": "Install language", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Install language", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/nodes/{id}/system": { "get": { "description": "Get system info", @@ -490,14 +763,14 @@ var doc = `{ }, "/schedules": { "get": { - "description": "Get schedule list", + "description": "Get spider list", "produces": [ "application/json" ], "tags": [ - "schedule" + "spider" ], - "summary": "Get schedule list", + "summary": "Get spider list", "parameters": [ { "type": "string", @@ -505,6 +778,54 @@ var doc = `{ "name": "Authorization", "in": "header", "required": true + }, + { + "type": "string", + "description": "page num", + "name": "page_num", + "in": "query" + }, + { + "type": "string", + "description": "page size", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "keyword", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "description": "project_id", + "name": "project_id", + "in": "query" + }, + { + "type": "string", + "description": "type", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "sort_key", + "name": "sort_key", + "in": "query" + }, + { + "type": "string", + "description": "sort_direction", + "name": "sort_direction", + "in": "query" + }, + { + "type": "string", + "description": "owner_type", + "name": "owner_type", + "in": "query" } ], "responses": { @@ -2172,6 +2493,104 @@ var doc = `{ } } }, + "/system/deps/": { + "get": { + "description": "Get all dep list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get all dep list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "dep name", + "name": "dep_nane", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/system/deps/{lang}/{dep_name}/json": { + "get": { + "description": "Get dep json", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get dep json", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "dep name", + "name": "dep_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/task/{id}": { "delete": { "description": "Delete task", diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index f82d1ba8..41a0a3ef 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -165,6 +165,279 @@ } } }, + "/nodes/{id}/deps": { + "get": { + "description": "Get dep list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get dep list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "dep name", + "name": "dep_name", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/deps/install": { + "post": { + "description": "Install dep", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Install dep", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/deps/installed": { + "get": { + "description": "Get installed dep list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get installed dep list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/deps/uninstall": { + "post": { + "description": "Uninstall dep", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Uninstall dep", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/langs": { + "get": { + "description": "Get language list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get language list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/langs/install": { + "post": { + "description": "Install language", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Install language", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/nodes/{id}/system": { "get": { "description": "Get system info", @@ -469,14 +742,14 @@ }, "/schedules": { "get": { - "description": "Get schedule list", + "description": "Get spider list", "produces": [ "application/json" ], "tags": [ - "schedule" + "spider" ], - "summary": "Get schedule list", + "summary": "Get spider list", "parameters": [ { "type": "string", @@ -484,6 +757,54 @@ "name": "Authorization", "in": "header", "required": true + }, + { + "type": "string", + "description": "page num", + "name": "page_num", + "in": "query" + }, + { + "type": "string", + "description": "page size", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "keyword", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "description": "project_id", + "name": "project_id", + "in": "query" + }, + { + "type": "string", + "description": "type", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "sort_key", + "name": "sort_key", + "in": "query" + }, + { + "type": "string", + "description": "sort_direction", + "name": "sort_direction", + "in": "query" + }, + { + "type": "string", + "description": "owner_type", + "name": "owner_type", + "in": "query" } ], "responses": { @@ -2151,6 +2472,104 @@ } } }, + "/system/deps/": { + "get": { + "description": "Get all dep list", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get all dep list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "dep name", + "name": "dep_nane", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/system/deps/{lang}/{dep_name}/json": { + "get": { + "description": "Get dep json", + "produces": [ + "application/json" + ], + "tags": [ + "system" + ], + "summary": "Get dep json", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "language", + "name": "lang", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "dep name", + "name": "dep_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/task/{id}": { "delete": { "description": "Delete task", diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 129aa4a1..e14439be 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -514,6 +514,189 @@ paths: summary: Post node tags: - node + /nodes/{id}/deps: + get: + description: Get dep list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + - description: language + in: query + name: lang + required: true + type: string + - description: dep name + in: query + name: dep_name + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get dep list + tags: + - system + /nodes/{id}/deps/install: + post: + description: Install dep + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Install dep + tags: + - system + /nodes/{id}/deps/installed: + get: + description: Get installed dep list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + - description: language + in: query + name: lang + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get installed dep list + tags: + - system + /nodes/{id}/deps/uninstall: + post: + description: Uninstall dep + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Uninstall dep + tags: + - system + /nodes/{id}/langs: + get: + description: Get language list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get language list + tags: + - system + /nodes/{id}/langs/install: + post: + description: Install language + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Install language + tags: + - system /nodes/{id}/system: get: description: Get system info @@ -718,13 +901,45 @@ paths: - project /schedules: get: - description: Get schedule list + description: Get spider list parameters: - description: Authorization token in: header name: Authorization required: true type: string + - description: page num + in: query + name: page_num + type: string + - description: page size + in: query + name: page_size + type: string + - description: keyword + in: query + name: keyword + type: string + - description: project_id + in: query + name: project_id + type: string + - description: type + in: query + name: type + type: string + - description: sort_key + in: query + name: sort_key + type: string + - description: sort_direction + in: query + name: sort_direction + type: string + - description: owner_type + in: query + name: owner_type + type: string produces: - application/json responses: @@ -736,9 +951,9 @@ paths: description: Bad Request schema: type: json - summary: Get schedule list + summary: Get spider list tags: - - schedule + - spider put: consumes: - application/json @@ -1844,6 +2059,72 @@ paths: summary: Upload spider by id tags: - spider + /system/deps/: + get: + description: Get all dep list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: language + in: path + name: lang + required: true + type: string + - description: dep name + in: query + name: dep_nane + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get all dep list + tags: + - system + /system/deps/{lang}/{dep_name}/json: + get: + description: Get dep json + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: language + in: path + name: lang + required: true + type: string + - description: dep name + in: path + name: dep_name + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get dep json + tags: + - system /task/{id}: delete: description: Delete task diff --git a/backend/routes/system.go b/backend/routes/system.go index 2caff7e4..5f3ab7c5 100644 --- a/backend/routes/system.go +++ b/backend/routes/system.go @@ -11,6 +11,15 @@ import ( "strings" ) +// @Summary Get language list +// @Description Get language list +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/langs [get] func GetLangList(c *gin.Context) { nodeId := c.Param("id") c.JSON(http.StatusOK, Response{ @@ -20,6 +29,17 @@ func GetLangList(c *gin.Context) { }) } +// @Summary Get dep list +// @Description Get dep list +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "node id" +// @Param lang query string true "language" +// @Param dep_name query string true "dep name" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/deps [get] func GetDepList(c *gin.Context) { nodeId := c.Param("id") lang := c.Query("lang") @@ -52,6 +72,16 @@ func GetDepList(c *gin.Context) { }) } +// @Summary Get installed dep list +// @Description Get installed dep list +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "node id" +// @Param lang query string true "language" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/deps/installed [get] func GetInstalledDepList(c *gin.Context) { nodeId := c.Param("id") lang := c.Query("lang") @@ -79,6 +109,16 @@ func GetInstalledDepList(c *gin.Context) { }) } +// @Summary Get all dep list +// @Description Get all dep list +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param lang path string true "language" +// @Param dep_nane query string true "dep name" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /system/deps/:lang [get] func GetAllDepList(c *gin.Context) { lang := c.Param("lang") depName := c.Query("dep_name") @@ -121,6 +161,15 @@ func GetAllDepList(c *gin.Context) { }) } +// @Summary Install dep +// @Description Install dep +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/deps/install [Post] func InstallDep(c *gin.Context) { type ReqBody struct { Lang string `json:"lang"` @@ -153,6 +202,15 @@ func InstallDep(c *gin.Context) { }) } +// @Summary Uninstall dep +// @Description Uninstall dep +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/deps/uninstall [Post] func UninstallDep(c *gin.Context) { type ReqBody struct { Lang string `json:"lang"` @@ -184,6 +242,16 @@ func UninstallDep(c *gin.Context) { }) } +// @Summary Get dep json +// @Description Get dep json +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param lang path string true "language" +// @Param dep_name path string true "dep name" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /system/deps/{lang}/{dep_name}/json [get] func GetDepJson(c *gin.Context) { depName := c.Param("dep_name") lang := c.Param("lang") @@ -209,6 +277,15 @@ func GetDepJson(c *gin.Context) { }) } +// @Summary Install language +// @Description Install language +// @Tags system +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/langs/install [Post] func InstallLang(c *gin.Context) { type ReqBody struct { Lang string `json:"lang"`