From 399ee75183e3e42d255d7b6b40072e2caf5b6ebd Mon Sep 17 00:00:00 2001 From: luoer Date: Wed, 18 Oct 2023 17:52:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/stack.yaml | 40 + public/assets/loading.svg | 3 +- scripts/openapi/12.json | 1796 +++++++++++++++ scripts/openapi/e.ts | 75 + scripts/openapi/index.ts | 5 +- scripts/openapi/openapi.json | 1245 +++++++---- scripts/openapi/openapi1.json | 3858 +++++++++++++++++++++++++++++++++ scripts/openapi/t.ts | 11 + tsconfig.node.json | 2 +- 9 files changed, 6555 insertions(+), 480 deletions(-) create mode 100644 .gitea/stack.yaml create mode 100644 scripts/openapi/12.json create mode 100644 scripts/openapi/e.ts create mode 100644 scripts/openapi/openapi1.json create mode 100644 scripts/openapi/t.ts diff --git a/.gitea/stack.yaml b/.gitea/stack.yaml new file mode 100644 index 0000000..5e2ce65 --- /dev/null +++ b/.gitea/stack.yaml @@ -0,0 +1,40 @@ +version: '3' + +services: + server: + image: git.dev.juetan.cn/juetan/server:latest + networks: + - public + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [node.role == manager] + labels: + - traefik.enable=true + - traefik.http.routers.nest.rule=Host(`nest.dev.juetan.cn`) && PathPrefix(`/api`, `/upload`) + - traefik.http.routers.nest.entrypoints=websecure + - traefik.http.routers.nest.tls=true + - traefik.http.routers.nest.tls.certresolver=acmer + - traefik.http.services.nest1.loadbalancer.server.port=3030 + + web: + image: git.dev.juetan.cn/juetan/web:latest + networks: + - public + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [node.role == manager] + labels: + - traefik.enable=true + - traefik.http.routers.vue.rule=Host(`nest.dev.juetan.cn`) + - traefik.http.routers.vue.entrypoints=websecure + - traefik.http.routers.vue.tls=true + - traefik.http.routers.vue.tls.certresolver=acmer + - traefik.http.services.vue1.loadbalancer.server.port=80 + +networks: + public: + external: true \ No newline at end of file diff --git a/public/assets/loading.svg b/public/assets/loading.svg index 04a4adf..a6d260f 100644 --- a/public/assets/loading.svg +++ b/public/assets/loading.svg @@ -1,2 +1 @@ - - + diff --git a/scripts/openapi/12.json b/scripts/openapi/12.json new file mode 100644 index 0000000..aa1595f --- /dev/null +++ b/scripts/openapi/12.json @@ -0,0 +1,1796 @@ +[ + { + "method": "post", + "path": "/api/v1/users", + "tag": "user", + "summary": "", + "operationId": "addUser", + "description": "新增用户", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan", + "name": "username", + "required": true + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹", + "name": "nickname", + "required": true + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password", + "name": "password", + "required": false + }, + "avatarId": { + "type": "number", + "description": "头像ID", + "example": 1, + "name": "avatarId", + "required": false + }, + "roleIds": { + "description": "角色ID列表", + "example": [ + 1, + 2, + 3 + ], + "type": "array", + "items": { + "type": "number" + }, + "name": "roleIds", + "required": false + } + }, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/users", + "tag": "user", + "summary": "", + "operationId": "getUsers", + "description": "分页/条件查询用户", + "pathParams": [], + "queryParams": [ + { + "name": "nickname", + "required": false, + "in": "query", + "description": "用户昵称", + "example": "绝弹", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "bodyParams": {}, + "resBody": { + "type": "array", + "items": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + } + }, + { + "method": "get", + "path": "/api/v1/users/{id}", + "tag": "user", + "summary": "", + "operationId": "getUser", + "description": "根据ID查询用户", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + }, + { + "method": "patch", + "path": "/api/v1/users/{id}", + "tag": "user", + "summary": "", + "operationId": "updateUser", + "description": "根据ID更新用户", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": { + "id": { + "type": "number", + "name": "id", + "required": true + }, + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan", + "name": "username", + "required": false + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹", + "name": "nickname", + "required": false + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password", + "name": "password", + "required": false + }, + "avatarId": { + "type": "number", + "description": "头像ID", + "example": 1, + "name": "avatarId", + "required": false + }, + "roleIds": { + "description": "角色ID列表", + "example": [ + 1, + 2, + 3 + ], + "type": "array", + "items": { + "type": "number" + }, + "name": "roleIds", + "required": false + } + } + }, + { + "method": "delete", + "path": "/api/v1/users/{id}", + "tag": "user", + "summary": "", + "operationId": "delUser", + "description": "根据ID删除用户", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "post", + "path": "/api/v1/auth/login", + "tag": "auth", + "summary": "", + "operationId": "login", + "description": "账号登陆", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "username": { + "type": "string", + "description": "用户名", + "example": "admin", + "name": "username", + "required": true + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "123456", + "name": "password", + "required": true + } + }, + "resBody": { + "type": "object", + "properties": { + "id": { + "type": "number", + "description": "用户ID" + }, + "token": { + "type": "string", + "description": "访问令牌", + "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjIsInVzZXJuYW1lIjoianVldGFuIiwiaWF0IjoxNjkxMTM5MjI3LCJleHAiOjE2OTExOTkyMjd9.6z7f-xfsHABbsyg401o2boKeqNQ1epPDYfEdavIcfYc" + }, + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "id", + "token", + "username", + "nickname", + "description", + "avatar", + "email", + "roleIds" + ] + } + }, + { + "method": "post", + "path": "/api/v1/logs", + "tag": "log", + "summary": "", + "operationId": "addLog", + "description": "新增日志管理", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "demo": { + "type": "string", + "description": "字段描述(Swagger用途)", + "example": "demo", + "name": "demo", + "required": true + } + }, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/logs", + "tag": "log", + "summary": "", + "operationId": "getLogs", + "description": "根据分页/过滤参数查询日志管理", + "pathParams": [], + "queryParams": [ + { + "name": "nickname", + "required": false, + "in": "query", + "description": "用户名", + "example": "绝弹", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "bodyParams": {}, + "resBody": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + } + } + }, + { + "method": "get", + "path": "/api/v1/logs/login", + "tag": "log", + "summary": "", + "operationId": "getLoginLogs", + "description": "分页查询登陆日志", + "pathParams": [], + "queryParams": [ + { + "name": "nickname", + "required": false, + "in": "query", + "description": "用户名", + "example": "绝弹", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "bodyParams": {}, + "resBody": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + } + } + }, + { + "method": "get", + "path": "/api/v1/logs/{id}", + "tag": "log", + "summary": "", + "operationId": "getLog", + "description": "根据ID查询日志管理", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + } + }, + { + "method": "patch", + "path": "/api/v1/logs/{id}", + "tag": "log", + "summary": "", + "operationId": "updateLog", + "description": "根据ID更新日志管理", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": { + "demo": { + "type": "string", + "description": "字段描述(Swagger用途)", + "example": "demo", + "name": "demo", + "required": false + } + } + }, + { + "method": "delete", + "path": "/api/v1/logs/{id}", + "tag": "log", + "summary": "", + "operationId": "delLog", + "description": "根据ID删除日志管理", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "post", + "path": "/api/v1/roles", + "tag": "role", + "summary": "", + "operationId": "addRole", + "description": "创建角色", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "name": { + "type": "string", + "name": "name", + "required": true + }, + "slug": { + "type": "string", + "name": "slug", + "required": true + }, + "description": { + "type": "string", + "name": "description", + "required": false + }, + "permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + }, + "name": "permissions", + "required": false + } + }, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/roles", + "tag": "role", + "summary": "", + "operationId": "getRoles", + "description": "批量查询角色", + "pathParams": [], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "get", + "path": "/api/v1/roles/{id}", + "tag": "role", + "summary": "", + "operationId": "getRole", + "description": "查询角色", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "string" + } + }, + { + "method": "patch", + "path": "/api/v1/roles/{id}", + "tag": "role", + "summary": "", + "operationId": "updateRole", + "description": "更新角色", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": { + "permissionIds": { + "type": "array", + "items": { + "type": "number" + }, + "name": "permissionIds", + "required": false + }, + "name": { + "type": "string", + "name": "name", + "required": false + }, + "slug": { + "type": "string", + "name": "slug", + "required": false + }, + "description": { + "type": "string", + "name": "description", + "required": false + }, + "permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + }, + "name": "permissions", + "required": false + } + } + }, + { + "method": "delete", + "path": "/api/v1/roles/{id}", + "tag": "role", + "summary": "", + "operationId": "delRole", + "description": "删除角色", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "string" + } + }, + { + "method": "post", + "path": "/api/v1/permissions", + "tag": "permission", + "summary": "", + "operationId": "addPermission", + "description": "创建权限", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "name": { + "type": "string", + "description": "权限名称", + "example": "权限名称", + "name": "name", + "required": true + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "permission:permission", + "name": "slug", + "required": true + }, + "description": { + "type": "string", + "description": "权限描述", + "name": "description", + "required": false + } + }, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/permissions", + "tag": "permission", + "summary": "", + "operationId": "getPermissions", + "description": "批量查询权限", + "pathParams": [], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "get", + "path": "/api/v1/permissions/{id}", + "tag": "permission", + "summary": "", + "operationId": "getPermission", + "description": "查询权限", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "string" + } + }, + { + "method": "patch", + "path": "/api/v1/permissions/{id}", + "tag": "permission", + "summary": "", + "operationId": "setPermission", + "description": "更新权限", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "queryParams": [], + "bodyParams": { + "id": { + "type": "number", + "name": "id", + "required": true + }, + "name": { + "type": "string", + "description": "权限名称", + "example": "权限名称", + "name": "name", + "required": false + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "permission:permission", + "name": "slug", + "required": false + }, + "description": { + "type": "string", + "description": "权限描述", + "name": "description", + "required": false + } + } + }, + { + "method": "delete", + "path": "/api/v1/permissions/{id}", + "tag": "permission", + "summary": "", + "operationId": "delPermission", + "description": "删除权限", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "string" + } + }, + { + "method": "post", + "path": "/api/v1/file", + "tag": "file", + "summary": "", + "operationId": "addFile", + "description": "上传文件", + "pathParams": [], + "queryParams": [], + "bodyParams": {}, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/file", + "tag": "file", + "summary": "", + "operationId": "getFiles", + "description": "批量查询", + "pathParams": [], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "get", + "path": "/api/v1/file/{id}", + "tag": "file", + "summary": "", + "operationId": "getFile", + "description": "查询", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "文件名", + "example": "xxx.jpg" + }, + "size": { + "type": "number", + "description": "文件大小", + "example": 1024 + }, + "mimetype": { + "type": "string", + "description": "文件类型", + "example": "image/jpeg" + }, + "path": { + "type": "string", + "description": "文件路径", + "example": "/upload/2021/10/01/xxx.jpg" + }, + "hash": { + "type": "string", + "description": "文件哈希", + "example": "2afb1f8b83ef0cc564f227d75d0b6914" + }, + "extension": { + "type": "string", + "description": "文件后缀", + "example": ".jpg" + } + }, + "required": [ + "name", + "size", + "mimetype", + "path", + "hash", + "extension" + ] + } + }, + { + "method": "patch", + "path": "/api/v1/file/{id}", + "tag": "file", + "summary": "", + "operationId": "setFile", + "description": "更新", + "pathParams": [], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "string" + } + }, + { + "method": "delete", + "path": "/api/v1/file/{id}", + "tag": "file", + "summary": "", + "operationId": "delFile", + "description": "删除", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "get", + "path": "/api/v1/file/hash/{hash}", + "tag": "file", + "summary": "", + "operationId": "getFileByHash", + "description": "查询文件是否已存在", + "pathParams": [ + { + "name": "hash", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "boolean" + } + }, + { + "method": "post", + "path": "/api/v1/posts", + "tag": "post", + "summary": "", + "operationId": "addPost", + "description": "创建文章", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "title": { + "type": "string", + "description": "文章标题", + "name": "title", + "required": true + }, + "description": { + "type": "string", + "description": "文章描述", + "name": "description", + "required": true + }, + "content": { + "type": "string", + "description": "文章内容", + "name": "content", + "required": true + } + }, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/posts", + "tag": "post", + "summary": "", + "operationId": "getPosts", + "description": "批量查询文章", + "pathParams": [], + "queryParams": [ + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "bodyParams": {} + }, + { + "method": "get", + "path": "/api/v1/posts/template.xlsx", + "tag": "post", + "summary": "", + "operationId": "getPostTemplate", + "description": "获取文章下载模板", + "pathParams": [], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "get", + "path": "/api/v1/posts/{id}", + "tag": "post", + "summary": "", + "operationId": "getPost", + "description": "查询文章", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题", + "example": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述", + "example": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容", + "example": "文章内容" + }, + "author": { + "description": "文章作者", + "example": "文章作者", + "allOf": [ + { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + ] + } + }, + "required": [ + "title", + "description", + "content", + "author" + ] + } + }, + { + "method": "patch", + "path": "/api/v1/posts/{id}", + "tag": "post", + "summary": "", + "operationId": "updatePost", + "description": "更新文章", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": { + "title": { + "type": "string", + "description": "文章标题", + "name": "title", + "required": false + }, + "description": { + "type": "string", + "description": "文章描述", + "name": "description", + "required": false + }, + "content": { + "type": "string", + "description": "文章内容", + "name": "content", + "required": false + } + } + }, + { + "method": "delete", + "path": "/api/v1/posts/{id}", + "tag": "post", + "summary": "", + "operationId": "delPost", + "description": "删除文章", + "pathParams": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "queryParams": [], + "bodyParams": {} + }, + { + "method": "post", + "path": "/api/v1/categories", + "tag": "category", + "summary": "", + "operationId": "addCategory", + "description": "添加分类", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类", + "name": "title", + "required": true + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default", + "name": "slug", + "required": true + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类", + "name": "description", + "required": false + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default", + "name": "icon", + "required": false + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0, + "name": "sort", + "required": false + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category", + "name": "type", + "required": true + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0, + "name": "parentId", + "required": false + } + }, + "resBody": {} + }, + { + "method": "get", + "path": "/api/v1/categories", + "tag": "category", + "summary": "", + "operationId": "getCategories", + "description": "分页获取分类", + "pathParams": [], + "queryParams": [ + { + "name": "demo", + "required": false, + "in": "query", + "description": "字段描述(Swagger用途)", + "example": "示例值", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "bodyParams": {}, + "resBody": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug" + ] + } + } + }, + { + "method": "get", + "path": "/api/v1/categories/{id}", + "tag": "category", + "summary": "", + "operationId": "getCategory", + "description": "添加分类", + "pathParams": [], + "queryParams": [], + "bodyParams": {}, + "resBody": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug" + ] + } + }, + { + "method": "patch", + "path": "/api/v1/categories/{id}", + "tag": "category", + "summary": "", + "operationId": "setCategory", + "description": "更新分类", + "pathParams": [], + "queryParams": [], + "bodyParams": { + "id": { + "type": "number", + "name": "id", + "required": true + }, + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类", + "name": "title", + "required": false + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default", + "name": "slug", + "required": false + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类", + "name": "description", + "required": false + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default", + "name": "icon", + "required": false + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0, + "name": "sort", + "required": false + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category", + "name": "type", + "required": false + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0, + "name": "parentId", + "required": false + } + } + }, + { + "method": "delete", + "path": "/api/v1/categories/{id}", + "tag": "category", + "summary": "", + "operationId": "delCategory", + "description": "删除分类", + "pathParams": [], + "queryParams": [], + "bodyParams": {} + } +] \ No newline at end of file diff --git a/scripts/openapi/e.ts b/scripts/openapi/e.ts new file mode 100644 index 0000000..a5a34a5 --- /dev/null +++ b/scripts/openapi/e.ts @@ -0,0 +1,75 @@ +import fs from 'fs' +import doc from './openapi1.json'; + +interface Param { + name: string; + required: boolean; + description: string; + example: string; + schema: { + type: string; + [key: string]: any; + } +} + +interface JsonParam { + name: string; + type: string; + required: boolean; + description: string; + example: string; +} + +const run = () => { + const { paths } = doc + const routes: any[] = [] + for(const [path, obj] of Object.entries(paths)) { + for(const [method, obj1] of Object.entries(obj)) { + const { tags, summary, operationId, description, parameters, requestBody, responses } = obj1 + + const { content = {} } = requestBody || {} + const { schema = {} } = content['application/json'] || {} + const { properties = {}, required: requireds = [] } = schema + const bodyParams = {} + for(const [id, obj2 = {}] of Object.entries(properties)) { + const { type, description, example } = obj2 as any; + const required = requireds.includes(id) + const param: JsonParam = { + ...(obj2 as any), + name: id, + type, + required, + description, + example, + } + bodyParams[id] = param + } + + const { content: content1 = {} } = responses['200'] || {} + const { schema: schema1 = {} } = content1['application/json'] || {} + let resBody = {} + if(schema1.type === 'object') { + resBody = schema1.properties?.data; + } + + const pathParams = parameters.filter((i: any) => i.in === 'path') + const queryParams = parameters.filter((i: any) => i.in === 'query') + const route = { + method, + path, + tag: tags?.[0], + summary, + operationId, + description, + pathParams, + queryParams, + bodyParams, + resBody, + } + routes.push(route) + } + } + fs.writeFileSync('12.json', JSON.stringify(routes, null, 2)); +} + +run(); \ No newline at end of file diff --git a/scripts/openapi/index.ts b/scripts/openapi/index.ts index df5ece1..aefdefc 100644 --- a/scripts/openapi/index.ts +++ b/scripts/openapi/index.ts @@ -8,9 +8,9 @@ const env = loadEnv("development", process.cwd()); const run = async () => { const output = await generateApi({ - url: env.VITE_OPENAPI, + url: "http://localhost:3030/openapi.json", templates: path.resolve(__dirname, "./template"), - output: path.resolve(process.cwd(), "src/api/service"), + // output: path.resolve(process.cwd(), "src/api/service"), name: "Api.ts", singleHttpClient: false, httpClientType: "axios", @@ -28,6 +28,7 @@ const run = async () => { parser: "typescript", }, }); + debugger; return output; }; diff --git a/scripts/openapi/openapi.json b/scripts/openapi/openapi.json index 9f172a9..6ff50e7 100644 --- a/scripts/openapi/openapi.json +++ b/scripts/openapi/openapi.json @@ -23,30 +23,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "number" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "user" - ] + "tags": ["user"] }, "get": { "operationId": "getUsers", @@ -104,33 +104,33 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/User" - } - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "user" - ] + "tags": ["user"] } }, "/api/v1/users/{id}": { @@ -154,30 +154,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/User" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "$ref": "#/components/schemas/User" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "user" - ] + "tags": ["user"] }, "patch": { "operationId": "updateUser", @@ -215,9 +215,7 @@ } } }, - "tags": [ - "user" - ] + "tags": ["user"] }, "delete": { "operationId": "delUser", @@ -245,9 +243,7 @@ } } }, - "tags": [ - "user" - ] + "tags": ["user"] } }, "/api/v1/auth/login": { @@ -272,30 +268,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/LoginedUserVo" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "$ref": "#/components/schemas/LoginedUserVo" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "auth" - ] + "tags": ["auth"] } }, "/api/v1/logs": { @@ -320,30 +316,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "number" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "log" - ] + "tags": ["log"] }, "get": { "operationId": "getLogs", @@ -401,33 +397,33 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LoginLog" - } - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LoginLog" + } } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "log" - ] + "tags": ["log"] } }, "/api/v1/logs/login": { @@ -487,33 +483,33 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LoginLog" - } - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LoginLog" + } } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "log" - ] + "tags": ["log"] } }, "/api/v1/logs/{id}": { @@ -537,30 +533,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/LoginLog" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "$ref": "#/components/schemas/LoginLog" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "log" - ] + "tags": ["log"] }, "patch": { "operationId": "updateLog", @@ -598,9 +594,7 @@ } } }, - "tags": [ - "log" - ] + "tags": ["log"] }, "delete": { "operationId": "delLog", @@ -628,9 +622,7 @@ } } }, - "tags": [ - "log" - ] + "tags": ["log"] } }, "/api/v1/roles": { @@ -655,30 +647,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "number" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "role" - ] + "tags": ["role"] }, "get": { "operationId": "getRoles", @@ -697,9 +689,7 @@ } } }, - "tags": [ - "role" - ] + "tags": ["role"] } }, "/api/v1/roles/{id}": { @@ -723,30 +713,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "role" - ] + "tags": ["role"] }, "patch": { "operationId": "updateRole", @@ -784,9 +774,7 @@ } } }, - "tags": [ - "role" - ] + "tags": ["role"] }, "delete": { "operationId": "delRole", @@ -808,30 +796,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "role" - ] + "tags": ["role"] } }, "/api/v1/permissions": { @@ -856,30 +844,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "number" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "permission" - ] + "tags": ["permission"] }, "get": { "operationId": "getPermissions", @@ -898,9 +886,7 @@ } } }, - "tags": [ - "permission" - ] + "tags": ["permission"] } }, "/api/v1/permissions/{id}": { @@ -924,30 +910,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "permission" - ] + "tags": ["permission"] }, "patch": { "operationId": "setPermission", @@ -985,9 +971,7 @@ } } }, - "tags": [ - "permission" - ] + "tags": ["permission"] }, "delete": { "operationId": "delPermission", @@ -1009,33 +993,33 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "permission" - ] + "tags": ["permission"] } }, - "/api/v1/upload": { + "/api/v1/file": { "post": { "operationId": "addFile", "summary": "", @@ -1058,33 +1042,33 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "number" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "upload" - ] + "tags": ["file"] }, "get": { - "operationId": "getUploads", + "operationId": "getFiles", "summary": "", "description": "批量查询", "parameters": [], @@ -1100,12 +1084,10 @@ } } }, - "tags": [ - "upload" - ] + "tags": ["file"] } }, - "/api/v1/upload/{id}": { + "/api/v1/file/{id}": { "get": { "operationId": "getFile", "summary": "", @@ -1126,33 +1108,33 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/Upload" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "$ref": "#/components/schemas/Upload" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "upload" - ] + "tags": ["file"] }, "patch": { - "operationId": "updateFile", + "operationId": "setFile", "summary": "", "description": "更新", "parameters": [], @@ -1162,30 +1144,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "upload" - ] + "tags": ["file"] }, "delete": { "operationId": "delFile", @@ -1213,9 +1195,54 @@ } } }, - "tags": [ - "upload" - ] + "tags": ["file"] + } + }, + "/api/v1/file/hash/{hash}": { + "get": { + "operationId": "getFileByHash", + "summary": "", + "description": "查询文件是否已存在", + "parameters": [ + { + "name": "hash", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "boolean" + } + }, + "required": ["code", "message"] + } + } + } + } + }, + "tags": ["file"] } }, "/api/v1/posts": { @@ -1240,30 +1267,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "type": "number" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "post" - ] + "tags": ["post"] }, "get": { "operationId": "getPosts", @@ -1317,9 +1344,7 @@ } } }, - "tags": [ - "post" - ] + "tags": ["post"] } }, "/api/v1/posts/template.xlsx": { @@ -1340,9 +1365,7 @@ } } }, - "tags": [ - "post" - ] + "tags": ["post"] } }, "/api/v1/posts/{id}": { @@ -1366,30 +1389,30 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Response" + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/Post" - } - }, - "required": [ - "data" - ] + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "$ref": "#/components/schemas/Post" } - ] + }, + "required": ["code", "message"] } } } } }, - "tags": [ - "post" - ] + "tags": ["post"] }, "patch": { "operationId": "updatePost", @@ -1427,9 +1450,7 @@ } } }, - "tags": [ - "post" - ] + "tags": ["post"] }, "delete": { "operationId": "delPost", @@ -1457,9 +1478,225 @@ } } }, - "tags": [ - "post" - ] + "tags": ["post"] + } + }, + "/api/v1/categories": { + "post": { + "operationId": "addCategory", + "summary": "", + "description": "添加分类", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCategoryDto" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": ["code", "message"] + } + } + } + } + }, + "tags": ["category"] + }, + "get": { + "operationId": "getCategories", + "summary": "", + "description": "分页获取分类", + "parameters": [ + { + "name": "demo", + "required": false, + "in": "query", + "description": "字段描述(Swagger用途)", + "example": "示例值", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Category" + } + } + }, + "required": ["code", "message"] + } + } + } + } + }, + "tags": ["category"] + } + }, + "/api/v1/categories/{id}": { + "get": { + "operationId": "getCategory", + "summary": "", + "description": "添加分类", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "$ref": "#/components/schemas/Category" + } + }, + "required": ["code", "message"] + } + } + } + } + }, + "tags": ["category"] + }, + "patch": { + "operationId": "setCategory", + "summary": "", + "description": "更新分类", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateCategoryDto" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + }, + "tags": ["category"] + }, + "delete": { + "operationId": "delCategory", + "summary": "", + "description": "删除分类", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + }, + "tags": ["category"] } } }, @@ -1530,21 +1767,14 @@ }, "roleIds": { "description": "角色ID列表", - "example": [ - 1, - 2, - 3 - ], + "example": [1, 2, 3], "type": "array", "items": { "type": "number" } } }, - "required": [ - "username", - "nickname" - ] + "required": ["username", "nickname"] }, "User": { "type": "object", @@ -1587,19 +1817,14 @@ } } }, - "required": [ - "username", - "nickname", - "description", - "avatar", - "password", - "email", - "roleIds" - ] + "required": ["username", "nickname", "description", "avatar", "password", "email", "roleIds"] }, "UpdateUserDto": { "type": "object", "properties": { + "id": { + "type": "number" + }, "username": { "type": "string", "description": "登录账号", @@ -1622,17 +1847,14 @@ }, "roleIds": { "description": "角色ID列表", - "example": [ - 1, - 2, - 3 - ], + "example": [1, 2, 3], "type": "array", "items": { "type": "number" } } - } + }, + "required": ["id"] }, "AuthUserDto": { "type": "object", @@ -1648,10 +1870,7 @@ "example": "123456" } }, - "required": [ - "username", - "password" - ] + "required": ["username", "password"] }, "LoginedUserVo": { "type": "object", @@ -1698,16 +1917,7 @@ } } }, - "required": [ - "id", - "token", - "username", - "nickname", - "description", - "avatar", - "email", - "roleIds" - ] + "required": ["id", "token", "username", "nickname", "description", "avatar", "email", "roleIds"] }, "CreateLogDto": { "type": "object", @@ -1718,9 +1928,7 @@ "example": "demo" } }, - "required": [ - "demo" - ] + "required": ["demo"] }, "LoginLog": { "type": "object", @@ -1761,15 +1969,7 @@ "example": "windows 10" } }, - "required": [ - "nickname", - "description", - "status", - "ip", - "addr", - "browser", - "os" - ] + "required": ["nickname", "description", "status", "ip", "addr", "browser", "os"] }, "UpdateLogDto": { "type": "object", @@ -1798,10 +1998,7 @@ "type": "string", "description": "权限类型", "example": "menu", - "enum": [ - "menu", - "api" - ] + "enum": ["menu", "api"] }, "description": { "type": "string", @@ -1809,12 +2006,7 @@ "example": "文章列表" } }, - "required": [ - "name", - "slug", - "type", - "description" - ] + "required": ["name", "slug", "type", "description"] }, "CreateRoleDto": { "type": "object", @@ -1835,10 +2027,7 @@ } } }, - "required": [ - "name", - "slug" - ] + "required": ["name", "slug"] }, "UpdateRoleDto": { "type": "object", @@ -1884,14 +2073,14 @@ "description": "权限描述" } }, - "required": [ - "name", - "slug" - ] + "required": ["name", "slug"] }, "UpdatePermissionDto": { "type": "object", "properties": { + "id": { + "type": "number" + }, "name": { "type": "string", "description": "权限名称", @@ -1906,7 +2095,8 @@ "type": "string", "description": "权限描述" } - } + }, + "required": ["id"] }, "CreateUploadDto": { "type": "object", @@ -1916,9 +2106,7 @@ "format": "binary" } }, - "required": [ - "file" - ] + "required": ["file"] }, "Upload": { "type": "object", @@ -1946,7 +2134,7 @@ "hash": { "type": "string", "description": "文件哈希", - "example": "xxx" + "example": "2afb1f8b83ef0cc564f227d75d0b6914" }, "extension": { "type": "string", @@ -1954,14 +2142,7 @@ "example": ".jpg" } }, - "required": [ - "name", - "size", - "mimetype", - "path", - "hash", - "extension" - ] + "required": ["name", "size", "mimetype", "path", "hash", "extension"] }, "CreatePostDto": { "type": "object", @@ -1979,11 +2160,7 @@ "description": "文章内容" } }, - "required": [ - "title", - "description", - "content" - ] + "required": ["title", "description", "content"] }, "Post": { "type": "object", @@ -2013,12 +2190,7 @@ ] } }, - "required": [ - "title", - "description", - "content", - "author" - ] + "required": ["title", "description", "content", "author"] }, "UpdatePostDto": { "type": "object", @@ -2037,6 +2209,132 @@ } } }, + "CreateCategoryDto": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": ["title", "slug", "type"] + }, + "Category": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": ["title", "slug"] + }, + "UpdateCategoryDto": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": ["id"] + }, "Response": { "type": "object", "properties": { @@ -2052,10 +2350,7 @@ "example": "请求成功" } }, - "required": [ - "code", - "message" - ] + "required": ["code", "message"] } } }, @@ -2063,4 +2358,4 @@ "description": "JSON数据", "url": "/openapi.json" } -} \ No newline at end of file +} diff --git a/scripts/openapi/openapi1.json b/scripts/openapi/openapi1.json new file mode 100644 index 0000000..5df8569 --- /dev/null +++ b/scripts/openapi/openapi1.json @@ -0,0 +1,3858 @@ +{ + "openapi": "3.0.0", + "paths": { + "/api/v1/users": { + "post": { + "operationId": "addUser", + "summary": "", + "description": "新增用户", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "avatarId": { + "type": "number", + "description": "头像ID", + "example": 1 + }, + "roleIds": { + "description": "角色ID列表", + "example": [ + 1, + 2, + 3 + ], + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "user" + ] + }, + "get": { + "operationId": "getUsers", + "summary": "", + "description": "分页/条件查询用户", + "parameters": [ + { + "name": "nickname", + "required": false, + "in": "query", + "description": "用户昵称", + "example": "绝弹", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "user" + ] + } + }, + "/api/v1/users/{id}": { + "get": { + "operationId": "getUser", + "summary": "", + "description": "根据ID查询用户", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "user" + ] + }, + "patch": { + "operationId": "updateUser", + "summary": "", + "description": "根据ID更新用户", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "avatarId": { + "type": "number", + "description": "头像ID", + "example": 1 + }, + "roleIds": { + "description": "角色ID列表", + "example": [ + 1, + 2, + 3 + ], + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "id" + ] + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "user" + ] + }, + "delete": { + "operationId": "delUser", + "summary": "", + "description": "根据ID删除用户", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "user" + ] + } + }, + "/api/v1/auth/login": { + "post": { + "operationId": "login", + "summary": "", + "description": "账号登陆", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "用户名", + "example": "admin" + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "123456" + } + }, + "required": [ + "username", + "password" + ] + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "object", + "properties": { + "id": { + "type": "number", + "description": "用户ID" + }, + "token": { + "type": "string", + "description": "访问令牌", + "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjIsInVzZXJuYW1lIjoianVldGFuIiwiaWF0IjoxNjkxMTM5MjI3LCJleHAiOjE2OTExOTkyMjd9.6z7f-xfsHABbsyg401o2boKeqNQ1epPDYfEdavIcfYc" + }, + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "id", + "token", + "username", + "nickname", + "description", + "avatar", + "email", + "roleIds" + ] + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "auth" + ] + } + }, + "/api/v1/logs": { + "post": { + "operationId": "addLog", + "summary": "", + "description": "新增日志管理", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "demo": { + "type": "string", + "description": "字段描述(Swagger用途)", + "example": "demo" + } + }, + "required": [ + "demo" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "log" + ] + }, + "get": { + "operationId": "getLogs", + "summary": "", + "description": "根据分页/过滤参数查询日志管理", + "parameters": [ + { + "name": "nickname", + "required": false, + "in": "query", + "description": "用户名", + "example": "绝弹", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + } + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "log" + ] + } + }, + "/api/v1/logs/login": { + "get": { + "operationId": "getLoginLogs", + "summary": "", + "description": "分页查询登陆日志", + "parameters": [ + { + "name": "nickname", + "required": false, + "in": "query", + "description": "用户名", + "example": "绝弹", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + } + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "log" + ] + } + }, + "/api/v1/logs/{id}": { + "get": { + "operationId": "getLog", + "summary": "", + "description": "根据ID查询日志管理", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "log" + ] + }, + "patch": { + "operationId": "updateLog", + "summary": "", + "description": "根据ID更新日志管理", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "demo": { + "type": "string", + "description": "字段描述(Swagger用途)", + "example": "demo" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "log" + ] + }, + "delete": { + "operationId": "delLog", + "summary": "", + "description": "根据ID删除日志管理", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "log" + ] + } + }, + "/api/v1/roles": { + "post": { + "operationId": "addRole", + "summary": "", + "description": "创建角色", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "description": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + } + } + }, + "required": [ + "name", + "slug" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "role" + ] + }, + "get": { + "operationId": "getRoles", + "summary": "", + "description": "批量查询角色", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "role" + ] + } + }, + "/api/v1/roles/{id}": { + "get": { + "operationId": "getRole", + "summary": "", + "description": "查询角色", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "role" + ] + }, + "patch": { + "operationId": "updateRole", + "summary": "", + "description": "更新角色", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "permissionIds": { + "type": "array", + "items": { + "type": "number" + } + }, + "name": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "description": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "role" + ] + }, + "delete": { + "operationId": "delRole", + "summary": "", + "description": "删除角色", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "role" + ] + } + }, + "/api/v1/permissions": { + "post": { + "operationId": "addPermission", + "summary": "", + "description": "创建权限", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "权限名称" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "permission:permission" + }, + "description": { + "type": "string", + "description": "权限描述" + } + }, + "required": [ + "name", + "slug" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "permission" + ] + }, + "get": { + "operationId": "getPermissions", + "summary": "", + "description": "批量查询权限", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "permission" + ] + } + }, + "/api/v1/permissions/{id}": { + "get": { + "operationId": "getPermission", + "summary": "", + "description": "查询权限", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "permission" + ] + }, + "patch": { + "operationId": "setPermission", + "summary": "", + "description": "更新权限", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "name": { + "type": "string", + "description": "权限名称", + "example": "权限名称" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "permission:permission" + }, + "description": { + "type": "string", + "description": "权限描述" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "permission" + ] + }, + "delete": { + "operationId": "delPermission", + "summary": "", + "description": "删除权限", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "permission" + ] + } + }, + "/api/v1/file": { + "post": { + "operationId": "addFile", + "summary": "", + "description": "上传文件", + "parameters": [], + "requestBody": { + "required": true, + "description": "要上传的文件", + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + } + }, + "required": [ + "file" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "file" + ] + }, + "get": { + "operationId": "getFiles", + "summary": "", + "description": "批量查询", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "file" + ] + } + }, + "/api/v1/file/{id}": { + "get": { + "operationId": "getFile", + "summary": "", + "description": "查询", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "文件名", + "example": "xxx.jpg" + }, + "size": { + "type": "number", + "description": "文件大小", + "example": 1024 + }, + "mimetype": { + "type": "string", + "description": "文件类型", + "example": "image/jpeg" + }, + "path": { + "type": "string", + "description": "文件路径", + "example": "/upload/2021/10/01/xxx.jpg" + }, + "hash": { + "type": "string", + "description": "文件哈希", + "example": "2afb1f8b83ef0cc564f227d75d0b6914" + }, + "extension": { + "type": "string", + "description": "文件后缀", + "example": ".jpg" + } + }, + "required": [ + "name", + "size", + "mimetype", + "path", + "hash", + "extension" + ] + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "file" + ] + }, + "patch": { + "operationId": "setFile", + "summary": "", + "description": "更新", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "file" + ] + }, + "delete": { + "operationId": "delFile", + "summary": "", + "description": "删除", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "file" + ] + } + }, + "/api/v1/file/hash/{hash}": { + "get": { + "operationId": "getFileByHash", + "summary": "", + "description": "查询文件是否已存在", + "parameters": [ + { + "name": "hash", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "boolean" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "file" + ] + } + }, + "/api/v1/posts": { + "post": { + "operationId": "addPost", + "summary": "", + "description": "创建文章", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容" + } + }, + "required": [ + "title", + "description", + "content" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "post" + ] + }, + "get": { + "operationId": "getPosts", + "summary": "", + "description": "批量查询文章", + "parameters": [ + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "post" + ] + } + }, + "/api/v1/posts/template.xlsx": { + "get": { + "operationId": "getPostTemplate", + "summary": "", + "description": "获取文章下载模板", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "post" + ] + } + }, + "/api/v1/posts/{id}": { + "get": { + "operationId": "getPost", + "summary": "", + "description": "查询文章", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题", + "example": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述", + "example": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容", + "example": "文章内容" + }, + "author": { + "description": "文章作者", + "example": "文章作者", + "allOf": [ + { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + ] + } + }, + "required": [ + "title", + "description", + "content", + "author" + ] + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "post" + ] + }, + "patch": { + "operationId": "updatePost", + "summary": "", + "description": "更新文章", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "post" + ] + }, + "delete": { + "operationId": "delPost", + "summary": "", + "description": "删除文章", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "post" + ] + } + }, + "/api/v1/categories": { + "post": { + "operationId": "addCategory", + "summary": "", + "description": "添加分类", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug", + "type" + ] + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "number" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "category" + ] + }, + "get": { + "operationId": "getCategories", + "summary": "", + "description": "分页获取分类", + "parameters": [ + { + "name": "demo", + "required": false, + "in": "query", + "description": "字段描述(Swagger用途)", + "example": "示例值", + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "required": false, + "in": "query", + "description": "排序规则", + "example": "id:desc", + "schema": { + "pattern": "/^(\\w+:\\w+,)*\\w+:\\w+$/", + "default": "id:desc", + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "页码", + "example": 1, + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "每页条数", + "example": 10, + "schema": { + "minimum": 0, + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug" + ] + } + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "category" + ] + } + }, + "/api/v1/categories/{id}": { + "get": { + "operationId": "getCategory", + "summary": "", + "description": "添加分类", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + }, + "data": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug" + ] + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "category" + ] + }, + "patch": { + "operationId": "setCategory", + "summary": "", + "description": "更新分类", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "id" + ] + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "category" + ] + }, + "delete": { + "operationId": "delCategory", + "summary": "", + "description": "删除分类", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + } + } + }, + "tags": [ + "category" + ] + } + } + }, + "info": { + "title": "Appnify接口文档", + "description": "Openapi 3.0文档", + "version": "1.0", + "contact": {} + }, + "tags": [ + { + "name": "user", + "description": "用户管理" + }, + { + "name": "auth", + "description": "认证管理" + }, + { + "name": "role", + "description": "角色管理" + }, + { + "name": "permission", + "description": "权限管理" + }, + { + "name": "post", + "description": "文章管理" + }, + { + "name": "upload", + "description": "文件上传" + } + ], + "servers": [], + "components": { + "securitySchemes": { + "bearer": { + "scheme": "bearer", + "bearerFormat": "JWT", + "type": "http" + } + }, + "schemas": { + "CreateUserDto": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "avatarId": { + "type": "number", + "description": "头像ID", + "example": 1 + }, + "roleIds": { + "description": "角色ID列表", + "example": [ + 1, + 2, + 3 + ], + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname" + ] + }, + "User": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + }, + "UpdateUserDto": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "avatarId": { + "type": "number", + "description": "头像ID", + "example": 1 + }, + "roleIds": { + "description": "角色ID列表", + "example": [ + 1, + 2, + 3 + ], + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "id" + ] + }, + "AuthUserDto": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "用户名", + "example": "admin" + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "123456" + } + }, + "required": [ + "username", + "password" + ] + }, + "LoginedUserVo": { + "type": "object", + "properties": { + "id": { + "type": "number", + "description": "用户ID" + }, + "token": { + "type": "string", + "description": "访问令牌", + "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjIsInVzZXJuYW1lIjoianVldGFuIiwiaWF0IjoxNjkxMTM5MjI3LCJleHAiOjE2OTExOTkyMjd9.6z7f-xfsHABbsyg401o2boKeqNQ1epPDYfEdavIcfYc" + }, + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "id", + "token", + "username", + "nickname", + "description", + "avatar", + "email", + "roleIds" + ] + }, + "CreateLogDto": { + "type": "object", + "properties": { + "demo": { + "type": "string", + "description": "字段描述(Swagger用途)", + "example": "demo" + } + }, + "required": [ + "demo" + ] + }, + "LoginLog": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "操作描述", + "example": "1" + }, + "status": { + "type": "boolean", + "description": "操作状态", + "example": true + }, + "ip": { + "type": "string", + "description": "登陆IP", + "example": "127.0.0.1" + }, + "addr": { + "type": "string", + "description": "登陆地址", + "example": "广东省深圳市" + }, + "browser": { + "type": "string", + "description": "浏览器", + "example": "chrome" + }, + "os": { + "type": "string", + "description": "操作系统", + "example": "windows 10" + } + }, + "required": [ + "nickname", + "description", + "status", + "ip", + "addr", + "browser", + "os" + ] + }, + "UpdateLogDto": { + "type": "object", + "properties": { + "demo": { + "type": "string", + "description": "字段描述(Swagger用途)", + "example": "demo" + } + } + }, + "Permission": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + }, + "CreateRoleDto": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "description": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + } + } + }, + "required": [ + "name", + "slug" + ] + }, + "UpdateRoleDto": { + "type": "object", + "properties": { + "permissionIds": { + "type": "array", + "items": { + "type": "number" + } + }, + "name": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "description": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "文章列表" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "post:list" + }, + "type": { + "type": "string", + "description": "权限类型", + "example": "menu", + "enum": [ + "menu", + "api" + ] + }, + "description": { + "type": "string", + "description": "权限描述", + "example": "文章列表" + } + }, + "required": [ + "name", + "slug", + "type", + "description" + ] + } + } + } + }, + "CreatePermissionDto": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "权限名称", + "example": "权限名称" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "permission:permission" + }, + "description": { + "type": "string", + "description": "权限描述" + } + }, + "required": [ + "name", + "slug" + ] + }, + "UpdatePermissionDto": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "name": { + "type": "string", + "description": "权限名称", + "example": "权限名称" + }, + "slug": { + "type": "string", + "description": "权限标识", + "example": "permission:permission" + }, + "description": { + "type": "string", + "description": "权限描述" + } + }, + "required": [ + "id" + ] + }, + "CreateUploadDto": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + } + }, + "required": [ + "file" + ] + }, + "Upload": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "文件名", + "example": "xxx.jpg" + }, + "size": { + "type": "number", + "description": "文件大小", + "example": 1024 + }, + "mimetype": { + "type": "string", + "description": "文件类型", + "example": "image/jpeg" + }, + "path": { + "type": "string", + "description": "文件路径", + "example": "/upload/2021/10/01/xxx.jpg" + }, + "hash": { + "type": "string", + "description": "文件哈希", + "example": "2afb1f8b83ef0cc564f227d75d0b6914" + }, + "extension": { + "type": "string", + "description": "文件后缀", + "example": ".jpg" + } + }, + "required": [ + "name", + "size", + "mimetype", + "path", + "hash", + "extension" + ] + }, + "CreatePostDto": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容" + } + }, + "required": [ + "title", + "description", + "content" + ] + }, + "Post": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题", + "example": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述", + "example": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容", + "example": "文章内容" + }, + "author": { + "description": "文章作者", + "example": "文章作者", + "allOf": [ + { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "登录账号", + "example": "juetan" + }, + "nickname": { + "type": "string", + "description": "用户昵称", + "example": "绝弹" + }, + "description": { + "type": "string", + "description": "用户介绍", + "example": "这个人很懒, 什么也没有留下!" + }, + "avatar": { + "type": "string", + "description": "用户头像(URL)", + "example": "./assets/222421415123.png " + }, + "password": { + "type": "string", + "description": "用户密码", + "example": "password" + }, + "email": { + "type": "string", + "description": "用户邮箱", + "example": "example@mail.com" + }, + "roleIds": { + "description": "用户角色ID", + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "username", + "nickname", + "description", + "avatar", + "password", + "email", + "roleIds" + ] + } + ] + } + }, + "required": [ + "title", + "description", + "content", + "author" + ] + }, + "UpdatePostDto": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "文章标题" + }, + "description": { + "type": "string", + "description": "文章描述" + }, + "content": { + "type": "string", + "description": "文章内容" + } + } + }, + "CreateCategoryDto": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug", + "type" + ] + }, + "Category": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "title", + "slug" + ] + }, + "UpdateCategoryDto": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "title": { + "type": "string", + "description": "分类名称", + "example": "待分类" + }, + "slug": { + "type": "string", + "description": "分类别名", + "example": "default" + }, + "description": { + "type": "string", + "description": "分类描述", + "example": "默认分类" + }, + "icon": { + "type": "string", + "description": "分类图标", + "example": "default" + }, + "sort": { + "type": "number", + "description": "分类排序", + "example": 0 + }, + "type": { + "type": "object", + "description": "分类类型", + "example": "category" + }, + "parentId": { + "type": "number", + "description": "父级分类ID", + "example": 0 + } + }, + "required": [ + "id" + ] + }, + "Response": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "状态码", + "example": 2000, + "format": "int32" + }, + "message": { + "type": "string", + "description": "提示信息", + "example": "请求成功" + } + }, + "required": [ + "code", + "message" + ] + } + } + }, + "externalDocs": { + "description": "JSON数据", + "url": "/openapi.json" + } +} \ No newline at end of file diff --git a/scripts/openapi/t.ts b/scripts/openapi/t.ts new file mode 100644 index 0000000..c95bcc1 --- /dev/null +++ b/scripts/openapi/t.ts @@ -0,0 +1,11 @@ +import parser from '@apidevtools/swagger-parser' +import apiJson from './openapi.json' +import fs from 'fs' + +const run = async () => { + const api = await parser.validate(apiJson as any) + console.log(api); + fs.writeFileSync('./openapi1.json', JSON.stringify(api, null, 2)) +} + +run() \ No newline at end of file diff --git a/tsconfig.node.json b/tsconfig.node.json index f377885..e83357f 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -8,7 +8,7 @@ }, "include": [ "vite.config.ts", - "scripts/vite/**/*", + "scripts/vite/**/*.ts", "scripts/vite/icon-file.json", "package.json", "src/types/env.d.ts"