<?php
namespace app\api\controller\publics;

use app\models\article\ArticleCategory;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use app\Request;

/**
 * 文章分类类
 * Class ArticleCategoryController
 * @package app\api\controller\publics
 */
class ArticleCategoryController
{
    /**
     * 文章分类列表
     * @return mixed
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     */
   public function lst(Request $request)
   {
       $mer_id = $request->mer_id() ?: '';
       $cateInfo = ArticleCategory::getArticleCategory($mer_id);
       if($cateInfo) $cateInfo = $cateInfo->toArray();
       else $cateInfo = [];
       array_unshift($cateInfo,['id'=>0,'title'=>'热门']);
       return app('json')->successful($cateInfo);
   }
}