user.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /**
  2. * 用户数据模型
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/7/20
  6. * @version
  7. */
  8. import mongoose from "mongoose";
  9. let Schema = mongoose.Schema;
  10. let collectionName = 'users';
  11. const invalidSchema = new Schema({
  12. invalid: Boolean,
  13. invalidDate: String,
  14. invalidBy: String //管理者名
  15. });
  16. const versionSchema = new Schema({
  17. compilationId: String,
  18. activateCode: String,
  19. activatedDate: String,
  20. activatedBy: String,
  21. invalidInfo: [invalidSchema]
  22. });
  23. let upgrade = mongoose.Schema({
  24. compilationID:String,//编办ID
  25. upgrade_time:Number,
  26. isUpgrade:Boolean,
  27. remark:String,//描述:广东办刘飞 2018-06-17 启用/关闭
  28. deadline: {
  29. type:String,
  30. default: '',
  31. },
  32. }, { _id: false })
  33. const userdList = mongoose.Schema({
  34. compilationId: String
  35. }, {_id: false});
  36. let modelSchema = {
  37. ssoId: {
  38. type: Number,
  39. unique: true,
  40. },
  41. // 用户名
  42. username: String,
  43. // 电子邮件
  44. email: String,
  45. // 手机号码
  46. mobile: String,
  47. // qq号码
  48. qq: {
  49. type: String,
  50. default: ''
  51. },
  52. // 真实姓名
  53. real_name: {
  54. type: String,
  55. default: ''
  56. },
  57. // 公司
  58. company: {
  59. type: String,
  60. default: ''
  61. },
  62. // 省份
  63. province: {
  64. type: Number,
  65. default: -1
  66. },
  67. version: {
  68. type: [versionSchema],
  69. default: []
  70. },
  71. // 公司类型
  72. company_type: {
  73. type: Number,
  74. default: -1
  75. },
  76. // 公司规模
  77. company_scale: {
  78. type: Number,
  79. default: -1
  80. },
  81. // 最后登录时间
  82. latest_login: {
  83. type: Number,
  84. default: 0
  85. },
  86. //最近使用编办
  87. latest_used:String,
  88. // 创建时间
  89. create_time: {
  90. type: Number,
  91. default: 0
  92. },
  93. upgrade_list:[upgrade],
  94. user_type:{
  95. type:String,
  96. default:'normal'// normal : 普通用户,test:测试用户
  97. },
  98. //使用过的费用定额,主要目的拷贝用户在该费用定额下的一些数据模板 eg:用户第一次进入该费用定额的补充定额库时,拷贝补充定额的章节树
  99. used_list: {
  100. type: [userdList],
  101. default: []
  102. },
  103. // 联系人
  104. contacts: {
  105. type: Array,
  106. default: []
  107. },
  108. // 是否邮箱已通过验证
  109. isUserActive: Number,
  110. // 是否只允许短信登录
  111. isSmsLogin: {
  112. type: Number,
  113. default: 0
  114. },
  115. // 登录异常短信通知
  116. isLoginValid: {
  117. type: Number,
  118. default: 0
  119. },
  120. welcomeShowTime:String,
  121. token: String,
  122. online_times: {
  123. type: Number,
  124. default: 0
  125. }, //最近一天的登录时长累计
  126. all_online_times: {//所有登录时长累计
  127. type: Number,
  128. default: 0
  129. },
  130. is_cld: {
  131. type: Number,
  132. default: 0, // 0为普通用户,时间戳代表CLD剔除用户并按时间戳排序
  133. },
  134. };
  135. mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));