|
@@ -6,7 +6,7 @@ class PaperService extends Service {
|
|
constructor(ctx) {
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
super(ctx);
|
|
this.model = this.ctx.model.Paper;
|
|
this.model = this.ctx.model.Paper;
|
|
- this.bankModel = this.ctx.model.bank;
|
|
|
|
|
|
+ this.bankModel = this.ctx.model.Bank;
|
|
}
|
|
}
|
|
async create({ userName, userId, list }) {
|
|
async create({ userName, userId, list }) {
|
|
assert(userName, '用户名不存在');
|
|
assert(userName, '用户名不存在');
|
|
@@ -14,10 +14,12 @@ class PaperService extends Service {
|
|
assert(list, '内容不存在');
|
|
assert(list, '内容不存在');
|
|
try {
|
|
try {
|
|
let fraction = 0;
|
|
let fraction = 0;
|
|
- await list.filter(async e => {
|
|
|
|
- const data = await this.bankModel.find({ title: e.title });
|
|
|
|
- if (data.answer === e.answer) fraction += data.answer;
|
|
|
|
- });
|
|
|
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
|
+ const data = await this.bankModel.findById({ _id: list[i]._id });
|
|
|
|
+ if (data.answer === list[i].answer) {
|
|
|
|
+ fraction += data.fraction;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
await this.model.create({ userName, userId, list, fraction });
|
|
await this.model.create({ userName, userId, list, fraction });
|
|
return { errcode: 0, errmsg: 'ok', data: { fraction } };
|
|
return { errcode: 0, errmsg: 'ok', data: { fraction } };
|
|
} catch (error) {
|
|
} catch (error) {
|