|
@@ -16,6 +16,20 @@ class TeacherService extends CrudService {
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
}
|
|
|
|
|
|
+ async query(info, { skip, limit }) {
|
|
|
+ console.log(skip, limit);
|
|
|
+ let res = await this.model
|
|
|
+ .find(info)
|
|
|
+ .skip(Number(skip))
|
|
|
+ .limit(Number(limit));
|
|
|
+ res = JSON.parse(JSON.stringify(res));
|
|
|
+ for (const tea of res) {
|
|
|
+ const r = await this.umodel.findOne({ uid: tea._id });
|
|
|
+ if (r) tea.openid = _.get(r, 'openid');
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
// 根据状态删除教师信息
|
|
|
async deleteByStatus({ status }) {
|
|
|
await this.model.deleteMany({ status });
|
|
@@ -32,10 +46,7 @@ class TeacherService extends CrudService {
|
|
|
return await this.model.find({ _id: { $in: ids } });
|
|
|
}
|
|
|
// 检查教师
|
|
|
- async checkarrange({ id, date }) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ async checkarrange({ id, date }) {}
|
|
|
|
|
|
async status(data) {
|
|
|
const { teachersid, zlscore, msscore, status, remark } = data;
|
|
@@ -52,9 +63,19 @@ class TeacherService extends CrudService {
|
|
|
let detail = '';
|
|
|
if (status === '1') {
|
|
|
const passwd = stringRandom();
|
|
|
- detail = '您的账号身份已确认,密码为:' + passwd + '请尽快登录账号上传课件资料附件';
|
|
|
+ detail =
|
|
|
+ '您的账号身份已确认,密码为:' +
|
|
|
+ passwd +
|
|
|
+ '请尽快登录账号上传课件资料附件';
|
|
|
// 状态更新后创建教师用户
|
|
|
- const newdata = { name: teacher.name, mobile: teacher.phone, type: '3', uid: teacher.id, gender: teacher.gender, passwd };
|
|
|
+ const newdata = {
|
|
|
+ name: teacher.name,
|
|
|
+ mobile: teacher.phone,
|
|
|
+ type: '3',
|
|
|
+ uid: teacher.id,
|
|
|
+ gender: teacher.gender,
|
|
|
+ passwd,
|
|
|
+ };
|
|
|
await this.ctx.service.user.create(newdata);
|
|
|
} else if (status === '4') {
|
|
|
detail = '您已通过审核被正式录入教师库';
|
|
@@ -66,11 +87,22 @@ class TeacherService extends CrudService {
|
|
|
console.log(user);
|
|
|
|
|
|
if (user && user.openid) {
|
|
|
- await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, user.openid, '您有一个新的通知', detail, date, remark);
|
|
|
+ await this.ctx.service.weixin.sendTemplateMsg(
|
|
|
+ this.ctx.app.config.REVIEW_TEMPLATE_ID,
|
|
|
+ user.openid,
|
|
|
+ '您有一个新的通知',
|
|
|
+ detail,
|
|
|
+ date,
|
|
|
+ remark
|
|
|
+ );
|
|
|
} else {
|
|
|
- await this.ctx.service.util.sendMail(teacher.email, '账号审核', detail, '');
|
|
|
+ await this.ctx.service.util.sendMail(
|
|
|
+ teacher.email,
|
|
|
+ '账号审核',
|
|
|
+ detail,
|
|
|
+ ''
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -81,9 +113,7 @@ class TeacherService extends CrudService {
|
|
|
// 取得excle中数据
|
|
|
const _filepath = this.ctx.app.config.baseUrl + filepath;
|
|
|
console.log(_filepath);
|
|
|
- const teadatas = await this.getImportXLSXData(
|
|
|
- _filepath
|
|
|
- );
|
|
|
+ const teadatas = await this.getImportXLSXData(_filepath);
|
|
|
// 将得到的数据校验
|
|
|
const datacheck = await this.datacheck(teadatas);
|
|
|
if (datacheck.errorcode === '1') {
|
|
@@ -91,7 +121,10 @@ class TeacherService extends CrudService {
|
|
|
}
|
|
|
// 将数据存入数据库中
|
|
|
for (const tea of teadatas) {
|
|
|
- const res = await this.model.findOne({ idnumber: tea.idnumber, name: tea.name });
|
|
|
+ const res = await this.model.findOne({
|
|
|
+ idnumber: tea.idnumber,
|
|
|
+ name: tea.name,
|
|
|
+ });
|
|
|
if (res) {
|
|
|
res.xsscore = tea.xsscore;
|
|
|
await res.save();
|
|
@@ -159,7 +192,6 @@ class TeacherService extends CrudService {
|
|
|
}
|
|
|
return { errorcode, errormsg };
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
module.exports = TeacherService;
|