iviOnlineUserModel.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. module.exports = app => {
  3. const mongoose = app.mongoose;
  4. const Schema = mongoose.Schema;
  5. const conn = app.mongooseDB.get('etlDB');
  6. // IVI登录埋点数据,记录用户每次登陆记录
  7. const IviOnlineUserSchema = new Schema({
  8. _id: { type: String }, // 主键,用户ID+年月日拼接+序号
  9. user_id: { type: String }, // 用户ID
  10. user_name: { type: String }, // 登录账号
  11. user_mobileno: { type: String }, // 登录手机号
  12. vin: { type: String }, // vin
  13. role_id: { type: String },
  14. // owner 是车主,common是使用人,guest是潜客(粉丝)
  15. login_time: { type: Number }, // 登录时间戳
  16. longitude: { type: Number }, // 登录位置-经度
  17. latitude: { type: Number }, // 登录位置-纬度
  18. // area_code: { type: String }, // 登录位置-地区编码
  19. // area_name: { type: String }, // 登录位置-地区名称
  20. // provice_code: { type: String }, // 登录位置-省份编码
  21. provice_name: { type: String }, // 登录位置-省份名称
  22. // city_code: { type: String }, // 登录位置-城市编码
  23. city_name: { type: String }, // 登录位置-城市名称
  24. county_code: { type: String }, // 登录位置-行政区编码
  25. county_name: { type: String }, // 登录位置-行政区名称
  26. // series_code: { type: String }, // 车系编码
  27. // series_name: { type: String }, // 车系名称
  28. login_mode: { type: Number }, // 登录方式 (1:人脸、2:声纹、3:密码、4:验证码、5:二维码)
  29. // FACE/SOUND/PASSWORD/VERIFICATION_CODE/QR
  30. login_state: { type: Number }, // 登录状态 (1:成功、2:失败)
  31. });
  32. IviOnlineUserSchema.index({ login_time: -1 });
  33. IviOnlineUserSchema.index({ login_time: -1, login_state: -1 });
  34. IviOnlineUserSchema.index({ login_time: -1, login_state: -1, user_id: -1 });
  35. IviOnlineUserSchema.index({ login_time: -1, login_state: -1, user_id: -1, provice_name: -1, city_name: -1 });
  36. IviOnlineUserSchema.index({ login_time: -1, login_mode: -1 });
  37. IviOnlineUserSchema.index({ login_time: -1, role_id: -1 });
  38. return conn.model('IviOnlineUser', IviOnlineUserSchema, 'ivi_online_user');
  39. };