diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 21b2c79a..f2bcfeb2 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-04 07:44:51.372978 +0800 CST m=+0.135701027 +// 2020-05-04 17:53:13.810815 +0800 CST m=+0.105728870 package docs @@ -763,14 +763,14 @@ var doc = `{ }, "/schedules": { "get": { - "description": "Get spider list", + "description": "Get schedule list", "produces": [ "application/json" ], "tags": [ - "spider" + "schedule" ], - "summary": "Get spider list", + "summary": "Get schedule list", "parameters": [ { "type": "string", @@ -778,54 +778,6 @@ 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": { @@ -3090,6 +3042,508 @@ var doc = `{ } } }, + "/tokens": { + "get": { + "description": "token", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Get token", + "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" + } + } + } + }, + "put": { + "description": "token", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Put token", + "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" + } + } + } + } + }, + "/tokens/{id}": { + "delete": { + "description": "Delete token", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Delete token", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "token id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/users": { + "get": { + "description": "Get user list", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Get user list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "data body", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.UserListRequestData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Put user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "reqData body", + "name": "reqData", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.UserRequestData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/users/{id}": { + "get": { + "description": "user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Post user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "user body", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.User" + } + }, + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/variable": { + "put": { + "description": "Put variable", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Put variable", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "reqData body", + "name": "variable", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Variable" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/variable/{id}": { + "post": { + "description": "Post variable", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Post variable", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "reqData body", + "name": "variable", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Variable" + } + }, + { + "type": "string", + "description": "variable id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete variable", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Delete variable", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "variable id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/variables": { + "get": { + "description": "Get variable list", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Get variable list", + "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" + } + } + } + } + }, "/version": { "get": { "description": "Get version", @@ -3669,6 +4123,85 @@ var doc = `{ } } }, + "model.User": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "role": { + "type": "string" + }, + "setting": { + "type": "object", + "$ref": "#/definitions/model.UserSetting" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "model.UserSetting": { + "type": "object", + "properties": { + "ding_talk_robot_webhook": { + "type": "string" + }, + "enabled_notifications": { + "type": "array", + "items": { + "type": "string" + } + }, + "error_regex_pattern": { + "type": "string" + }, + "log_expire_duration": { + "type": "integer" + }, + "max_error_log": { + "type": "integer" + }, + "notification_trigger": { + "type": "string" + }, + "wechat_robot_webhook": { + "type": "string" + } + } + }, + "model.Variable": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "key": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "routes.SpiderFileReqBody": { "type": "object", "properties": { @@ -3716,6 +4249,34 @@ var doc = `{ "type": "integer" } } + }, + "routes.UserListRequestData": { + "type": "object", + "properties": { + "pageNum": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, + "routes.UserRequestData": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "role": { + "type": "string" + }, + "username": { + "type": "string" + } + } } } }` diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 41a0a3ef..bdfc7a72 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -742,14 +742,14 @@ }, "/schedules": { "get": { - "description": "Get spider list", + "description": "Get schedule list", "produces": [ "application/json" ], "tags": [ - "spider" + "schedule" ], - "summary": "Get spider list", + "summary": "Get schedule list", "parameters": [ { "type": "string", @@ -757,54 +757,6 @@ "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": { @@ -3069,6 +3021,508 @@ } } }, + "/tokens": { + "get": { + "description": "token", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Get token", + "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" + } + } + } + }, + "put": { + "description": "token", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Put token", + "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" + } + } + } + } + }, + "/tokens/{id}": { + "delete": { + "description": "Delete token", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Delete token", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "token id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/users": { + "get": { + "description": "Get user list", + "produces": [ + "application/json" + ], + "tags": [ + "token" + ], + "summary": "Get user list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "data body", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.UserListRequestData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Put user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "reqData body", + "name": "reqData", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.UserRequestData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/users/{id}": { + "get": { + "description": "user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Post user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "user body", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.User" + } + }, + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete user", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete user", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/variable": { + "put": { + "description": "Put variable", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Put variable", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "reqData body", + "name": "variable", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Variable" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/variable/{id}": { + "post": { + "description": "Post variable", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Post variable", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "reqData body", + "name": "variable", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Variable" + } + }, + { + "type": "string", + "description": "variable id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete variable", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Delete variable", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "variable id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/variables": { + "get": { + "description": "Get variable list", + "produces": [ + "application/json" + ], + "tags": [ + "variable" + ], + "summary": "Get variable list", + "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" + } + } + } + } + }, "/version": { "get": { "description": "Get version", @@ -3648,6 +4102,85 @@ } } }, + "model.User": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "role": { + "type": "string" + }, + "setting": { + "type": "object", + "$ref": "#/definitions/model.UserSetting" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "model.UserSetting": { + "type": "object", + "properties": { + "ding_talk_robot_webhook": { + "type": "string" + }, + "enabled_notifications": { + "type": "array", + "items": { + "type": "string" + } + }, + "error_regex_pattern": { + "type": "string" + }, + "log_expire_duration": { + "type": "integer" + }, + "max_error_log": { + "type": "integer" + }, + "notification_trigger": { + "type": "string" + }, + "wechat_robot_webhook": { + "type": "string" + } + } + }, + "model.Variable": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "key": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "routes.SpiderFileReqBody": { "type": "object", "properties": { @@ -3695,6 +4228,34 @@ "type": "integer" } } + }, + "routes.UserListRequestData": { + "type": "object", + "properties": { + "pageNum": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, + "routes.UserRequestData": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "role": { + "type": "string" + }, + "username": { + "type": "string" + } + } } } } \ No newline at end of file diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index e14439be..16d6aa18 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -372,6 +372,58 @@ definitions: wait_duration: type: number type: object + model.User: + properties: + _id: + type: string + create_ts: + type: string + email: + type: string + password: + type: string + role: + type: string + setting: + $ref: '#/definitions/model.UserSetting' + type: object + update_ts: + type: string + user_id: + type: string + username: + type: string + type: object + model.UserSetting: + properties: + ding_talk_robot_webhook: + type: string + enabled_notifications: + items: + type: string + type: array + error_regex_pattern: + type: string + log_expire_duration: + type: integer + max_error_log: + type: integer + notification_trigger: + type: string + wechat_robot_webhook: + type: string + type: object + model.Variable: + properties: + _id: + type: string + key: + type: string + remark: + type: string + value: + type: string + type: object routes.SpiderFileReqBody: properties: content: @@ -403,6 +455,24 @@ definitions: pageSize: type: integer type: object + routes.UserListRequestData: + properties: + pageNum: + type: integer + pageSize: + type: integer + type: object + routes.UserRequestData: + properties: + email: + type: string + password: + type: string + role: + type: string + username: + type: string + type: object info: contact: {} license: {} @@ -901,45 +971,13 @@ paths: - project /schedules: get: - description: Get spider list + description: Get schedule 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: @@ -951,9 +989,9 @@ paths: description: Bad Request schema: type: json - summary: Get spider list + summary: Get schedule list tags: - - spider + - schedule put: consumes: - application/json @@ -2458,6 +2496,342 @@ paths: summary: Delete task tags: - task + /tokens: + get: + description: token + 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: Get token + tags: + - token + put: + description: token + 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 token + tags: + - token + /tokens/{id}: + delete: + description: Delete token + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: token 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 token + tags: + - token + /users: + get: + description: Get user list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: data body + in: body + name: data + required: true + schema: + $ref: '#/definitions/routes.UserListRequestData' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get user list + tags: + - token + put: + description: Put user + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: reqData body + in: body + name: reqData + required: true + schema: + $ref: '#/definitions/routes.UserRequestData' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Put user + tags: + - user + /users/{id}: + delete: + description: Delete user + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: user 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 user + tags: + - user + get: + description: user + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: user 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 user + tags: + - user + post: + description: Post user + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: user body + in: body + name: item + required: true + schema: + $ref: '#/definitions/model.User' + type: object + - description: user 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: Post user + tags: + - user + /variable: + put: + description: Put variable + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: reqData body + in: body + name: variable + required: true + schema: + $ref: '#/definitions/model.Variable' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Put variable + tags: + - variable + /variable/{id}: + delete: + description: Delete variable + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: variable 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 variable + tags: + - variable + post: + description: Post variable + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: reqData body + in: body + name: variable + required: true + schema: + $ref: '#/definitions/model.Variable' + type: object + - description: variable 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: Post variable + tags: + - variable + /variables: + get: + description: Get variable list + 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: Get variable list + tags: + - variable /version: get: description: Get version diff --git a/backend/routes/token.go b/backend/routes/token.go index 57ad5990..8ad25aed 100644 --- a/backend/routes/token.go +++ b/backend/routes/token.go @@ -9,6 +9,14 @@ import ( "time" ) +// @Summary Get token +// @Description token +// @Tags token +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tokens [get] func GetTokens(c *gin.Context) { u := services.GetCurrentUser(c) @@ -25,6 +33,14 @@ func GetTokens(c *gin.Context) { }) } +// @Summary Put token +// @Description token +// @Tags token +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tokens [put] func PutToken(c *gin.Context) { u := services.GetCurrentUser(c) @@ -53,6 +69,15 @@ func PutToken(c *gin.Context) { }) } +// @Summary Delete token +// @Description Delete token +// @Tags token +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "token id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /tokens/{id} [delete] func DeleteToken(c *gin.Context) { id := c.Param("id") diff --git a/backend/routes/user.go b/backend/routes/user.go index 56a8cb2c..a195cd75 100644 --- a/backend/routes/user.go +++ b/backend/routes/user.go @@ -25,6 +25,15 @@ type UserRequestData struct { Email string `json:"email"` } +// @Summary Get user +// @Description user +// @Tags user +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "user id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /users/{id} [get] func GetUser(c *gin.Context) { id := c.Param("id") @@ -41,6 +50,15 @@ func GetUser(c *gin.Context) { }) } +// @Summary Get user list +// @Description Get user list +// @Tags token +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param data body routes.UserListRequestData true "data body" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /users [get] func GetUserList(c *gin.Context) { // 绑定数据 data := UserListRequestData{} @@ -82,6 +100,15 @@ func GetUserList(c *gin.Context) { }) } +// @Summary Put user +// @Description Put user +// @Tags user +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param reqData body routes.UserRequestData true "reqData body" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /users [put] func PutUser(c *gin.Context) { // 绑定请求数据 var reqData UserRequestData @@ -115,6 +142,16 @@ func PutUser(c *gin.Context) { }) } +// @Summary Post user +// @Description Post user +// @Tags user +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param item body model.User true "user body" +// @Param id path string true "user id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /users/{id} [post] func PostUser(c *gin.Context) { id := c.Param("id") @@ -143,6 +180,15 @@ func PostUser(c *gin.Context) { }) } +// @Summary Delete user +// @Description Delete user +// @Tags user +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "user id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /users/{id} [delete] func DeleteUser(c *gin.Context) { id := c.Param("id") diff --git a/backend/routes/variable.go b/backend/routes/variable.go index c35c16ab..c55652ca 100644 --- a/backend/routes/variable.go +++ b/backend/routes/variable.go @@ -8,6 +8,16 @@ import ( ) // 新增 + +// @Summary Put variable +// @Description Put variable +// @Tags variable +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param variable body model.Variable true "reqData body" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /variable [put] func PutVariable(c *gin.Context) { var variable model.Variable if err := c.ShouldBindJSON(&variable); err != nil { @@ -22,6 +32,17 @@ func PutVariable(c *gin.Context) { } // 修改 + +// @Summary Post variable +// @Description Post variable +// @Tags variable +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param variable body model.Variable true "reqData body" +// @Param id path string true "variable id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /variable/{id} [post] func PostVariable(c *gin.Context) { var id = c.Param("id") var variable model.Variable @@ -38,6 +59,16 @@ func PostVariable(c *gin.Context) { } // 删除 + +// @Summary Delete variable +// @Description Delete variable +// @Tags variable +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "variable id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /variable/{id} [delete] func DeleteVariable(c *gin.Context) { var idStr = c.Param("id") var id = bson.ObjectIdHex(idStr) @@ -56,6 +87,15 @@ func DeleteVariable(c *gin.Context) { } // 列表 + +// @Summary Get variable list +// @Description Get variable list +// @Tags variable +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /variables [get] func GetVariableList(c *gin.Context) { list := model.GetVariableList() HandleSuccessData(c, list)