require('../conf/code.inc')
class Response {
  constructor (ctx, params) {
    this.ctx = ctx

    if (params) {
      this.send(params)
    }
  }

  send (params) {
    this.ctx.response.body = params
  }

  success (data) {
    let res = {
      msg: CODE_MSG_MAP['CODE_SUCCESS'],
      code: CODE_SUCCESS,
      data: data
    }

    this.ctx.response.body = res
  }

  error (params) {
    this.send(params)
  }
}

module.exports = Response
