member-doc/response.md
zhouyangyang a4b70328c6 提交
2022-06-14 19:36:15 +08:00

27 lines
890 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 统一响应
目前会员中心工程中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();
}
```