const Controller = require('./base')
const Response = require('../util/response')
const { parseResume } = require('../util/parseResume')

class UploadController extends Controller {
  async uploadResume (ctx) {
    let response = new Response(ctx)

    let curFile = ctx.request.files[0]

    try {
      let txt = await parseResume(curFile)
      response.success(txt)
    } catch (e) {
      response.error({
        msg: e.message,
        code: CODE_NORMAL_ERROR
      })
    }
  }
}

module.exports = UploadController
