Update
This commit is contained in:
parent
101022258d
commit
7f89c32404
|
|
@ -1 +1,8 @@
|
||||||
// invoked in worker
|
// invoked in worker
|
||||||
|
think.beforeStartServer(async () => {
|
||||||
|
const username = 'test';
|
||||||
|
let user = await this.model("users").where({ username }).find();
|
||||||
|
if (think.isEmpty(user)) {
|
||||||
|
await this.model("users").add({ username, password: 'e10adc3949ba59abbe56e057f20f883e', email: 'ilovejiajia@qq.com' });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -606,6 +606,9 @@ module.exports = class extends Base {
|
||||||
async adviceAddAction() {
|
async adviceAddAction() {
|
||||||
let advice = this.post();
|
let advice = this.post();
|
||||||
advice.userId = this.ctx.state.user.id;
|
advice.userId = this.ctx.state.user.id;
|
||||||
|
if (this.ctx.state.user.username == 'test') {
|
||||||
|
return this.json({ code: 400, data: '', msg: `Test user forbid advice!` });
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
let res = await this.model("advices").add(advice);
|
let res = await this.model("advices").add(advice);
|
||||||
this.json({ code: 0, data: res, msg: `留言 添加成功` });
|
this.json({ code: 0, data: res, msg: `留言 添加成功` });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue