attendance.js 1.5 KB

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