member-doc/response.md

27 lines
890 B
Markdown
Raw Permalink Normal View History

2022-06-14 11:36:15 +00:00
## 统一响应
目前会员中心工程中app/Controller/Response/AppResponse.php 实现控制器controller统一响应开发者可以controller 实例化AppResponse进行响应切记勿用注解或di注入AppResponse导致AppResponse单列以至于返回数据异常。
代码示例:
```php
/**
* @param ApiLayerService $service
* @return ResponseInterface
* @throws MemberException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function get(ApiLayerService $service): ResponseInterface
{
$result = $service->inject($this->request)
->handle([
'logic_config' => [
EnumConstService::class,
'getEnum'
]
]);
return (new AppResponse())->setResult($result)->success();
}
```