wangzhibo
2026-07-16 bac4362a0b7726d38a23d38f0d7913f2c2bab262
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Inject, Provide, Get } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { DemoRpcService } from '../../service/rpc';
 
/**
 * 远程RPC调用
 */
@CoolController()
export class OpenDemoRpcController extends BaseController {
  @Inject()
  demoRpcService: DemoRpcService;
 
  @Get('/call', { summary: '远程调用' })
  async call() {
    return this.ok(await this.demoRpcService.call());
  }
 
  @Get('/event', { summary: '集群事件' })
  async event() {
    await this.demoRpcService.event();
    return this.ok();
  }
 
  @Get('/transaction', { summary: '分布式事务' })
  async transaction() {
    await this.demoRpcService.transaction({ a: 1 });
    return this.ok();
  }
}