lrf402788946 4 years ago
parent
commit
96416e317d
4 changed files with 20 additions and 1 deletions
  1. 4 0
      app/controller/.trainlive.js
  2. 1 1
      app/model/trainlive.js
  3. 1 0
      app/router.js
  4. 14 0
      app/service/trainlive.js

+ 4 - 0
app/controller/.trainlive.js

@@ -63,6 +63,10 @@ module.exports = {
       count: true,
     },
   },
+  userData:{
+    params: ["!id"],
+    service: "userData",
+  },
   addUser: {
     params: ["!id"],
     requestBody: ["users"],

+ 1 - 1
app/model/trainlive.js

@@ -25,7 +25,7 @@ const trainlive = {
   user: { type: String }, // 负责人
   phone: { type: String }, // 负责人手机号
   video_data: { type: [ video ] }, // 视频
-  user_data: { type: [ user ] }, // 参加用户
+  user_data: { type: [ user ], select: false }, // 参加用户
   create_date: { type: String }, // 开始时间
   type: { type: String, default: 'train' }, // 类型
   remark: { type: String, maxLength: 200 },

+ 1 - 0
app/router.js

@@ -123,6 +123,7 @@ module.exports = app => {
   router.delete('trainlive', '/api/live/trainlive/user/:id', controller.trainlive.deleteUser);
   router.post('trainlive', '/api/live/trainlive/user/update/:id', controller.trainlive.updateUser);
   router.post('trainlive', '/api/live/trainlive/update/:id', controller.trainlive.update);
+  router.get('trainlive', '/api/live/trainlive/user/:id', controller.trainlive.userData);
   router.resources('trainlive', '/api/live/trainlive', controller.trainlive); // index、create、show、destroy
 
   router.resources('trainchat', '/api/live/trainchat', controller.trainchat); // index、create、show、destroy

+ 14 - 0
app/service/trainlive.js

@@ -27,6 +27,16 @@ class TrainliveService extends CrudService {
     return await this.model.create(body);
   }
 
+  /**
+   * 查询指定培训问诊的参会人员
+   * @param {Object} {id} 培训问诊id
+   */
+  async userData({ id }) {
+    const object = await this.model.findOne({ _id: ObjectId(id) }, 'user_data');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    return _.get(object, 'user_data');
+  }
+
   /**
    * 培训问诊管理登陆
    * @param {Object} {room_id,password} 房间号,密码
@@ -105,6 +115,10 @@ class TrainliveService extends CrudService {
     return user;
   }
 
+  /**
+   * 延长用户登陆时效
+   * @param {Object} {id} 用户id
+   */
   async userLonger({ id }) {
     const is_login = this.ctx.session[`trainlive/${id}`];
     if (!is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户登陆已失效,请重新登陆');