如何通过curl调用用GrpcMethod装饰器nestjs装饰的方法?

时间:2019-11-14 08:37:52

标签: node.js typescript nestjs

让我们看一下以下代码:

SELECT
EXTRACT(MONTH FROM o.date_added) AS month,
EXTRACT(YEAR FROM o.date_added) AS year,
COUNT(o.order_id) AS orders
FROM
orders o  
LEFT JOIN
(
    SELECT
        op.order_id,
        SUM(op.quantity) AS op_qty,
        SUM(op.total) AS total,
        SUM(op.cost) AS cost            
    FROM
        order_product op 
    GROUP BY
        op.order_id
) op 
    ON op.order_id = o.order_id             
LEFT JOIN
(
    SELECT
        order_id                       
    FROM
        order_total 
    WHERE
        1 
    GROUP BY
        order_id
) ot 
    ON ot.order_id = o.order_id                        
WHERE
(
    DATE(o.date_added) >= CURRENT_DATE + interval '-24 month' 
    AND DATE(o.date_added) <= DATE(CURRENT_DATE)
)                              
GROUP BY EXTRACT(MONTH FROM o.date_added), EXTRACT(YEAR FROM o.date_added)
ORDER BY year ASC, month ASC LIMIT 25

如何通过curl调用此方法?

我试图像下面这样打电话,但没有成功。

import { Controller, Get } from '@nestjs/common';
import { GrpcMethod } from "@nestjs/microservices";
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

//  @Get()
  @GrpcMethod('A', 'B')
  getHello(): string {
    return this.appService.getHello();
  }
}

代码在这里:https://github.com/unegare/nestjs_example/blob/master/src/app.controller.ts

0 个答案:

没有答案