其他分享
首页 > 其他分享> > Biz-SIP中间件之xbank项目实战(3)——账户域服务的开发

Biz-SIP中间件之xbank项目实战(3)——账户域服务的开发

作者:互联网

xbank项目版本库:https://gitee.com/szhengye/xbank.git

项目实践:账户域服务的开发

1. Account领域服务的封装

Account领域服务是和Customer领域服务并列的,Account领域服务的封装,依次有以下步骤:

另外,Account领域服务在封装时,涉及到多个接口调用,对每个接口采用命令执行器(Command Executor),所有的接口实现继承AbstractBeanCmdExe类来实现:
image.png

2. Account服务在适配层和应用层的开发和对外暴露

把sink服务,暴露给适配层接口调用,有2种方案:

方案一:

通过sink-service类型,打通适配层和应用层:直接把account领域服务所对应的sink,直接暴露给Biz-SIP开放平台接口。

接口测试如下:

$ curl -H "Content-Type:application/json" -H "Biz-Service-Id:sink/account" -X POST --data '{"methodName":"getAccountListByCustomerId","params":["001"]}' http://localhost:8888/api|jq

{
  "code": 0,
  "message": "success",
  "extMessage": null,
  "traceId": "2280472dd72c4ee4a2b7214604e9cf27",
  "parentTraceId": null,
  "timestamp": 1630751382623,
  "data": {
    "result": [
      {
        "accountId": "0001",
        "balance": 100,
        "customerId": "001"
      },
      {
        "accountId": "0002",
        "balance": 200,
        "customerId": "001"
      }
    ]
  }
}

方案二:

通过bean-service,打通适配层和应用层:

接口测试如下:

$ curl http://localhost:9001/personal/getAccountListByCustomerId\?customerId=001|jq

[
  {
    "accountId": "0001",
    "balance": 100,
    "customerId": "001"
  },
  {
    "accountId": "0002",
    "balance": 200,
    "customerId": "001"
  }
]

Biz-SIP官方网站:http://bizsip.bizmda.com
Gitee:https://gitee.com/szhengye/biz-sip

标签:SIP,服务,适配,中间件,接口,Biz,sink,xbank
来源: https://blog.csdn.net/shizhengye/article/details/120687974