attendance.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 考勤信息表
  5. const attendInfo = new Schema({
  6. date: { type: String, required: false, maxLength: 200 }, // 日期
  7. time: { type: String, required: false, maxLength: 200 }, // 时间
  8. type: { type: String, required: false, maxLength: 10 }, // 考勤类别0、上课考勤 1、寝室考勤
  9. status: { type: String, required: false, maxLength: 200 }, // 是否签到,0-未签到,1-签到,2-迟到
  10. });
  11. // 考勤表
  12. const AttendanceSchema = {
  13. planyearid: { type: String, required: false, maxLength: 200 }, // 大批次id
  14. planid: { type: String, required: false, maxLength: 200 }, // 计划id
  15. termid: { type: String, required: false, maxLength: 200 }, // 期id
  16. batchid: { type: String, required: false, maxLength: 200 }, // 批次id
  17. classid: { type: String, required: false, maxLength: 200 }, // 班级id
  18. schid: { type: String, required: false, maxLength: 200 }, // 学校id
  19. schname: { type: String, required: false, maxLength: 200 }, // 学校名称
  20. studentid: { type: String, required: false, maxLength: 200 }, // 学生id
  21. stuname: { type: String, required: false, maxLength: 200 }, // 学生姓名
  22. attend: { type: [ attendInfo ], select: true }, // 考勤信息
  23. };
  24. const schema = new Schema(AttendanceSchema, { toJSON: { virtuals: true } });
  25. schema.index({ id: 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Attendance', schema, 'attendance');
  30. };