forked from youlaitech/vue3-element-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.mock.ts
More file actions
189 lines (181 loc) · 4.06 KB
/
user.mock.ts
File metadata and controls
189 lines (181 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import { defineMock } from "./base";
export default defineMock([
{
url: "users/me",
method: ["GET"],
body: {
code: "00000",
data: {
userId: 2,
nickname: "系统管理员",
username: "admin",
avatar:
"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
roles: ["ROOT"],
perms: [
"sys:menu:delete",
"sys:dept:edit",
"sys:dict_type:add",
"sys:dict:edit",
"sys:dict:delete",
"sys:dict_type:edit",
"sys:menu:add",
"sys:user:add",
"sys:role:edit",
"sys:dept:delete",
"sys:user:edit",
"sys:user:delete",
"sys:user:password:reset",
"sys:dept:add",
"sys:role:delete",
"sys:dict_type:delete",
"sys:menu:edit",
"sys:dict:add",
"sys:role:add",
"sys:user:query",
"sys:user:export",
],
},
msg: "一切ok",
},
},
{
url: "users/page",
method: ["GET"],
body: {
code: "00000",
data: {
list: [
{
id: 2,
username: "admin",
nickname: "系统管理员",
mobile: "17621210366",
gender: 1,
avatar:
"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
email: "",
status: 1,
deptId: 1,
roleIds: [2],
},
{
id: 3,
username: "test",
nickname: "测试小用户",
mobile: "17621210366",
gender: 1,
avatar:
"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
email: "youlaitech@163.com",
status: 1,
deptId: 3,
roleIds: [3],
},
],
total: 2,
},
msg: "一切ok",
},
},
// 新增用户
{
url: "users",
method: ["POST"],
body({ body }) {
return {
code: "00000",
data: null,
msg: "新增用户" + body.nickname + "成功",
};
},
},
// 获取用户表单数据
{
url: "users/:userId/form",
method: ["GET"],
body: ({ params }) => {
return {
code: "00000",
data: userMap[params.userId],
msg: "一切ok",
};
},
},
// 修改用户
{
url: "users/:userId",
method: ["PUT"],
body({ body }) {
return {
code: "00000",
data: null,
msg: "修改用户" + body.nickname + "成功",
};
},
},
// 删除用户
{
url: "users/:userId",
method: ["DELETE"],
body({ params }) {
return {
code: "00000",
data: null,
msg: "删除用户" + params.id + "成功",
};
},
},
// 重置密码
{
url: "users/:userId/password",
method: ["PATCH"],
body({ query }) {
return {
code: "00000",
data: null,
msg: "重置密码成功,新密码为:" + query.password,
};
},
},
// 导出Excel
{
url: "users/_export",
method: ["GET"],
headers: {
"Content-Disposition":
"attachment; filename=%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8.xlsx",
"Content-Type":
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
},
]);
// 用户映射表数据
const userMap: Record<string, any> = {
2: {
id: 2,
username: "admin",
nickname: "系统管理员",
mobile: "17621210366",
gender: 1,
avatar:
"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
email: "",
status: 1,
deptId: 1,
roleIds: [2],
},
3: {
id: 3,
username: "test",
nickname: "测试小用户",
mobile: "17621210366",
gender: 1,
avatar:
"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
email: "youlaitech@163.com",
status: 1,
deptId: 3,
roleIds: [3],
},
};