|
@@ -6,13 +6,12 @@ use App\JsonRpc\NewsServiceInterface;
|
|
use App\JsonRpc\WebsiteServiceInterface;
|
|
use App\JsonRpc\WebsiteServiceInterface;
|
|
use App\Tools\PublicData;
|
|
use App\Tools\PublicData;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
+use Hyperf\HttpServer\Annotation\AutoController;
|
|
use App\Tools\Result;
|
|
use App\Tools\Result;
|
|
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
|
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
|
use App\Constants\ErrorCode;
|
|
use App\Constants\ErrorCode;
|
|
-use App\Controller\PublicController;
|
|
|
|
use Hyperf\Context\Context;
|
|
use Hyperf\Context\Context;
|
|
-use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
-use Hyperf\HttpServer\Contract\ResponseInterface;
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Class WebController
|
|
* Class WebController
|
|
* @package App\Controller
|
|
* @package App\Controller
|
|
@@ -22,7 +21,7 @@ class WebController extends AbstractController
|
|
|
|
|
|
#[Inject]
|
|
#[Inject]
|
|
protected ValidatorFactoryInterface $validationFactory;
|
|
protected ValidatorFactoryInterface $validationFactory;
|
|
- private $publicServiceClient;
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @var NewsServiceInterface
|
|
* @var NewsServiceInterface
|
|
*/
|
|
*/
|
|
@@ -37,7 +36,6 @@ class WebController extends AbstractController
|
|
|
|
|
|
|
|
|
|
private $PublicController;
|
|
private $PublicController;
|
|
-
|
|
|
|
public function __construct(PublicController $PublicController)
|
|
public function __construct(PublicController $PublicController)
|
|
{
|
|
{
|
|
$this->PublicController = $PublicController;
|
|
$this->PublicController = $PublicController;
|
|
@@ -66,10 +64,9 @@ class WebController extends AbstractController
|
|
}
|
|
}
|
|
|
|
|
|
$data = [
|
|
$data = [
|
|
- 'website_id'=>Context::get("SiteId"),
|
|
|
|
- 'pageSize'=>$requireData['pageSize']
|
|
|
|
|
|
+ 'website_id'=>Context::get("SiteId")
|
|
];
|
|
];
|
|
- // var_dump("网站id:",Context::get("SiteId"));
|
|
|
|
|
|
+ var_dump("网站id:",Context::get("SiteId"));
|
|
$result = $this->websiteServiceClient->getWebsiteCategory($data);
|
|
$result = $this->websiteServiceClient->getWebsiteCategory($data);
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
return Result::error($result['message'],0,[]);
|
|
return Result::error($result['message'],0,[]);
|
|
@@ -153,7 +150,6 @@ class WebController extends AbstractController
|
|
return Result::success($result['data']);
|
|
return Result::success($result['data']);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
*各省市查询
|
|
*各省市查询
|
|
*/
|
|
*/
|
|
@@ -375,7 +371,7 @@ class WebController extends AbstractController
|
|
/**
|
|
/**
|
|
* 获取文章列表
|
|
* 获取文章列表
|
|
*/
|
|
*/
|
|
- public function getWebsiteArticlesList()
|
|
|
|
|
|
+ public function getWebsiteArticleList()
|
|
{
|
|
{
|
|
|
|
|
|
$requireData = $this->request->all();
|
|
$requireData = $this->request->all();
|
|
@@ -391,34 +387,8 @@ class WebController extends AbstractController
|
|
]
|
|
]
|
|
);
|
|
);
|
|
$data['catid'] = $requireData['catid'];
|
|
$data['catid'] = $requireData['catid'];
|
|
- }elseif(isset($requireData['keyword'])){
|
|
|
|
- $validator = $this->validationFactory->make(
|
|
|
|
- $requireData,
|
|
|
|
- [
|
|
|
|
- 'keyword' => 'required'
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'keyword.required' => '搜索词不能为空'
|
|
|
|
-
|
|
|
|
- ]
|
|
|
|
- );
|
|
|
|
- $data['keyword'] = $requireData['keyword'];
|
|
|
|
- }else{
|
|
|
|
- $validator = $this->validationFactory->make(
|
|
|
|
- $requireData,
|
|
|
|
- [
|
|
|
|
- 'catid' => 'required',
|
|
|
|
- 'keyword' => 'required'
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'catid.required' => '栏目id不能为空',
|
|
|
|
- 'keyword.required' => '搜索词不能为空'
|
|
|
|
-
|
|
|
|
- ]
|
|
|
|
- );
|
|
|
|
- $data['catid'] = $requireData['catid'];
|
|
|
|
- $data['keyword'] = $requireData['keyword'];
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
$validator = $this->validationFactory->make(
|
|
$validator = $this->validationFactory->make(
|
|
$requireData,
|
|
$requireData,
|
|
[
|
|
[
|
|
@@ -435,10 +405,14 @@ class WebController extends AbstractController
|
|
$errorMessage = $validator->errors()->first();
|
|
$errorMessage = $validator->errors()->first();
|
|
return Result::error($errorMessage);
|
|
return Result::error($errorMessage);
|
|
}
|
|
}
|
|
|
|
+ // $data['catid'] = $requireData['catid'];
|
|
|
|
+ if(isset($requireData['keyword']) && !empty($requireData['keyword'])){
|
|
|
|
+ $data['keyword'] = $requireData['keyword'];
|
|
|
|
+ }
|
|
$data['website_id'] = Context::get("SiteId");
|
|
$data['website_id'] = Context::get("SiteId");
|
|
$data['pageSize'] = $requireData['pageSize'];
|
|
$data['pageSize'] = $requireData['pageSize'];
|
|
$data['page'] = $requireData['page'];
|
|
$data['page'] = $requireData['page'];
|
|
- $result = $this->newsServiceClient->getArticleList($data);
|
|
|
|
|
|
+ $result = $this->newsServiceClient->getWebsiteArticleList($data);
|
|
// var_dump($result);
|
|
// var_dump($result);
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
return Result::error($result['message'],0,[]);
|
|
return Result::error($result['message'],0,[]);
|
|
@@ -480,4 +454,169 @@ class WebController extends AbstractController
|
|
return Result::success($result['data']);
|
|
return Result::success($result['data']);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 获取网站底部信息
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteFootInfo()
|
|
|
|
+ {
|
|
|
|
+ $data = [
|
|
|
|
+ 'website_id'=>Context::get("SiteId")
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->websiteServiceClient->getWebsiteFootInfo($data);
|
|
|
|
+ if ($result['code'] != ErrorCode::SUCCESS) {
|
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result['data']);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 获取网站底部导航
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteFooterCategory()
|
|
|
|
+ {
|
|
|
|
+ $data = [
|
|
|
|
+ 'website_id'=>Context::get("SiteId")
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->websiteServiceClient->getWebsiteFooterCategory($data);
|
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
|
+ }else{
|
|
|
|
+ return Result::success($result['data']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 获取网站底部导航列表
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteFooterCategoryList()
|
|
|
|
+ {
|
|
|
|
+ $requireData = $this->request->all();
|
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
|
+ $requireData,
|
|
|
|
+ [
|
|
|
|
+ 'fcat_id' =>'required|integer'
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'fcat_id.required' => '底部导航栏目id不能为空',
|
|
|
|
+ 'fcat_id.integer' => '底部导航栏目id必须为整数'
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ if ($validator->fails()){
|
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
|
+ return Result::error($errorMessage);
|
|
|
|
+ }
|
|
|
|
+ $data = [
|
|
|
|
+ 'fcat_id'=>$requireData['fcat_id'],
|
|
|
|
+ 'website_id'=>Context::get("SiteId")
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->websiteServiceClient->getWebsiteFooterCategoryList($data);
|
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
|
+ }else{
|
|
|
|
+ return Result::success($result['data']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 获取网站底部导航内容
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteFooterCategoryInfo()
|
|
|
|
+ {
|
|
|
|
+ $requireData = $this->request->all();
|
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
|
+ $requireData,
|
|
|
|
+ [
|
|
|
|
+ 'fcat_id' =>'required|integer',
|
|
|
|
+ 'type' => 'nullable|in:0'
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'fcat_id.required' => 'id不能为空',
|
|
|
|
+ 'fcat_id.integer' => 'id必须为整数',
|
|
|
|
+ 'type.in' => '类型必须为0'
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ if ($validator->fails()){
|
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
|
+ return Result::error($errorMessage);
|
|
|
|
+ }
|
|
|
|
+ $data = [
|
|
|
|
+ 'fcat_id'=>$requireData['fcat_id'],
|
|
|
|
+ 'website_id'=>Context::get("SiteId")
|
|
|
|
+ ];
|
|
|
|
+ if(isset($requireData['type'])){
|
|
|
|
+ $data['type'] = $requireData['type'];
|
|
|
|
+ }
|
|
|
|
+ $result = $this->websiteServiceClient->getWebsiteFooterCategoryInfo($data);
|
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
|
+ }else{
|
|
|
|
+ return Result::success($result['data']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 搜索二级导航
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function selectWebsiteCategory()
|
|
|
|
+ {
|
|
|
|
+ $requireData = $this->request->all();
|
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
|
+ $requireData,
|
|
|
|
+ [
|
|
|
|
+ 'pid' =>'required|integer',
|
|
|
|
+ 'cityid' => 'nullable|numeric',
|
|
|
|
+ 'department_id' => 'nullable|numeric',
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'pid.required' => 'id不能为空',
|
|
|
|
+ 'pid.integer' => 'id必须为整数',
|
|
|
|
+ 'cityid.numeric' => '城市id必须为数字',
|
|
|
|
+ 'department_id.numeric' => '部门id必须为数字'
|
|
|
|
+ ]
|
|
|
|
+ ) ;
|
|
|
|
+ if ($validator->fails()){
|
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
|
+ return Result::error($errorMessage);
|
|
|
|
+ }
|
|
|
|
+ $data = $requireData;
|
|
|
|
+ $data['website_id'] = Context::get("SiteId");
|
|
|
|
+ $result = $this->websiteServiceClient->selectWebsiteCategory($data);
|
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
|
+ }else{
|
|
|
|
+ return Result::success($result['data']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 搜索二级导航
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteCategoryHead()
|
|
|
|
+ {
|
|
|
|
+ $requireData = $this->request->all();
|
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
|
+ $requireData,
|
|
|
|
+ [
|
|
|
|
+ 'catid' =>'required|integer'
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'catid.required' => 'id不能为空'
|
|
|
|
+ ]
|
|
|
|
+ ) ;
|
|
|
|
+ if ($validator->fails()){
|
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
|
+ return Result::error($errorMessage);
|
|
|
|
+ }
|
|
|
|
+ $data = $requireData;
|
|
|
|
+ $data['website_id'] = Context::get("SiteId");
|
|
|
|
+ $result = $this->websiteServiceClient->getWebsiteCategoryHead($data);
|
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
|
+ }else{
|
|
|
|
+ return Result::success($result['data']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|