| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\ArticleService;
- use App\Services\ConfigService;
- /**
- * 司文章管理
- * Class ArticleController
- * @package App\Http\Controllers\Api
- */
- class ArticleController extends webApp
- {
- /**
- * 列表
- * @return array
- */
- public function index()
- {
- $params =request()->post();
- $pageSize = request()->post('pageSize', 15);
- $datas = ArticleService::make()->getDataList($params, $pageSize);
- return message(1010, true, $datas);
- }
- /**
- * 详情
- */
- public function info()
- {
- $params = request()->all();
- $id = isset($params['id'])? intval($params['id']) : 0;
- if(empty($id)){
- return message(1036, false);
- }
- if($info = ArticleService::make()->getInfo($id)){
- return message(1010, true, $info);
- }else{
- return message(1009, false);
- }
- }
- /**
- * 客服推荐数据
- */
- public function customRecommend()
- {
- $keywords = ConfigService::make()->getConfigByCode('custom_keywords');
- $keywords = $keywords? explode('、',$keywords) : ['问题','常见问题','账号','账号登录','登录','密码','商家','商家合作','物流','发货'];
- $datas = [
- 'keywords'=> array_filter($keywords),
- 'site_custom_phone'=> ConfigService::make()->getConfigByCode('site_custom_phone'),
- 'category'=> [
- ['id'=>9,'name'=>'常见问题','status'=>1],
- ['id'=>10,'name'=>'账号登录','status'=>1],
- ['id'=>11,'name'=>'商家合作','status'=>1],
- ],
- 'recommend'=> ArticleService::make()->getCustomRecommend(),
- ];
- return message(1010, true, $datas);
- }
- /**
- * 客服咨询数据
- */
- public function custom()
- {
- $type = request()->post('type',0);
- $keyword = request()->post('keyword','');
- $num = request()->post('num',6);
- $datas = ArticleService::make()->getCustomRecommend($type, $num, $keyword, $type==0?true:false);
- if($datas){
- return message(1010, true, $datas);
- }else{
- return message(1009, false);
- }
- }
- /**
- * 单页数据
- */
- public function page()
- {
- $params = request()->all();
- $type = isset($params['type'])? intval($params['type']) : 0;
- if(empty($type)){
- return message(1031, false);
- }
- if($info = ArticleService::make()->getInfoByType($type)){
- return message(1010, true, $info);
- }else{
- return message(1009, false);
- }
- }
- }
|