Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Controller 报错,以下是代码片段 #87

Open
weijian702 opened this issue Jun 24, 2020 · 0 comments
Open

@Controller 报错,以下是代码片段 #87

weijian702 opened this issue Jun 24, 2020 · 0 comments

Comments

@weijian702
Copy link

import { Controller } from "egg";
/**
*@controller eccmimutecd
*/

class EccmimutecdController extends Controller {
/**

  • @summary text
  • @description test
  • @router get /api/vi/eccmimutecd/index
  • @request body string starttime
  • @response 200 Jsonbody ok
    */
    public async index() {
    const { ctx } = this; // 当前请求的上下文 Context 对象实例
    const Op = require("Sequelize").Op; // 获取sequelize的Op 属性
    const body = ctx.request.body; // 获取请求body
    const starttime = body.starttime; // 获取请求body 的starttime值
    const endtime = body.endtime; // 获取请求body 的endtime 值
    const data = await ctx.model.EccmonMimuteCd.findAll({
    where: {
    time: { [Op.between]: [starttime, endtime] },
    },
    });
    this.Jsonbody(data);
    }
    Jsonbody(data) {
    this.ctx.body = {
    code: 200,
    result: data,
    msg: "sucess",
    };
    }
    }

module.exports = EccmimutecdController;

contract:

request.ts:
module.exports = {
EccmonMimuteCd: {
starttime: { type: 'string', required: true, example: '2020-06-24 10:00:01' },

}

}
response.ts:
module.exports = {
JsonBody: {
result:{ type: 'string'},
}
}

错误信息:
020-06-24 18:31:39,629 ERROR 177792 [-/127.0.0.1/-/0ms GET /] nodejs.TypeError: Cannot read property 'prototype' of undefined
at generateAPIFunc (D:\egg-example\init\node_modules\egg-swagger-doc\lib\document\index.js:190:22)
at getTag_Path (D:\egg-example\init\node_modules\egg-swagger-doc\lib\document\index.js:115:18)
at buildDocument (D:\egg-example\init\node_modules\egg-swagger-doc\lib\document\index.js:50:14)
at documentInit (D:\egg-example\init\node_modules\egg-swagger-doc\lib\document\index.js:497:7)
at module.exports.swaggerInit (D:\egg-example\init\node_modules\egg-swagger-doc\lib\index.js:10:3)
at D:\egg-example\init\node_modules\egg-swagger-doc\app.js:8:5
at Object.callFn (D:\egg-example\init\node_modules\egg-core\lib\utils\index.js:44:42)
at D:\egg-example\init\node_modules\egg-core\lib\lifecycle.js:256:13
at processTicksAndRejections (internal/process/task_queues.js:79:11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant