|
@@ -6,13 +6,12 @@ use App\JsonRpc\NewsServiceInterface;
|
|
|
use App\JsonRpc\WebsiteServiceInterface;
|
|
|
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 App\Controller\PublicController;
|
|
|
use Hyperf\Context\Context;
|
|
|
-use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
-use Hyperf\HttpServer\Contract\ResponseInterface;
|
|
|
+
|
|
|
/**
|
|
|
* Class WebController
|
|
|
* @package App\Controller
|
|
@@ -22,7 +21,7 @@ class WebController extends AbstractController
|
|
|
|
|
|
#[Inject]
|
|
|
protected ValidatorFactoryInterface $validationFactory;
|
|
|
- private $publicServiceClient;
|
|
|
+
|
|
|
/**
|
|
|
* @var NewsServiceInterface
|
|
|
*/
|
|
@@ -37,7 +36,6 @@ class WebController extends AbstractController
|
|
|
|
|
|
|
|
|
private $PublicController;
|
|
|
-
|
|
|
public function __construct(PublicController $PublicController)
|
|
|
{
|
|
|
$this->PublicController = $PublicController;
|
|
@@ -66,10 +64,9 @@ class WebController extends AbstractController
|
|
|
}
|
|
|
|
|
|
$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);
|
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
|
return Result::error($result['message'],0,[]);
|
|
@@ -103,24 +100,26 @@ class WebController extends AbstractController
|
|
|
public function getWebsiteAdvertisement()
|
|
|
{
|
|
|
$requireData = $this->request->all();
|
|
|
- $validator = $this->validationFactory->make(
|
|
|
- $requireData,
|
|
|
- [
|
|
|
- 'adPlace' => 'required'
|
|
|
- ],
|
|
|
- [
|
|
|
- 'adPlace.required' => '广告位置编号不能为空'
|
|
|
- ]
|
|
|
- );
|
|
|
- if ($validator->fails()){
|
|
|
- $errorMessage = $validator->errors()->first();
|
|
|
- return Result::error($errorMessage);
|
|
|
+ $data = ['website_id'=>Context::get("SiteId")];
|
|
|
+ if($requireData['ad_tag']){
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'ad_tag' => 'required'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'ad_tag.required' => '广告位置表示不能为空'
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ if ($validator->fails()){
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
+ return Result::error($errorMessage);
|
|
|
+ }
|
|
|
+ $data['ad_tag'] = $requireData['ad_tag'];
|
|
|
}
|
|
|
- $data = [
|
|
|
- 'website_id'=>Context::get("SiteId"),
|
|
|
- 'ad_placeid'=>$requireData['adPlace']
|
|
|
- ];
|
|
|
|
|
|
+
|
|
|
+ // return Result::success($data);//测试
|
|
|
$result = $this->websiteServiceClient->getWebsiteAdvertisement($data);
|
|
|
|
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
@@ -153,7 +152,6 @@ class WebController extends AbstractController
|
|
|
return Result::success($result['data']);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
*各省市查询
|
|
|
*/
|
|
@@ -374,8 +372,9 @@ class WebController extends AbstractController
|
|
|
|
|
|
/**
|
|
|
* 获取文章列表
|
|
|
+ * @return array
|
|
|
*/
|
|
|
- public function getWebsiteArticlesList()
|
|
|
+ public function getWebsiteArticleList()
|
|
|
{
|
|
|
|
|
|
$requireData = $this->request->all();
|
|
@@ -390,55 +389,39 @@ class WebController extends AbstractController
|
|
|
|
|
|
]
|
|
|
);
|
|
|
- $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'];
|
|
|
+ if(is_string($requireData['catid'])){
|
|
|
+ $data['catid'] = json_decode($requireData['catid']);
|
|
|
+ }else{
|
|
|
+ $data['catid'] = $requireData['catid'];
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
$validator = $this->validationFactory->make(
|
|
|
- $requireData,
|
|
|
- [
|
|
|
- 'page' => 'required',
|
|
|
- 'pageSize' => 'required'
|
|
|
- ],
|
|
|
- [
|
|
|
- 'page.required' => '分页不能为空',
|
|
|
- 'pageSize.required' => '显示条数不能为空'
|
|
|
-
|
|
|
- ]
|
|
|
- );
|
|
|
- if ($validator->fails()){
|
|
|
- $errorMessage = $validator->errors()->first();
|
|
|
- return Result::error($errorMessage);
|
|
|
- }
|
|
|
- $data['website_id'] = Context::get("SiteId");
|
|
|
- $data['pageSize'] = $requireData['pageSize'];
|
|
|
- $data['page'] = $requireData['page'];
|
|
|
- $result = $this->newsServiceClient->getArticleList($data);
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'page' => 'required',
|
|
|
+ 'pageSize' => 'required'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'page.required' => '分页不能为空',
|
|
|
+ 'pageSize.required' => '显示条数不能为空'
|
|
|
+
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ if ($validator->fails()){
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
+ 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['pageSize'] = $requireData['pageSize'];
|
|
|
+ $data['page'] = $requireData['page'];
|
|
|
+ // return Result::success($data);
|
|
|
+ $result = $this->newsServiceClient->getWebsiteArticleList($data);
|
|
|
// var_dump($result);
|
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
|
return Result::error($result['message'],0,[]);
|
|
@@ -472,7 +455,7 @@ class WebController extends AbstractController
|
|
|
'website_id'=>Context::get("SiteId"),
|
|
|
'id'=>$requireData['articleid'],
|
|
|
];
|
|
|
- $result = $this->newsServiceClient->getArticleInfo($data);
|
|
|
+ $result = $this->newsServiceClient->selectWebsiteArticleInfo($data);
|
|
|
// var_dump($result);
|
|
|
if ($result['code'] != ErrorCode::SUCCESS) {
|
|
|
return Result::error($result['message'],0,[]);
|
|
@@ -480,4 +463,307 @@ class WebController extends AbstractController
|
|
|
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,
|
|
|
+ [
|
|
|
+ 'cityid' => 'nullable|numeric',
|
|
|
+ 'department_id' => 'nullable|numeric',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ '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']);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 搜索栏目的seo信息
|
|
|
+ * @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']);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 搜索某个导航
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getOneWebsiteCategory()
|
|
|
+ {
|
|
|
+ $requireData = $this->request->all();
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'catid' =>'required|integer'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'catid.required' => 'catid不能为空'
|
|
|
+ ]
|
|
|
+ ) ;
|
|
|
+ if ($validator->fails()){
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
+ return Result::error($errorMessage);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'category_id' => $requireData['catid'],
|
|
|
+ 'website_id' => Context::get("SiteId")
|
|
|
+ ];
|
|
|
+ $result = $this->websiteServiceClient->getOneWebsiteCategory($data);
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
+ }else{
|
|
|
+ return Result::success($result['data']);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取网站调查问卷
|
|
|
+ */
|
|
|
+ public function getWebsiteSurvey()
|
|
|
+ {
|
|
|
+ $requireData = $this->request->all();
|
|
|
+ if(isset($requireData['art_id'])){
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'art_id' =>'required|integer'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'art_id.required' => 'id不能为空',
|
|
|
+ 'art_id.integer' => 'id必须为整数'
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ if ($validator->fails()){
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
+ return Result::error($errorMessage);
|
|
|
+ }
|
|
|
+ $data['art_id'] = $requireData['art_id'];
|
|
|
+ }
|
|
|
+ $data['website_id'] = Context::get("SiteId");
|
|
|
+ // return Result::success($data);
|
|
|
+ $result = $this->newsServiceClient->getWebsiteSurvey($data);
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
+ }else{
|
|
|
+ return Result::success($result['data']);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 添加网站调查问卷选项
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ public function addWebsiteSurveyOption()
|
|
|
+ {
|
|
|
+ $requireData = $this->request->all();
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'sur_id' =>'required',
|
|
|
+ 'choice_name' =>'required|string|max:30',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'sur_id.required' => '问卷id不能为空',
|
|
|
+ 'choice_name.required' => '选项名称不能为空',
|
|
|
+ 'choice_name.string' => '选项名称必须为字符串',
|
|
|
+ 'choice_name.max' => '选项名称不能超过30个字符',
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ if ($validator->fails()){
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
+ return Result::error($errorMessage);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'website_id' => Context::get("SiteId"),
|
|
|
+ 'sur_id' => $requireData['sur_id'],
|
|
|
+ 'choice_name' => $requireData['choice_name'],
|
|
|
+ ];
|
|
|
+ $result = $this->newsServiceClient->addWebsiteSurveyOption($data);
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
+ }else{
|
|
|
+ return Result::success($result['data']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 调查问卷-投票
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ public function addWebsiteSurveyVote()
|
|
|
+ {
|
|
|
+ $requireData = $this->request->all();
|
|
|
+ $validator = $this->validationFactory->make(
|
|
|
+ $requireData,
|
|
|
+ [
|
|
|
+ 'sur_id' =>'required',
|
|
|
+ 'choice_id' =>'required',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'sur_id.required' => '问卷id不能为空',
|
|
|
+ 'choice_id.required' => '选项名称不能为空'
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ if ($validator->fails()){
|
|
|
+ $errorMessage = $validator->errors()->first();
|
|
|
+ return Result::error($errorMessage);
|
|
|
+ }
|
|
|
+ if(is_array($requireData['choice_id'])){
|
|
|
+ // return Result::error('选项名称必须为数组');
|
|
|
+ // $$requireData['choice_id'] = json_encode($requireData['choice_id']);
|
|
|
+ // return Result::success($requireData['choice_id']);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'website_id' => Context::get("SiteId"),
|
|
|
+ 'sur_id' => $requireData['sur_id'],
|
|
|
+ 'choice_id' => $requireData['choice_id']
|
|
|
+ ];
|
|
|
+ // return Result::success($data);
|
|
|
+ $result = $this->newsServiceClient->addWebsiteSurveyVote($data);
|
|
|
+ if ($result['code']!= ErrorCode::SUCCESS) {
|
|
|
+ return Result::error($result['message'],0,[]);
|
|
|
+ }else{
|
|
|
+ return Result::success($result['data']);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|