attendance.js 1.2 KB

123456789101112131415161718192021222324252627282930
  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. termid: { type: String, required: false, maxLength: 200 }, // 期id
  14. batchid: { type: String, required: false, maxLength: 200 }, // 批次id
  15. classid: { type: String, required: false, maxLength: 200 }, // 班级id
  16. studentid: { type: String, required: false, maxLength: 200 }, // 学生id
  17. attend: { type: [ attendInfo ], select: true }, // 考勤信息
  18. };
  19. const schema = new Schema(AttendanceSchema, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Attendance', schema, 'attendance');
  25. };