lrf402788946 4 years ago
parent
commit
1f520c7fce
3 changed files with 17 additions and 3 deletions
  1. 14 0
      app/controller/weixin.js
  2. 1 1
      app/model/student.js
  3. 2 2
      app/service/cerconfirm.js

+ 14 - 0
app/controller/weixin.js

@@ -81,15 +81,29 @@ class WeixinController extends Controller {
         if (user) {
           const token = await this.ctx.service.login.createJwt(user);
           if (user.type === '4') {
+            // 学生
+            // 检查学生是否已退出,学生表的isComming是不是2,如果是2 就跳到别的地方提示您已退出
+            const stu = this.ctx.service.student.fetch({ id: uid });
+            if (stu) {
+              const { isComming } = stu;
+              if (isComming && isComming === '2') {
+                const refuse = `${this.app.config.baseUrl}/msgconfirm/isleave`;
+                this.ctx.redirect(refuse);
+              }
+            }
             const to_uri = urljoin(redirect_uri, `?token=${token}`);
             // TODO: 重定性页面
             this.ctx.redirect(to_uri);
+
+
           } else if (user.type === '1') {
+            // 班主任
             const touri = `${this.app.config.baseUrl}/mobiledirtea`;
             const to_uri = urljoin(touri, `?token=${token}`);
             // TODO: 重定性页面
             this.ctx.redirect(to_uri);
           } else if (user.type === '3') {
+            // 教师
             const touri = `${this.app.config.baseUrl}/mobiledirtea`;
             const to_uri = urljoin(touri, `?token=${token}`);
             // TODO: 重定性页面

+ 1 - 1
app/model/student.js

@@ -12,7 +12,7 @@ const StudentSchema = {
   nation: { type: String, required: false, maxLength: 200, zh: '民族' }, // 民族
   insurance: { type: String, required: false, maxLength: 200, zh: '拓训时间' }, // 拓训时间
   school_name: { type: String, required: false, maxLength: 200, zh: '学校名称' }, // 学校名称
-  isComming: { type: String, default: '0', zh: '是否参培' }, // 是否签到0否,1是
+  isComming: { type: String, default: '0', zh: '是否参培' }, // 是否签到0否,1是; 2退出
   faculty: { type: String, required: false, maxLength: 200, zh: '院系' }, // 院系
   major: { type: String, required: false, maxLength: 200, zh: '专业' }, // 专业
   edua_level: { type: String, required: false, maxLength: 200, zh: '学历层次' }, // 学历层次

+ 2 - 2
app/service/cerconfirm.js

@@ -21,8 +21,8 @@ class CerconfirmService extends CrudService {
    */
   async getStudentList(data) {
     const { classid } = data;
-    // 根据范围查找学生列表
-    const stuList = await this.stumodel.find({ classid });
+    // 根据范围查找学生列表, 补充,把isComming为2的学生排除(退出的学生)
+    const stuList = await this.stumodel.find({ classid, isComming: { $ne: '2' } });
     const stuHead = _.head(stuList);
     // 一个学生没有就没必要继续了
     if (!stuHead) return [];