dealQuery.js 382 B

1234567891011
  1. 'use strict';
  2. const _ = require('lodash');
  3. // 将特殊的查询,service返回为{data,total}的情况转换为通常查询结果:即把{}展开
  4. module.exports = options => {
  5. return async function dealquery(ctx, next) {
  6. await next();
  7. const body = ctx.response.body;
  8. const { data, errcode, errmsg } = body;
  9. ctx.response.body = { ...data, errcode, errmsg };
  10. };
  11. };