|
@ -14,18 +14,20 @@ const { |
|
|
|
|
|
|
|
|
class AccountController { |
|
|
class AccountController { |
|
|
async register(ctx, next) { |
|
|
async register(ctx, next) { |
|
|
const { username, password, role } = ctx.request.body; |
|
|
|
|
|
|
|
|
const { username, password, role, name } = ctx.request.body; |
|
|
try { |
|
|
try { |
|
|
const res = await createAccount( |
|
|
const res = await createAccount( |
|
|
username, |
|
|
username, |
|
|
password, |
|
|
password, |
|
|
role == "1" ? role : "0" |
|
|
|
|
|
|
|
|
role == "1" ? role : "0", |
|
|
|
|
|
name |
|
|
); |
|
|
); |
|
|
ctx.body = Response(0, "用户注册成功", { |
|
|
ctx.body = Response(0, "用户注册成功", { |
|
|
id: res.id, |
|
|
id: res.id, |
|
|
username: res.username, |
|
|
username: res.username, |
|
|
}); |
|
|
}); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
|
|
|
console.log(error); |
|
|
ctx.app.emit("error", accountRegisterError, ctx); |
|
|
ctx.app.emit("error", accountRegisterError, ctx); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|