forked from cool-team-official/cool-admin-midway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
144 additions
and
139 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Inject, Post, Provide } from '@midwayjs/decorator'; | ||
import { CoolController, BaseController } from '@cool-midway/core'; | ||
import { CoolRpc } from '@cool-midway/rpc'; | ||
import { DemoRpcService } from '../../service/rpc'; | ||
|
||
/** | ||
* 微服务 | ||
*/ | ||
@Provide() | ||
@CoolController() | ||
export class DemoRpcController extends BaseController { | ||
@Inject() | ||
rpc: CoolRpc; | ||
|
||
@Inject() | ||
demoRpcService: DemoRpcService; | ||
|
||
@Post('/call', { summary: '远程调用' }) | ||
async call() { | ||
return this.ok( | ||
await this.rpc.call('goods', 'demoGoodsService', 'test', { a: 1 }) | ||
); | ||
} | ||
|
||
@Post('/event', { summary: '集群事件' }) | ||
async event() { | ||
this.rpc.broadcastEvent('test', { a: 1 }); | ||
return this.ok(); | ||
} | ||
|
||
@Post('/transaction', { summary: '分布式事务' }) | ||
async transaction() { | ||
await this.demoRpcService.transaction({ a: 1 }); | ||
return this.ok(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import { Provide } from '@midwayjs/decorator'; | ||
import { Inject, Provide } from '@midwayjs/decorator'; | ||
import { BaseService } from '@cool-midway/core'; | ||
import { CoolRpc } from '@cool-midway/rpc'; | ||
|
||
/** | ||
* 缓存 | ||
*/ | ||
@Provide() | ||
export class DemoGoodsService extends BaseService {} | ||
export class DemoGoodsService extends BaseService { | ||
@Inject() | ||
rpc: CoolRpc; | ||
|
||
async test() { | ||
console.log('调用'); | ||
} | ||
} |
Oops, something went wrong.