|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
namespace App\Services\Api;
|
|
|
|
|
|
+use App\Models\ArticleCateModel;
|
|
|
use App\Models\ArticleModel;
|
|
|
use App\Services\BaseService;
|
|
|
use App\Services\ConfigService;
|
|
@@ -58,6 +59,7 @@ class ArticleService extends BaseService
|
|
|
$where = ['a.mark' => 1];
|
|
|
$status = isset($params['status'])? $params['status'] : 0;
|
|
|
$type = isset($params['type'])? $params['type'] : 0;
|
|
|
+ $publishType = isset($params['publish_type'])? $params['publish_type'] : 0;
|
|
|
$cateId = isset($params['cate_id'])? $params['cate_id'] : 0;
|
|
|
if($status>0){
|
|
|
$where['a.status'] = $status;
|
|
@@ -65,6 +67,11 @@ class ArticleService extends BaseService
|
|
|
if($type>0){
|
|
|
$where['a.type'] = $type;
|
|
|
}
|
|
|
+
|
|
|
+ if($publishType>0){
|
|
|
+ $where['a.publish_type'] = $publishType;
|
|
|
+ }
|
|
|
+
|
|
|
if($cateId>0){
|
|
|
$where['a.cate_id'] = $cateId;
|
|
|
}
|
|
@@ -96,6 +103,40 @@ class ArticleService extends BaseService
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 类目
|
|
|
+ * @return array[]
|
|
|
+ */
|
|
|
+ public function getCateList($type=0)
|
|
|
+ {
|
|
|
+ $cacheKey = "caches:articles:cates_{$type}";
|
|
|
+ $datas = RedisService::get($cacheKey);
|
|
|
+ if($datas){
|
|
|
+ return $datas;
|
|
|
+ }
|
|
|
+
|
|
|
+ $where = ['status'=>1,'mark'=>1];
|
|
|
+ if($type){
|
|
|
+ $where['type'] = $type;
|
|
|
+ }
|
|
|
+ $datas = ArticleCateModel::where($where)
|
|
|
+ ->select(['id','icon','name','type','status'])
|
|
|
+ ->orderBy('sort','desc')
|
|
|
+ ->orderBy('id','desc')
|
|
|
+ ->get();
|
|
|
+ if($datas){
|
|
|
+ foreach ($datas as &$item){
|
|
|
+ $item['icon'] = $item['icon']? get_image_url($item['icon']) : '';
|
|
|
+ }
|
|
|
+ unset($item);
|
|
|
+ }
|
|
|
+ return $datas;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分类
|
|
|
+ * @return array[]
|
|
|
+ */
|
|
|
public function getCategory()
|
|
|
{
|
|
|
$datas = [
|