swagger2api-v3 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -378
- package/dist/cli/index.js +50 -38
- package/dist/core/generator.js +2 -1
- package/dist/index.js +9 -5
- package/package.json +68 -68
- package/dist/api/authcontroller/index.d.ts +0 -11
- package/dist/api/authcontroller/index.js +0 -21
- package/dist/api/index.d.ts +0 -8
- package/dist/api/index.js +0 -24
- package/dist/api/menucontroller/index.d.ts +0 -9
- package/dist/api/menucontroller/index.js +0 -18
- package/dist/api/types.d.ts +0 -65
- package/dist/api/types.js +0 -2
- package/dist/api/usercontroller/index.d.ts +0 -41
- package/dist/api/usercontroller/index.js +0 -73
package/README.md
CHANGED
|
@@ -1,63 +1,50 @@
|
|
|
1
1
|
# Swagger2API-v3
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
一个强大的命令行工具,用于从 Swagger/OpenAPI 文档自动生成 TypeScript 接口代码。
|
|
4
4
|
|
|
5
|
-
## 特性
|
|
5
|
+
## ✨ 特性
|
|
6
6
|
|
|
7
|
-
- 🚀
|
|
8
|
-
- 📁
|
|
9
|
-
- 📝
|
|
10
|
-
- 🎨
|
|
11
|
-
- ⚙️
|
|
12
|
-
- 🔧 **CLI
|
|
7
|
+
- 🚀 **快速生成** - 从 Swagger JSON 快速生成 TypeScript 接口代码
|
|
8
|
+
- 📁 **智能分组** - 支持按 Swagger 标签自动分组生成文件
|
|
9
|
+
- 📝 **详细注释** - 自动生成包含描述、参数、返回值的详细注释
|
|
10
|
+
- 🎨 **代码格式化** - 支持自定义格式化命令
|
|
11
|
+
- ⚙️ **环境适配** - 自动检测项目环境,生成对应格式的配置文件
|
|
12
|
+
- 🔧 **CLI 工具** - 提供完整的命令行工具
|
|
13
13
|
|
|
14
|
-
## 安装
|
|
14
|
+
## 📦 安装
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
#
|
|
18
|
-
|
|
17
|
+
# 全局安装
|
|
18
|
+
npm install -g swagger2api-v3
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# 项目依赖
|
|
21
21
|
npm install swagger2api-v3
|
|
22
|
-
|
|
23
|
-
# 使用 yarn
|
|
24
|
-
yarn add swagger2api-v3
|
|
25
22
|
```
|
|
26
23
|
|
|
27
|
-
## 快速开始
|
|
24
|
+
## 🚀 快速开始
|
|
28
25
|
|
|
29
26
|
### 1. 初始化配置文件
|
|
30
27
|
|
|
31
28
|
```bash
|
|
32
|
-
|
|
33
|
-
npx swagger2api-v3 init
|
|
29
|
+
swagger2api-v3 init
|
|
34
30
|
```
|
|
35
31
|
|
|
36
|
-
### 2.
|
|
32
|
+
### 2. 配置文件说明
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
工具会根据项目环境自动生成对应格式的配置文件:
|
|
35
|
+
|
|
36
|
+
**CommonJS 环境** (`"type": "commonjs"` 或未设置):
|
|
37
|
+
```javascript
|
|
39
38
|
const config = {
|
|
40
|
-
// Swagger JSON 文件路径或 URL
|
|
41
39
|
input: 'https://petstore.swagger.io/v2/swagger.json',
|
|
42
|
-
|
|
43
|
-
// 输出目录
|
|
44
40
|
output: './src/api',
|
|
45
|
-
|
|
46
|
-
// request 导入路径模板
|
|
47
|
-
importTemplate: "import { request } from '../../utils/request';",
|
|
48
|
-
|
|
49
|
-
// 生成器类型
|
|
41
|
+
importTemplate: "import { request } from '@/utils/request';",
|
|
50
42
|
generator: 'typescript',
|
|
51
|
-
|
|
52
|
-
// 按标签分组生成文件
|
|
53
43
|
groupByTags: true,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
lint: '
|
|
57
|
-
|
|
58
|
-
// 生成选项
|
|
44
|
+
overwrite: true,
|
|
45
|
+
prefix: '',
|
|
46
|
+
lint: 'prettier --write',
|
|
59
47
|
options: {
|
|
60
|
-
// 是否添加注释
|
|
61
48
|
addComments: true
|
|
62
49
|
}
|
|
63
50
|
};
|
|
@@ -65,169 +52,50 @@ const config = {
|
|
|
65
52
|
module.exports = config;
|
|
66
53
|
```
|
|
67
54
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# 或者通过 npm script
|
|
75
|
-
npm run swagger:generate
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## NPM 脚本
|
|
79
|
-
|
|
80
|
-
在 `package.json` 中添加以下脚本:
|
|
81
|
-
|
|
82
|
-
```json
|
|
83
|
-
{
|
|
84
|
-
"scripts": {
|
|
85
|
-
"swagger:generate": "npx swagger2api-v3 generate",
|
|
86
|
-
"swagger:run": "npx swagger2api-v3 run",
|
|
87
|
-
"swagger:init": "npx swagger2api-v3 init",
|
|
88
|
-
"swagger:validate": "npx swagger2api-v3 validate"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## CLI 命令
|
|
94
|
-
|
|
95
|
-
### `swagger2api-v3 run`
|
|
96
|
-
|
|
97
|
-
运行 `.swagger.config.ts` 配置文件生成接口代码:
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
# 使用默认配置文件
|
|
101
|
-
swagger2api-v3 run
|
|
102
|
-
|
|
103
|
-
# 指定配置文件
|
|
104
|
-
swagger2api-v3 run -c ./custom.swagger.config.ts
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### `swagger2api-v3 generate`
|
|
108
|
-
|
|
109
|
-
使用配置文件生成接口代码:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# 使用默认配置文件 (.swagger.config.ts)
|
|
113
|
-
swagger2api generate
|
|
114
|
-
|
|
115
|
-
# 或者通过 npm script
|
|
116
|
-
npm run swagger:generate
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### `swagger2api-v3 init`
|
|
120
|
-
|
|
121
|
-
初始化配置文件:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
# 创建基础配置
|
|
125
|
-
swagger2api-v3 init
|
|
126
|
-
|
|
127
|
-
# 创建示例配置
|
|
128
|
-
swagger2api-v3 init --example
|
|
55
|
+
**ES 模块环境** (`"type": "module"`):
|
|
56
|
+
```javascript
|
|
57
|
+
const config = {
|
|
58
|
+
// ... 相同配置
|
|
59
|
+
};
|
|
129
60
|
|
|
130
|
-
|
|
131
|
-
swagger2api-v3 init -o ./config/swagger.config.ts
|
|
61
|
+
export default config;
|
|
132
62
|
```
|
|
133
63
|
|
|
134
|
-
###
|
|
135
|
-
|
|
136
|
-
验证 Swagger 文档:
|
|
64
|
+
### 3. 生成接口代码
|
|
137
65
|
|
|
138
66
|
```bash
|
|
139
|
-
|
|
140
|
-
swagger2api-v3 validate -i ./swagger.json
|
|
141
|
-
|
|
142
|
-
# 使用配置文件验证
|
|
143
|
-
swagger2api-v3 validate -c ./.swagger.config.ts
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## 配置选项
|
|
147
|
-
|
|
148
|
-
### 配置文件结构
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
interface SwaggerConfig {
|
|
152
|
-
// 必需配置
|
|
153
|
-
input: string; // Swagger JSON 文件路径或 URL
|
|
154
|
-
output: string; // 输出目录
|
|
155
|
-
|
|
156
|
-
// 可选配置
|
|
157
|
-
generator?: 'typescript' | 'javascript'; // 生成器类型,默认 'typescript'
|
|
158
|
-
groupByTags?: boolean; // 是否按标签分组,默认 false
|
|
159
|
-
overwrite?: boolean; // 是否覆盖更新,默认 true
|
|
160
|
-
importTemplate?: string; // request 导入路径模板
|
|
161
|
-
lint?: string; // 代码格式化命令(如:'npm run lint')
|
|
162
|
-
|
|
163
|
-
// 生成选项
|
|
164
|
-
options?: {
|
|
165
|
-
addComments?: boolean; // 添加注释,默认 true
|
|
166
|
-
};
|
|
167
|
-
}
|
|
67
|
+
swagger2api-v3 generate
|
|
168
68
|
```
|
|
169
69
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
- **input**: Swagger JSON 文件的路径或 URL
|
|
173
|
-
- **output**: 生成代码的输出目录
|
|
174
|
-
- **generator**: 代码生成器类型,目前支持 'typescript'
|
|
175
|
-
- **groupByTags**: 是否按 Swagger 标签分组生成文件到不同文件夹
|
|
176
|
-
- **overwrite**: 是否覆盖更新,默认为 true。为 true 时会先删除输出目录下的所有文件再重新生成,为 false 时采用增量更新模式
|
|
177
|
-
- **prefix**: 接口路径公共前缀,默认为空字符串。如果配置了此项,生成的所有接口前面都会添加这个前缀
|
|
178
|
-
- **importTemplate**: 自定义 request 函数的导入语句模板
|
|
179
|
-
- **lint**: 可选的代码格式化命令,在所有文件生成完成后执行
|
|
180
|
-
- **options.addComments**: 是否在生成的代码中添加详细注释
|
|
181
|
-
|
|
182
|
-
## 代码格式化 (Lint)
|
|
70
|
+
## ⚙️ 配置选项
|
|
183
71
|
|
|
184
|
-
|
|
72
|
+
| 选项 | 类型 | 默认值 | 说明 |
|
|
73
|
+
|------|------|--------|------|
|
|
74
|
+
| `input` | string | - | Swagger JSON 文件路径或 URL |
|
|
75
|
+
| `output` | string | `'./src/api'` | 生成代码的输出目录 |
|
|
76
|
+
| `generator` | string | `'typescript'` | 代码生成器类型 |
|
|
77
|
+
| `groupByTags` | boolean | `true` | 是否按标签分组生成文件 |
|
|
78
|
+
| `overwrite` | boolean | `true` | 是否覆盖已存在的文件 |
|
|
79
|
+
| `prefix` | string | `''` | 接口路径公共前缀 |
|
|
80
|
+
| `importTemplate` | string | - | request 函数导入语句模板 |
|
|
81
|
+
| `lint` | string | - | 代码格式化命令(可选) |
|
|
82
|
+
| `options.addComments` | boolean | `true` | 是否添加详细注释 |
|
|
185
83
|
|
|
186
|
-
|
|
84
|
+
## 📁 生成的文件结构
|
|
187
85
|
|
|
188
|
-
|
|
86
|
+
### 按标签分组 (推荐)
|
|
189
87
|
|
|
190
|
-
```typescript
|
|
191
|
-
const config = {
|
|
192
|
-
// ... 其他配置
|
|
193
|
-
|
|
194
|
-
// 代码格式化命令
|
|
195
|
-
lint: 'npm run lint', // 或者 'prettier --write' 等
|
|
196
|
-
};
|
|
197
88
|
```
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
### 常用 Lint 命令示例
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
// 使用 Prettier
|
|
209
|
-
lint: 'prettier --write'
|
|
210
|
-
|
|
211
|
-
// 使用 ESLint 修复
|
|
212
|
-
lint: 'eslint --fix'
|
|
213
|
-
|
|
214
|
-
// 使用项目的 npm script
|
|
215
|
-
lint: 'npm run lint'
|
|
216
|
-
lint: 'npm run format'
|
|
217
|
-
|
|
218
|
-
// 使用 pnpm
|
|
219
|
-
lint: 'pnpm run lint'
|
|
89
|
+
src/api/
|
|
90
|
+
├── types.ts # 数据类型定义
|
|
91
|
+
├── user/ # User 相关接口
|
|
92
|
+
│ └── index.ts
|
|
93
|
+
├── auth/ # Auth 相关接口
|
|
94
|
+
│ └── index.ts
|
|
95
|
+
└── index.ts # 入口文件
|
|
220
96
|
```
|
|
221
97
|
|
|
222
|
-
###
|
|
223
|
-
|
|
224
|
-
- Lint 命令会在生成的输出目录中执行
|
|
225
|
-
- 请确保项目中已安装相应的格式化工具
|
|
226
|
-
- 如果 lint 命令执行失败,会显示错误信息但不会中断生成流程
|
|
227
|
-
|
|
228
|
-
## 生成的文件结构
|
|
229
|
-
|
|
230
|
-
### 不分组模式 (groupByTags: false)
|
|
98
|
+
### 不分组
|
|
231
99
|
|
|
232
100
|
```
|
|
233
101
|
src/api/
|
|
@@ -236,236 +104,91 @@ src/api/
|
|
|
236
104
|
└── index.ts # 入口文件
|
|
237
105
|
```
|
|
238
106
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
src/api/
|
|
243
|
-
├── types.ts # 数据类型定义
|
|
244
|
-
├── authcontroller/ # Auth 相关接口
|
|
245
|
-
│ └── index.ts
|
|
246
|
-
├── usercontroller/ # User 相关接口
|
|
247
|
-
│ └── index.ts
|
|
248
|
-
├── menucontroller/ # Menu 相关接口
|
|
249
|
-
│ └── index.ts
|
|
250
|
-
└── index.ts # 入口文件(导出所有模块)
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
## 生成的代码示例
|
|
107
|
+
## 💡 使用示例
|
|
254
108
|
|
|
255
|
-
###
|
|
109
|
+
### 生成的类型定义
|
|
256
110
|
|
|
257
111
|
```typescript
|
|
258
|
-
|
|
259
|
-
* API 类型定义
|
|
260
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
261
|
-
*/
|
|
112
|
+
// types.ts
|
|
262
113
|
export interface LoginDto {
|
|
263
|
-
|
|
114
|
+
/** 账号 */
|
|
264
115
|
account: string;
|
|
265
|
-
|
|
116
|
+
/** 密码 */
|
|
266
117
|
password: string;
|
|
267
118
|
}
|
|
268
119
|
|
|
269
|
-
export interface
|
|
270
|
-
|
|
120
|
+
export interface UserInfo {
|
|
121
|
+
/** 用户ID */
|
|
271
122
|
id: string;
|
|
272
|
-
|
|
123
|
+
/** 用户名 */
|
|
273
124
|
username: string;
|
|
274
|
-
/** 角色 */
|
|
275
|
-
roles: string[];
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export interface LoginRespDto {
|
|
279
|
-
/** 用户信息 */
|
|
280
|
-
user: any;
|
|
281
|
-
/** token */
|
|
282
|
-
token: string;
|
|
283
125
|
}
|
|
284
126
|
```
|
|
285
127
|
|
|
286
|
-
### API
|
|
128
|
+
### 生成的 API 接口
|
|
287
129
|
|
|
288
130
|
```typescript
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
import { request } from '../../utils/request';;
|
|
295
|
-
import type { LoginDto, LoginRespDto } from '../types';
|
|
131
|
+
// auth/index.ts
|
|
132
|
+
import { request } from '@/utils/request';
|
|
133
|
+
import type { LoginDto, UserInfo } from '../types';
|
|
296
134
|
|
|
297
135
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
136
|
+
* 用户登录
|
|
300
137
|
* @param data 登录参数
|
|
301
|
-
* @param config 请求配置
|
|
302
138
|
*/
|
|
303
|
-
export const
|
|
304
|
-
return request.post<
|
|
305
|
-
url: '/
|
|
306
|
-
data
|
|
307
|
-
...config
|
|
139
|
+
export const login = (data: LoginDto) => {
|
|
140
|
+
return request.post<UserInfo>({
|
|
141
|
+
url: '/auth/login',
|
|
142
|
+
data
|
|
308
143
|
});
|
|
309
|
-
}
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
### 入口文件 (index.ts)
|
|
313
|
-
|
|
314
|
-
```typescript
|
|
315
|
-
/**
|
|
316
|
-
* API 入口文件
|
|
317
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
318
|
-
*/
|
|
319
|
-
|
|
320
|
-
export * from './types';
|
|
321
|
-
export * from './authcontroller';
|
|
322
|
-
export * from './usercontroller';
|
|
323
|
-
export * from './menucontroller';
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
## 使用示例
|
|
327
|
-
|
|
328
|
-
### 基础配置示例
|
|
329
|
-
|
|
330
|
-
```typescript
|
|
331
|
-
// .swagger.config.ts
|
|
332
|
-
const config = {
|
|
333
|
-
input: 'http://localhost:3000/api/docs/json',
|
|
334
|
-
output: './src/api',
|
|
335
|
-
generator: 'typescript',
|
|
336
|
-
groupByTags: false,
|
|
337
|
-
overwrite: true,
|
|
338
|
-
prefix: '',
|
|
339
|
-
options: {
|
|
340
|
-
addComments: true
|
|
341
|
-
}
|
|
342
144
|
};
|
|
343
|
-
|
|
344
|
-
module.exports = config;
|
|
345
145
|
```
|
|
346
146
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
```typescript
|
|
350
|
-
// .swagger.config.ts
|
|
351
|
-
const config = {
|
|
352
|
-
input: 'https://petstore.swagger.io/v2/swagger.json',
|
|
353
|
-
output: './src/api',
|
|
354
|
-
importTemplate: "import { request } from '../utils/request';",
|
|
355
|
-
generator: 'typescript',
|
|
356
|
-
groupByTags: true,
|
|
357
|
-
overwrite: true,
|
|
358
|
-
prefix: '/api',
|
|
359
|
-
lint: 'prettier --write',
|
|
360
|
-
options: {
|
|
361
|
-
addComments: true
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
module.exports = config;
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
## 技术栈
|
|
369
|
-
|
|
370
|
-
- **TypeScript** - 类型安全的 JavaScript
|
|
371
|
-
- **Commander.js** - 命令行工具框架
|
|
372
|
-
- **Prettier** - 代码格式化
|
|
373
|
-
- **Axios** - HTTP 客户端(生成的代码中使用)
|
|
374
|
-
|
|
375
|
-
## 测试
|
|
376
|
-
|
|
377
|
-
项目包含完整的测试套件,包括单元测试和集成测试。
|
|
378
|
-
|
|
379
|
-
### 运行测试
|
|
147
|
+
## 🔧 CLI 命令
|
|
380
148
|
|
|
381
149
|
```bash
|
|
382
|
-
#
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
# 运行测试并监听文件变化
|
|
386
|
-
npm run test:watch
|
|
387
|
-
|
|
388
|
-
# 运行测试并生成覆盖率报告
|
|
389
|
-
npm run test:coverage
|
|
150
|
+
# 初始化配置文件
|
|
151
|
+
swagger2api-v3 init [--force]
|
|
390
152
|
|
|
391
|
-
#
|
|
392
|
-
|
|
393
|
-
```
|
|
153
|
+
# 生成接口代码
|
|
154
|
+
swagger2api-v3 generate [--config <path>]
|
|
394
155
|
|
|
395
|
-
|
|
156
|
+
# 验证配置文件
|
|
157
|
+
swagger2api-v3 validate [--config <path>]
|
|
396
158
|
|
|
159
|
+
# 查看帮助
|
|
160
|
+
swagger2api-v3 --help
|
|
397
161
|
```
|
|
398
|
-
test/
|
|
399
|
-
├── config.test.ts # 配置管理测试
|
|
400
|
-
├── typescript-generator.test.ts # TypeScript生成器测试
|
|
401
|
-
├── cli.test.ts # CLI功能测试
|
|
402
|
-
├── integration.test.ts # 集成测试
|
|
403
|
-
└── setup.ts # 测试环境设置
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### 测试覆盖率
|
|
407
162
|
|
|
408
|
-
|
|
409
|
-
- 分支覆盖率: 80%
|
|
410
|
-
- 函数覆盖率: 80%
|
|
411
|
-
- 行覆盖率: 80%
|
|
412
|
-
- 语句覆盖率: 80%
|
|
163
|
+
## 📝 NPM 脚本
|
|
413
164
|
|
|
414
|
-
|
|
165
|
+
在 `package.json` 中添加:
|
|
415
166
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
# 安装依赖
|
|
424
|
-
npm install
|
|
425
|
-
|
|
426
|
-
# 构建项目
|
|
427
|
-
npm run build
|
|
428
|
-
|
|
429
|
-
# 运行测试
|
|
430
|
-
npm test
|
|
431
|
-
|
|
432
|
-
# 启动开发模式(监听文件变化)
|
|
433
|
-
npm run test:watch
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"scripts": {
|
|
170
|
+
"api:generate": "swagger2api-v3 generate",
|
|
171
|
+
"api:init": "swagger2api-v3 init"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
434
174
|
```
|
|
435
175
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
项目使用以下工具确保代码质量:
|
|
176
|
+
## 🎨 代码格式化
|
|
439
177
|
|
|
440
|
-
|
|
441
|
-
- **Prettier**: 代码格式化
|
|
442
|
-
- **Jest**: 测试框架
|
|
443
|
-
- **ESLint**: 代码规范(推荐)
|
|
178
|
+
支持在生成完成后自动执行格式化命令:
|
|
444
179
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
6. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
453
|
-
7. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
454
|
-
8. 打开 Pull Request
|
|
455
|
-
|
|
456
|
-
### 发布流程
|
|
457
|
-
|
|
458
|
-
```bash
|
|
459
|
-
# 构建项目
|
|
460
|
-
npm run build
|
|
180
|
+
```javascript
|
|
181
|
+
// 配置文件中
|
|
182
|
+
const config = {
|
|
183
|
+
// ... 其他配置
|
|
184
|
+
lint: 'prettier --write' // 或 'eslint --fix' 等
|
|
185
|
+
};
|
|
186
|
+
```
|
|
461
187
|
|
|
462
|
-
|
|
463
|
-
npm run test:ci
|
|
188
|
+
## 🤝 贡献
|
|
464
189
|
|
|
465
|
-
|
|
466
|
-
npm publish
|
|
467
|
-
```
|
|
190
|
+
欢迎提交 Issue 和 Pull Request!
|
|
468
191
|
|
|
469
|
-
## 许可证
|
|
192
|
+
## 📄 许可证
|
|
470
193
|
|
|
471
|
-
MIT License
|
|
194
|
+
MIT License
|
package/dist/cli/index.js
CHANGED
|
@@ -97,46 +97,58 @@ program
|
|
|
97
97
|
console.error('❌ 配置文件已存在,使用 --force 参数强制覆盖');
|
|
98
98
|
process.exit(1);
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
100
|
+
// 检测当前项目的模块类型
|
|
101
|
+
let isESModule = false;
|
|
102
|
+
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
103
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
104
|
+
try {
|
|
105
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
106
|
+
isESModule = packageJson.type === 'module';
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.warn('⚠️ 无法读取package.json,使用默认CommonJS格式');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const configContent = `/**
|
|
113
|
+
* Swagger2API 配置文件
|
|
114
|
+
* 用于配置从 Swagger JSON 生成前端接口的参数
|
|
115
|
+
*/
|
|
116
|
+
const config = {
|
|
117
|
+
// Swagger JSON 文件路径或 URL
|
|
118
|
+
input: 'https://petstore.swagger.io/v2/swagger.json',
|
|
119
|
+
|
|
120
|
+
// 输出目录
|
|
121
|
+
output: './src/api',
|
|
122
|
+
|
|
123
|
+
// request 导入路径模板
|
|
124
|
+
importTemplate: "import { request } from '@/utils/request';",
|
|
125
|
+
|
|
126
|
+
// 生成器类型
|
|
127
|
+
generator: 'typescript',
|
|
128
|
+
|
|
129
|
+
// 按标签分组生成文件
|
|
130
|
+
groupByTags: true,
|
|
131
|
+
|
|
132
|
+
// 是否覆盖更新,默认为true。为true时会先删除输出目录下的所有文件
|
|
133
|
+
overwrite: true,
|
|
134
|
+
|
|
135
|
+
// 接口路径公共前缀,默认为空字符串
|
|
136
|
+
prefix: '',
|
|
137
|
+
|
|
138
|
+
// 代码格式化命令(可选)
|
|
139
|
+
lint: 'prettier --write',
|
|
140
|
+
|
|
141
|
+
// 生成选项
|
|
142
|
+
options: {
|
|
143
|
+
// 是否添加注释
|
|
144
|
+
addComments: true
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
${isESModule ? 'export default config;' : 'module.exports = config;'}
|
|
137
149
|
`;
|
|
138
150
|
try {
|
|
139
|
-
fs.writeFileSync(configPath,
|
|
151
|
+
fs.writeFileSync(configPath, configContent, 'utf-8');
|
|
140
152
|
console.log('✅ 配置文件已创建:', configPath);
|
|
141
153
|
console.log('💡 请根据需要修改配置文件,然后运行 swagger2api generate');
|
|
142
154
|
}
|
package/dist/core/generator.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -100,7 +100,7 @@ class Swagger2API {
|
|
|
100
100
|
}
|
|
101
101
|
if (errors.length > 0) {
|
|
102
102
|
console.error('❌ 配置验证失败:');
|
|
103
|
-
errors.forEach(error => console.error(` - ${error}`));
|
|
103
|
+
errors.forEach((error) => console.error(` - ${error}`));
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
return true;
|
|
@@ -115,9 +115,12 @@ async function generateFromConfig(configPath) {
|
|
|
115
115
|
const configFile = configPath || '.swagger.config.ts';
|
|
116
116
|
const fullPath = path.resolve(process.cwd(), configFile);
|
|
117
117
|
try {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
118
|
+
let config;
|
|
119
|
+
// 使用动态import加载配置文件以支持ES模块语法
|
|
120
|
+
const fileUrl = `file:///${fullPath.replace(/\\/g, '/')}?t=${Date.now()}`;
|
|
121
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
122
|
+
const configModule = await dynamicImport(fileUrl);
|
|
123
|
+
config = configModule.default || configModule;
|
|
121
124
|
const swagger2api = new Swagger2API(config);
|
|
122
125
|
if (!swagger2api.validateConfig()) {
|
|
123
126
|
process.exit(1);
|
|
@@ -125,7 +128,8 @@ async function generateFromConfig(configPath) {
|
|
|
125
128
|
await swagger2api.generate();
|
|
126
129
|
}
|
|
127
130
|
catch (error) {
|
|
128
|
-
if (error instanceof Error &&
|
|
131
|
+
if (error instanceof Error &&
|
|
132
|
+
error.message.includes('Cannot resolve module')) {
|
|
129
133
|
console.error(`❌ 找不到配置文件: ${fullPath}`);
|
|
130
134
|
console.error('请确保配置文件存在并且路径正确');
|
|
131
135
|
}
|
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "swagger2api-v3",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "从 Swagger/OpenAPI 文档生成 TypeScript API 接口的命令行工具",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"test
|
|
18
|
-
"test:
|
|
19
|
-
"test:
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"swagger:
|
|
31
|
-
"swagger:
|
|
32
|
-
"swagger:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/jest": "^29.5.0",
|
|
57
|
-
"@types/node": "^24.3.1",
|
|
58
|
-
"jest": "^29.5.0",
|
|
59
|
-
"prettier": "^3.6.2",
|
|
60
|
-
"rimraf": "^6.0.1",
|
|
61
|
-
"ts-jest": "^29.1.0",
|
|
62
|
-
"typescript": "^5.9.2"
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"axios": "^1.11.0",
|
|
66
|
-
"commander": "^12.0.0"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "swagger2api-v3",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "从 Swagger/OpenAPI 文档生成 TypeScript API 接口的命令行工具",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"bin": {
|
|
9
|
+
"swagger2api-v3": "dist/cli/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"package.json"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"test:watch": "jest --watch",
|
|
19
|
+
"test:coverage": "jest --coverage",
|
|
20
|
+
"test:ci": "jest --ci --coverage --watchAll=false",
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"clean": "rimraf dist",
|
|
23
|
+
"prebuild": "npm run clean",
|
|
24
|
+
"start": "node dist/cli/index.js",
|
|
25
|
+
"dev": "npm run build && npm start",
|
|
26
|
+
"lint": "prettier --write",
|
|
27
|
+
"generate": "npm run build && node dist/cli/index.js generate",
|
|
28
|
+
"init": "npm run build && node dist/cli/index.js init",
|
|
29
|
+
"validate": "npm run build && node dist/cli/index.js validate",
|
|
30
|
+
"swagger:generate": "npm run generate",
|
|
31
|
+
"swagger:run": "npm run generate",
|
|
32
|
+
"swagger:init": "npm run init",
|
|
33
|
+
"swagger:validate": "npm run validate"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"swagger",
|
|
37
|
+
"openapi",
|
|
38
|
+
"typescript",
|
|
39
|
+
"api",
|
|
40
|
+
"generator",
|
|
41
|
+
"cli",
|
|
42
|
+
"code-generation"
|
|
43
|
+
],
|
|
44
|
+
"author": "xiaoyang",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"homepage": "https://github.com/xiaoyang33/swagger2api-v3#readme",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/xiaoyang33/swagger2api-v3.git"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/xiaoyang33/swagger2api-v3/issues"
|
|
53
|
+
},
|
|
54
|
+
"packageManager": "pnpm@10.11.0",
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/jest": "^29.5.0",
|
|
57
|
+
"@types/node": "^24.3.1",
|
|
58
|
+
"jest": "^29.5.0",
|
|
59
|
+
"prettier": "^3.6.2",
|
|
60
|
+
"rimraf": "^6.0.1",
|
|
61
|
+
"ts-jest": "^29.1.0",
|
|
62
|
+
"typescript": "^5.9.2"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"axios": "^1.11.0",
|
|
66
|
+
"commander": "^12.0.0"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AuthController API 接口
|
|
3
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
4
|
-
*/
|
|
5
|
-
import type { LoginDto, LoginRespDto } from '../types';
|
|
6
|
-
/**
|
|
7
|
-
* 登录
|
|
8
|
-
*
|
|
9
|
-
* @param body
|
|
10
|
-
*/
|
|
11
|
-
export declare const authControllerLogin: (data: LoginDto, config?: any) => Promise<import("../../utils/request").IReqBoay<LoginRespDto>>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* AuthController API 接口
|
|
4
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.authControllerLogin = void 0;
|
|
8
|
-
const request_1 = require("../../utils/request");
|
|
9
|
-
/**
|
|
10
|
-
* 登录
|
|
11
|
-
*
|
|
12
|
-
* @param body
|
|
13
|
-
*/
|
|
14
|
-
const authControllerLogin = (data, config) => {
|
|
15
|
-
return request_1.request.post({
|
|
16
|
-
url: '/admin/auth/login',
|
|
17
|
-
data,
|
|
18
|
-
...config
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
exports.authControllerLogin = authControllerLogin;
|
package/dist/api/index.d.ts
DELETED
package/dist/api/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* API 入口文件
|
|
4
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
__exportStar(require("./types"), exports);
|
|
22
|
-
__exportStar(require("./authcontroller"), exports);
|
|
23
|
-
__exportStar(require("./usercontroller"), exports);
|
|
24
|
-
__exportStar(require("./menucontroller"), exports);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MenuController API 接口
|
|
3
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
4
|
-
*/
|
|
5
|
-
import type { MenuListRespDto } from '../types';
|
|
6
|
-
/**
|
|
7
|
-
* 菜单列表
|
|
8
|
-
*/
|
|
9
|
-
export declare const menuControllerList: (config?: any) => Promise<import("../../utils/request").IReqBoay<MenuListRespDto>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MenuController API 接口
|
|
4
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.menuControllerList = void 0;
|
|
8
|
-
const request_1 = require("../../utils/request");
|
|
9
|
-
/**
|
|
10
|
-
* 菜单列表
|
|
11
|
-
*/
|
|
12
|
-
const menuControllerList = (config) => {
|
|
13
|
-
return request_1.request.post({
|
|
14
|
-
url: '/admin/system/menus/list',
|
|
15
|
-
...config
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.menuControllerList = menuControllerList;
|
package/dist/api/types.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API 类型定义
|
|
3
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
4
|
-
*/
|
|
5
|
-
export interface LoginDto {
|
|
6
|
-
/** 账号 */
|
|
7
|
-
account: string;
|
|
8
|
-
/** 密码 */
|
|
9
|
-
password: string;
|
|
10
|
-
}
|
|
11
|
-
export interface UserInfoRespDto {
|
|
12
|
-
/** 用户ID */
|
|
13
|
-
id: string;
|
|
14
|
-
/** 用户名 */
|
|
15
|
-
username: string;
|
|
16
|
-
/** 角色 */
|
|
17
|
-
roles: string[];
|
|
18
|
-
}
|
|
19
|
-
export interface LoginRespDto {
|
|
20
|
-
/** 用户信息 */
|
|
21
|
-
user: any;
|
|
22
|
-
/** token */
|
|
23
|
-
token: string;
|
|
24
|
-
}
|
|
25
|
-
export interface UserListDto {
|
|
26
|
-
/** 页码 */
|
|
27
|
-
pageNum?: number;
|
|
28
|
-
/** 每页数量 */
|
|
29
|
-
pageSize?: number;
|
|
30
|
-
/** 用户名 */
|
|
31
|
-
username: string;
|
|
32
|
-
}
|
|
33
|
-
export interface UserListRespDto {
|
|
34
|
-
/** 列表 */
|
|
35
|
-
list: UserInfoRespDto[];
|
|
36
|
-
/** 总条数 */
|
|
37
|
-
total: number;
|
|
38
|
-
}
|
|
39
|
-
export interface CreateUserDto {
|
|
40
|
-
/** 用户名 */
|
|
41
|
-
username: string;
|
|
42
|
-
/** 密码 */
|
|
43
|
-
password: string;
|
|
44
|
-
role: {
|
|
45
|
-
id?: string;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export interface UpdateUserDto {
|
|
49
|
-
/** 用户名 */
|
|
50
|
-
username: string;
|
|
51
|
-
}
|
|
52
|
-
export interface MenuInfoRespDto {
|
|
53
|
-
/** 菜单ID */
|
|
54
|
-
id: string;
|
|
55
|
-
/** 菜单名称 */
|
|
56
|
-
name: string;
|
|
57
|
-
/** 角色 */
|
|
58
|
-
roles: string[];
|
|
59
|
-
}
|
|
60
|
-
export interface MenuListRespDto {
|
|
61
|
-
/** 列表 */
|
|
62
|
-
list: MenuInfoRespDto[];
|
|
63
|
-
/** 总条数 */
|
|
64
|
-
total: number;
|
|
65
|
-
}
|
package/dist/api/types.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UserController API 接口
|
|
3
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
4
|
-
*/
|
|
5
|
-
import type { CreateUserDto, UpdateUserDto, UserListDto, UserListRespDto } from '../types';
|
|
6
|
-
/**
|
|
7
|
-
* 用户列表
|
|
8
|
-
*
|
|
9
|
-
* @param body
|
|
10
|
-
*/
|
|
11
|
-
export declare const userControllerList: (data: UserListDto, config?: any) => Promise<import("../../utils/request").IReqBoay<UserListRespDto>>;
|
|
12
|
-
/**
|
|
13
|
-
* 创建用户
|
|
14
|
-
*
|
|
15
|
-
* @param body
|
|
16
|
-
*/
|
|
17
|
-
export declare const userControllerCreate: (data: CreateUserDto, config?: any) => Promise<import("../../utils/request").IReqBoay<any>>;
|
|
18
|
-
/**
|
|
19
|
-
* 更新用户
|
|
20
|
-
*
|
|
21
|
-
* @param body
|
|
22
|
-
*/
|
|
23
|
-
export declare const userControllerUpdate: (data: UpdateUserDto, config?: any) => Promise<import("../../utils/request").IReqBoay<any>>;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param pageNum 页码
|
|
27
|
-
* @param pageSize 每页数量
|
|
28
|
-
* @param username 用户名
|
|
29
|
-
*/
|
|
30
|
-
export declare const userControllerDetail: (params: {
|
|
31
|
-
pageNum?: number;
|
|
32
|
-
pageSize?: number;
|
|
33
|
-
username: string;
|
|
34
|
-
}, config?: any) => Promise<import("../../utils/request").IReqBoay<any>>;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param id
|
|
38
|
-
*/
|
|
39
|
-
export declare const userControllerDetail1: (params: {
|
|
40
|
-
id: string;
|
|
41
|
-
}, config?: any) => Promise<import("../../utils/request").IReqBoay<any>>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* UserController API 接口
|
|
4
|
-
* 此文件由 swagger2api 自动生成,请勿手动修改
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.userControllerDetail1 = exports.userControllerDetail = exports.userControllerUpdate = exports.userControllerCreate = exports.userControllerList = void 0;
|
|
8
|
-
const request_1 = require("../../utils/request");
|
|
9
|
-
/**
|
|
10
|
-
* 用户列表
|
|
11
|
-
*
|
|
12
|
-
* @param body
|
|
13
|
-
*/
|
|
14
|
-
const userControllerList = (data, config) => {
|
|
15
|
-
return request_1.request.post({
|
|
16
|
-
url: '/admin/system/user/list',
|
|
17
|
-
data,
|
|
18
|
-
...config
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
exports.userControllerList = userControllerList;
|
|
22
|
-
/**
|
|
23
|
-
* 创建用户
|
|
24
|
-
*
|
|
25
|
-
* @param body
|
|
26
|
-
*/
|
|
27
|
-
const userControllerCreate = (data, config) => {
|
|
28
|
-
return request_1.request.post({
|
|
29
|
-
url: '/admin/system/user/create',
|
|
30
|
-
data,
|
|
31
|
-
...config
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
exports.userControllerCreate = userControllerCreate;
|
|
35
|
-
/**
|
|
36
|
-
* 更新用户
|
|
37
|
-
*
|
|
38
|
-
* @param body
|
|
39
|
-
*/
|
|
40
|
-
const userControllerUpdate = (data, config) => {
|
|
41
|
-
return request_1.request.post({
|
|
42
|
-
url: '/admin/system/user/update',
|
|
43
|
-
data,
|
|
44
|
-
...config
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
exports.userControllerUpdate = userControllerUpdate;
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param pageNum 页码
|
|
51
|
-
* @param pageSize 每页数量
|
|
52
|
-
* @param username 用户名
|
|
53
|
-
*/
|
|
54
|
-
const userControllerDetail = (params, config) => {
|
|
55
|
-
return request_1.request.get({
|
|
56
|
-
url: '/admin/system/user/detail',
|
|
57
|
-
params,
|
|
58
|
-
...config
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
exports.userControllerDetail = userControllerDetail;
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* @param id
|
|
65
|
-
*/
|
|
66
|
-
const userControllerDetail1 = (params, config) => {
|
|
67
|
-
return request_1.request.get({
|
|
68
|
-
url: '/admin/system/user/detail1',
|
|
69
|
-
params,
|
|
70
|
-
...config
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
exports.userControllerDetail1 = userControllerDetail1;
|