|
@@ -1,8 +1,10 @@
|
|
<?php
|
|
<?php
|
|
|
|
+
|
|
namespace app\api\controller\publics;
|
|
namespace app\api\controller\publics;
|
|
|
|
|
|
use app\models\article\Article;
|
|
use app\models\article\Article;
|
|
use app\models\article\ArticleCategory;
|
|
use app\models\article\ArticleCategory;
|
|
|
|
+use app\models\article\ArticleReply;
|
|
use app\Request;
|
|
use app\Request;
|
|
use crmeb\services\UtilService;
|
|
use crmeb\services\UtilService;
|
|
|
|
|
|
@@ -22,13 +24,14 @@ class ArticleController
|
|
public function lst(Request $request, $cid)
|
|
public function lst(Request $request, $cid)
|
|
{
|
|
{
|
|
list($page, $limit) = UtilService::getMore([
|
|
list($page, $limit) = UtilService::getMore([
|
|
- ['page',1],
|
|
|
|
- ['limit',10],
|
|
|
|
- ],$request, true);
|
|
|
|
- $list = Article::cidByArticleList($cid,$page,$limit,"id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
|
|
|
|
- if(is_object($list)) $list = $list->toArray();
|
|
|
|
|
|
+ ['page', 1],
|
|
|
|
+ ['limit', 10],
|
|
|
|
+ ], $request, true);
|
|
|
|
+ $list = Article::cidByArticleList($cid, $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
|
|
|
|
+ if (is_object($list)) $list = $list->toArray();
|
|
return app('json')->successful($list);
|
|
return app('json')->successful($list);
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 文章详情
|
|
* 文章详情
|
|
* @param $id
|
|
* @param $id
|
|
@@ -37,16 +40,16 @@ class ArticleController
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
*/
|
|
- public function details($id)
|
|
|
|
- {
|
|
|
|
- $content = Article::getArticleOne($id);
|
|
|
|
- if(!$content) return app('json')->fail('此文章已经不存在!');
|
|
|
|
- $content["visit"] = $content["visit"] + 1;
|
|
|
|
- $content["cart_name"] = ArticleCategory::getArticleCategoryField($content['cid']);
|
|
|
|
- $content['add_time'] = date('m月d日',$content['add_time']);
|
|
|
|
- Article::edit(['visit'=>$content["visit"]],$id);//增加浏览次数
|
|
|
|
- return app('json')->successful($content);
|
|
|
|
- }
|
|
|
|
|
|
+ public function details($id)
|
|
|
|
+ {
|
|
|
|
+ $content = Article::getArticleOne($id);
|
|
|
|
+ if (!$content) return app('json')->fail('此文章已经不存在!');
|
|
|
|
+ $content["visit"] = $content["visit"] + 1;
|
|
|
|
+ $content["cart_name"] = ArticleCategory::getArticleCategoryField($content['cid']);
|
|
|
|
+ $content['add_time'] = date('m月d日', $content['add_time']);
|
|
|
|
+ Article::edit(['visit' => $content["visit"]], $id);//增加浏览次数
|
|
|
|
+ return app('json')->successful($content);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 文章 热门
|
|
* 文章 热门
|
|
@@ -55,7 +58,7 @@ class ArticleController
|
|
public function hot()
|
|
public function hot()
|
|
{
|
|
{
|
|
$list = Article::getArticleListHot("id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
|
|
$list = Article::getArticleListHot("id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
|
|
- if(is_object($list)) $list = $list->toArray();
|
|
|
|
|
|
+ if (is_object($list)) $list = $list->toArray();
|
|
return app('json')->successful($list);
|
|
return app('json')->successful($list);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -66,7 +69,7 @@ class ArticleController
|
|
public function banner()
|
|
public function banner()
|
|
{
|
|
{
|
|
$list = Article::getArticleListBanner("id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
|
|
$list = Article::getArticleListBanner("id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
|
|
- if(is_object($list)) $list = $list->toArray();
|
|
|
|
|
|
+ if (is_object($list)) $list = $list->toArray();
|
|
return app('json')->successful($list);
|
|
return app('json')->successful($list);
|
|
}
|
|
}
|
|
}
|
|
}
|