lrf402788946 %!s(int64=4) %!d(string=hai) anos
pai
achega
50706dede3
Modificáronse 3 ficheiros con 5 adicións e 2 borrados
  1. 3 1
      app/service/attendance.js
  2. 1 0
      app/service/login.js
  3. 1 1
      app/service/student.js

+ 3 - 1
app/service/attendance.js

@@ -15,6 +15,7 @@ class AttendanceService extends CrudService {
     super(ctx, 'attendance');
     this.model = this.ctx.model.Attendance;
     this.stumodel = this.ctx.model.Student;
+    this.umodel = this.ctx.model.User;
     this.clamodel = this.ctx.model.Class;
     this.lomodel = this.ctx.model.Location;
     this.bmodel = this.ctx.model.Bedroom;
@@ -25,10 +26,11 @@ class AttendanceService extends CrudService {
     const { openid, type, ibeacon } = data;
     assert(openid && type && ibeacon, '缺少信息项');
     // 通过openid取得学生信息
-    const user = await this.ctx.service.user.findByappopenid(openid);
+    const user = await this.umodel.findOne({ appopenid: openid });
     if (!user) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '用户不存在');
     }
+    console.log(user);
     const student = await this.stumodel.findById(user.uid);
     if (!student) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '学生信息不存在');

+ 1 - 0
app/service/login.js

@@ -64,6 +64,7 @@ class LoginService extends CrudService {
       const result = await this.stuModel.findById(_userid);
       console.log(result);
       res = { userid: _userid, schid: result.schid, schname: result.school_name, termid: result.termid, batchid: result.batchid, classid: result.classid, bedroomid: result.bedroomid, bedroom: result.bedroom, job: result.job, name, type, id: _id, status, planid: result.planid };
+      console.warn(res);
     }
     const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
     return token;

+ 1 - 1
app/service/student.js

@@ -22,7 +22,7 @@ class StudentService extends CrudService {
     const { name, phone: mobile, gender } = data;
     const res = await this.model.create(data);
     if (res) {
-      const obj = { name, mobile, gender, type: '4', passwd: '12345678' };
+      const obj = { name, mobile, gender, type: '4', passwd: '12345678', uid: res._id };
       const user = await this.ctx.service.user.create(obj);
     }
     return res;