staff.js 1.1 KB

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 人员表
  5. const StaffSchema = {
  6. name: { type: String, required: true, maxLength: 200 }, // 姓名
  7. gender: { type: String, required: true, maxLength: 200 }, // 性别,0-女,1-男
  8. phone: { type: String, required: false, maxLength: 200 }, // 个人电话
  9. address: { type: String, required: false, maxLength: 200 }, // 家庭住址
  10. birthday: { type: String, required: false, maxLength: 200 }, // 出生日期
  11. id_number: { type: String, required: false, maxLength: 200 }, // 身份证号
  12. dept_id: { type: String, required: false, maxLength: 200 }, // 部门id
  13. level_id: { type: String, required: false, maxLength: 200 }, // 职务id
  14. sort: { type: String, required: false, maxLength: 200 }, // 排序号
  15. };
  16. const schema = new Schema(StaffSchema, { toJSON: { virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Staff', schema, 'staff');
  22. };