const Sequelize = require('sequelize');

/**
 * 简历信息表模型
 * 存储用户简历的核心要素和分析结果
 */
module.exports = (db) => {
  const resume_info = db.define("resume_info", {
    // 基本信息
    sn_code: {
      comment: '设备SN码',
      type: Sequelize.STRING(50),
      allowNull: false,
      defaultValue: ''
    },
    account_id: {
      comment: '用户ID',
      type: Sequelize.STRING(50),
      allowNull: false,
      defaultValue: ''
    },
    platform: {
      comment: '平台: boss-Boss直聘, liepin-猎聘',
      type: Sequelize.STRING(20),
      allowNull: false,
      defaultValue: 'boss'
    },
    resumeId: {
      comment: '简历ID',
      type: Sequelize.STRING(50),
      allowNull: false,
      defaultValue: ''
    },

    // 个人信息
    fullName: {
      comment: '姓名',
      type: Sequelize.STRING(50),
      allowNull: true,
      defaultValue: ''
    },
    gender: {
      comment: '性别',
      type: Sequelize.STRING(10),
      allowNull: true,
      defaultValue: ''
    },
    age: {
      comment: '年龄',
      type: Sequelize.INTEGER,
      allowNull: true,
      defaultValue: 0
    },
    phone: {
      comment: '电话',
      type: Sequelize.STRING(20),
      allowNull: true,
      defaultValue: ''
    },
    email: {
      comment: '邮箱',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },
    location: {
      comment: '所在地',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },

    // 教育背景
    education: {
      comment: '学历',
      type: Sequelize.STRING(50),
      allowNull: true,
      defaultValue: ''
    },
    major: {
      comment: '专业',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },
    school: {
      comment: '毕业院校',
      type: Sequelize.STRING(200),
      allowNull: true,
      defaultValue: ''
    },
    graduationYear: {
      comment: '毕业年份',
      type: Sequelize.INTEGER,
      allowNull: true,
      defaultValue: 0
    },

    // 工作经验
    workYears: {
      comment: '工作年限',
      type: Sequelize.STRING(50),
      allowNull: true,
      defaultValue: ''
    },
    currentPosition: {
      comment: '当前职位',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },
    currentCompany: {
      comment: '当前公司',
      type: Sequelize.STRING(200),
      allowNull: true,
      defaultValue: ''
    },
    currentSalary: {
      comment: '当前薪资',
      type: Sequelize.STRING(50),
      allowNull: true,
      defaultValue: ''
    },

    // 期望信息
    expectedPosition: {
      comment: '期望职位',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },
    expectedSalary: {
      comment: '期望薪资',
      type: Sequelize.STRING(50),
      allowNull: true,
      defaultValue: ''
    },
    expectedLocation: {
      comment: '期望工作地点',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },
    expectedIndustry: {
      comment: '期望行业',
      type: Sequelize.STRING(100),
      allowNull: true,
      defaultValue: ''
    },

    // 技能和专长
    skills: {
      comment: '技能标签(JSON数组)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },
    skillDescription: {
      comment: '技能描述',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },
    certifications: {
      comment: '证书资质(JSON数组)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },

    // 项目经验
    projectExperience: {
      comment: '项目经验(JSON数组)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },

    // 工作经历
    workExperience: {
      comment: '工作经历(JSON数组)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },

    // AI分析结果
    aiSkillTags: {
      comment: 'AI提取的技能标签(JSON数组)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },
    aiStrengths: {
      comment: 'AI分析的优势',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },
    aiWeaknesses: {
      comment: 'AI分析的劣势',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },
    aiCareerSuggestion: {
      comment: 'AI职业建议',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },
    aiCompetitiveness: {
      comment: 'AI竞争力评分(0-100)',
      type: Sequelize.INTEGER,
      allowNull: true,
      defaultValue: 0
    },

    // 简历内容
    resumeContent: {
      comment: '简历完整内容(HTML或文本)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },

    // 原始数据
    originalData: {
      comment: '原始数据(JSON)',
      type: Sequelize.TEXT,
      allowNull: true,
      defaultValue: ''
    },

    // 状态信息
    isActive: {
      comment: '是否活跃简历',
      type: Sequelize.BOOLEAN,
      allowNull: true,
      defaultValue: true
    },
    isPublic: {
      comment: '是否公开',
      type: Sequelize.BOOLEAN,
      allowNull: true,
      defaultValue: true
    },

    syncTime: {
      comment: '同步时间',
      type: Sequelize.DATE,
      allowNull: true,
      defaultValue: Sequelize.NOW
    }
  }, {
    timestamps: true,
    createdAt: 'create_time',
    updatedAt: 'last_modify_time',
    indexes: [
      {
        unique: false,
        fields: ['sn_code']
      },
      {
        unique: false,
        fields: ['platform']
      },
      {
        unique: false,
        fields: ['isActive']
      },

    ]
  });

 // resume_info.sync({ force: true });
  return resume_info


};

