enrollment.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 学籍信息信息库
  5. const SchemaDefine = {
  6. schid: { type: String, required: true, maxLength: 64 }, // 学校ID,等同于yxdm
  7. year: { type: String, required: true, maxLength: 64 }, // 毕业年份
  8. xh: { type: String, required: true, maxLength: 64 }, // 学号
  9. xm: { type: String, required: true, maxLength: 64 }, // 姓名
  10. sfzh: { type: String, required: true, maxLength: 64 }, // 身份证号
  11. xb: { type: String, required: true, maxLength: 64 }, // 性别
  12. mz: String, // 民族
  13. zzmm: String, // 政治面貌
  14. yxdm: { type: String, required: true, maxLength: 64 }, // 院校代码
  15. yxmc: { type: String, required: true, maxLength: 64 }, // 院校名称
  16. zydm: String, // 专业代码
  17. zymc: { type: String, required: true, maxLength: 64 }, // 专业名称
  18. xldm: String, // 学历代码
  19. xl: { type: String, required: true, maxLength: 64 }, // 学历
  20. syszddm: String, // 生源所在地代码
  21. syszd: String, // 生源所在地
  22. szyx: String, // 所在院系
  23. szbj: String, // 所在班级
  24. };
  25. const schema = new Schema(SchemaDefine, { toJSON: { virtuals: true } });
  26. schema.index({ year: 1 });
  27. schema.index({ year: 1, schid: 1 });
  28. schema.index({ schid: 1, xh: 1 }, { unique: true, sparse: true }); // 同一学校学号必须唯一
  29. schema.plugin(metaPlugin);
  30. module.exports = app => {
  31. const { mongoose } = app;
  32. return mongoose.model('Enrollment', schema, 'stud_enrollment');
  33. };