/**
 * 求职信
 */
'use strict';
const Schema = require('mongoose').Schema;
const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');

// 求职信信息
const SchemaDefine = {
  post_id: { type: String, require: true }, // 职位ID
  resume_id: { type: String, require: true }, // 简历ID(学生ID)
  studname: { type: String, required: true, maxLength: 64 }, // 学生姓名
  corpname: { type: String, required: true, maxLength: 128 }, // 企业名称
  title: { type: String, required: true, maxLength: 128 }, // 职位标题
  status: { type: String, default: '0' }, // 状态: 0-新投递,未接收;1-已接收;2-已回绝
  type: { type: String, default: '0' }, // 求职信类型:0-在线招聘;1-招聘会;2-宣讲会;
  origin: { type: String, require: false }, // 信息来源ID:招聘信息ID、招聘会ID
  remark: { type: String, required: false, maxLength: 256 },
};
const schema = new Schema(SchemaDefine, { toJSON: { virtuals: true } });
schema.index({ post_id: 1 });
schema.index({ resume_id: 1 });
schema.index({ post_id: 1, resume_id: 1 }, { unique: true });
schema.plugin(metaPlugin);

module.exports = app => {
  const { mongoose } = app;
  return mongoose.model('JobsMsg', schema, 'jobs_msg');
};