User.entity.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { modelOptions, prop } from '@typegoose/typegoose';
  2. import { BaseModel } from 'free-midway-component';
  3. import isString = require('lodash/isString');
  4. @modelOptions({
  5. schemaOptions: { collection: 'User' },
  6. })
  7. export class User extends BaseModel {
  8. @prop({ required: true, index: true, zh: '姓名' })
  9. name: string;
  10. @prop({ required: true, index: true, zh: '联系电话' })
  11. tel: string;
  12. @prop({
  13. required: false,
  14. index: false,
  15. zh: '密码',
  16. select: false,
  17. set: (val: string | object) => {
  18. if (isString(val)) {
  19. return { secret: val };
  20. }
  21. return val;
  22. },
  23. })
  24. password: {
  25. secret: string;
  26. };
  27. @prop({
  28. required: false,
  29. index: true,
  30. zh: '性别',
  31. remark: '0:男;1女;2未知',
  32. default: '2',
  33. })
  34. gender: string;
  35. @prop({ required: false, index: true, zh: '角色' })
  36. role: string;
  37. @prop({ required: false, index: true, zh: '所属街道' })
  38. street: string;
  39. @prop({ required: false, index: false, zh: '所属社区' })
  40. community: string;
  41. @prop({ required: false, index: true, zh: '微信id' })
  42. openid: string;
  43. @prop({
  44. required: false,
  45. index: true,
  46. zh: '状态',
  47. remark: '0-待审核;1-审核成功;2-审核失败',
  48. default: '0',
  49. })
  50. status: string;
  51. }