|
@@ -1,41 +1,37 @@
|
|
|
<?php
|
|
|
+
|
|
|
declare(strict_types=1);
|
|
|
namespace App\Controller;
|
|
|
|
|
|
use App\JsonRpc\FooterServiceInterface;
|
|
|
use App\Tools\PublicData;
|
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
+use Hyperf\HttpServer\Annotation\AutoController;
|
|
|
use App\Tools\Result;
|
|
|
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
|
|
use App\Constants\ErrorCode;
|
|
|
-use Hyperf\Context\Context;
|
|
|
-use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
-use Hyperf\HttpServer\Contract\ResponseInterface;
|
|
|
|
|
|
* Class FooterController
|
|
|
* @package App\Controller
|
|
|
*/
|
|
|
+
|
|
|
class FooterController extends AbstractController
|
|
|
{
|
|
|
-
|
|
|
|
|
|
protected ValidatorFactoryInterface $validationFactory;
|
|
|
|
|
|
|
|
|
* @var FooterServiceInterface
|
|
|
- */
|
|
|
-
|
|
|
- private $FooterServiceClient;
|
|
|
-
|
|
|
+ */
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- * 获取栏目导航
|
|
|
+
|
|
|
+ private $footerServiceClient;
|
|
|
+
|
|
|
+ * 获取底部导航
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getFooterCategory()
|
|
|
{
|
|
|
-
|
|
|
$requireData = $this->request->all();
|
|
|
if(isset($requireData['id'])){
|
|
|
$validator = $this->validationFactory->make(
|
|
@@ -48,7 +44,8 @@ class FooterController extends AbstractController
|
|
|
]
|
|
|
);
|
|
|
$data[] = ['id',$requireData['id']];
|
|
|
- }elseif(isset($requireData['web_name'])){
|
|
|
+ }else{
|
|
|
+ if(isset($requireData['web_name'])){
|
|
|
$validator = $this->validationFactory->make(
|
|
|
$requireData,
|
|
|
[
|
|
@@ -59,21 +56,21 @@ class FooterController extends AbstractController
|
|
|
]
|
|
|
);
|
|
|
$data[] = ['web_name',$requireData['web_name']];
|
|
|
- }elseif(isset($requireData['footer_category'])){
|
|
|
+ }elseif(isset($requireData['footer_category'])){
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'footer_category' =>'required'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'footer_category.required' => '底部导航名称不能为空'
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ $data[] = ['footer_category',$requireData['footer_category']];
|
|
|
+ }else{
|
|
|
+ $data = null;
|
|
|
+ }
|
|
|
$validator = $this->validationFactory->make(
|
|
|
- $requireData,
|
|
|
- [
|
|
|
- 'footer_category' =>'required'
|
|
|
- ],
|
|
|
- [
|
|
|
- 'footer_category.required' => '底部导航名称不能为空'
|
|
|
- ]
|
|
|
- );
|
|
|
- $data[] = ['footer_category',$requireData['footer_category']];
|
|
|
- }else{
|
|
|
- $data = null;
|
|
|
- }
|
|
|
- $validator = $this->validationFactory->make(
|
|
|
$requireData,
|
|
|
[
|
|
|
'page' =>'required',
|
|
@@ -83,19 +80,22 @@ class FooterController extends AbstractController
|
|
|
'page.required' => '第几页不能为空',
|
|
|
'pageSize.required' => '每页显示数量不能为空'
|
|
|
]
|
|
|
- );
|
|
|
- $data[] = ['page',$requireData['page']];
|
|
|
- $data[] = ['pageSize',$requireData['pageSize']];
|
|
|
+ );
|
|
|
+ $data[] = ['page',$requireData['page']];
|
|
|
+ $data[] = ['pageSize',$requireData['pageSize']];
|
|
|
+ }
|
|
|
if ($validator->fails()){
|
|
|
- $errorMessage = $validator->errors()->first();
|
|
|
+ $errorMessage = $validator->errors()->all();
|
|
|
return Result::error($errorMessage);
|
|
|
}
|
|
|
- $result = $this->FooterServiceClient->getFooterCategory($data);
|
|
|
- if ($result['code'] != ErrorCode::SUCCESS) {
|
|
|
- return Result::error($result['message'],0,[]);
|
|
|
- }
|
|
|
- return Result::success($result['data']);
|
|
|
+ var_dump($data);
|
|
|
+ $result = $this->footerServiceClient->getFooterCategory($data);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}
|