attendance.js 1.2 KB

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