user.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. lock: { // 锁信息 1:借出;2:销售;
  33. type: Number,
  34. default: 0
  35. },
  36. }, { _id: false })
  37. const userdList = mongoose.Schema({
  38. compilationId: String
  39. }, {_id: false});
  40. let modelSchema = {
  41. ssoId: {
  42. type: Number,
  43. unique: true,
  44. },
  45. // 用户名
  46. username: String,
  47. // 电子邮件
  48. email: String,
  49. // 手机号码
  50. mobile: String,
  51. // qq号码
  52. qq: {
  53. type: String,
  54. default: ''
  55. },
  56. // 真实姓名
  57. real_name: {
  58. type: String,
  59. default: ''
  60. },
  61. // 公司
  62. company: {
  63. type: String,
  64. default: ''
  65. },
  66. // 省份
  67. province: {
  68. type: Number,
  69. default: -1
  70. },
  71. version: {
  72. type: [versionSchema],
  73. default: []
  74. },
  75. // 公司类型
  76. company_type: {
  77. type: Number,
  78. default: -1
  79. },
  80. // 公司规模
  81. company_scale: {
  82. type: Number,
  83. default: -1
  84. },
  85. // 最后登录时间
  86. latest_login: {
  87. type: Number,
  88. default: 0
  89. },
  90. //最近使用编办
  91. latest_used:String,
  92. // 创建时间
  93. create_time: {
  94. type: Number,
  95. default: 0
  96. },
  97. upgrade_list:[upgrade],
  98. user_type:{
  99. type:String,
  100. default:'normal'// normal : 普通用户,test:测试用户
  101. },
  102. //使用过的费用定额,主要目的拷贝用户在该费用定额下的一些数据模板 eg:用户第一次进入该费用定额的补充定额库时,拷贝补充定额的章节树
  103. used_list: {
  104. type: [userdList],
  105. default: []
  106. },
  107. // 联系人
  108. contacts: {
  109. type: Array,
  110. default: []
  111. },
  112. // 是否邮箱已通过验证
  113. isUserActive: Number,
  114. // 是否只允许短信登录
  115. isSmsLogin: {
  116. type: Number,
  117. default: 0
  118. },
  119. // 登录异常短信通知
  120. isLoginValid: {
  121. type: Number,
  122. default: 0
  123. },
  124. welcomeShowTime:String,
  125. token: String,
  126. online_times: {
  127. type: Number,
  128. default: 0
  129. }, //最近一天的登录时长累计
  130. all_online_times: {//所有登录时长累计
  131. type: Number,
  132. default: 0
  133. },
  134. is_cld: {
  135. type: Number,
  136. default: 0, // 0为普通用户,时间戳代表CLD剔除用户并按时间戳排序
  137. },
  138. };
  139. mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));