|
@@ -29,6 +29,20 @@ class UploadtaskService extends CrudService {
|
|
|
}
|
|
|
return { data, total };
|
|
|
}
|
|
|
+ async create(data) {
|
|
|
+ const { studentid, lessonid } = data;
|
|
|
+ let res = await this.model.findOne({ studentid, lessonid });
|
|
|
+ if (res) {
|
|
|
+ // 存在数据,但是页面还是创建提交,需要进行修改
|
|
|
+ if (_.get(data, 'picurl')) res.picurl = _.get(data, 'picurl');
|
|
|
+ if (_.get(data, 'taskid')) res.taskid = _.get(data, 'taskid');
|
|
|
+ if (_.get(data, 'answers')) res.picurl = _.get(data, 'answers');
|
|
|
+ res = await res.save();
|
|
|
+ } else {
|
|
|
+ res = await this.model.create(data);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = UploadtaskService;
|