<?php

namespace App\Http\Controllers\Wap\Book;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Modules\Book\Services\BookCategoryService;

class BookCategoryController extends Controller
{
    /**
     * @apiDefine Book 图书
     */

    /**
     * @apiVersion 1.0.0
     * @apiDescription 获取分类
     * @api {get}
     * 获取分类
     * @apiGroup Book
     * @apiName getCategory
     * @apiSuccess {int}         code 状态码
     * @apiSuccess {String}      msg  信息
     * @apiSuccess {object}      data 结果集
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *       code: 0,
     *       msg: "",
     *       data:  [
     *                   {
     *                   id: 1,
     *                   name: "男频",
     *                   children: [
     *                           {
     *                               id: 7,
     *                               name: "灵异鬼怪"
     *                           },
     *                           {
     *                               id: 8,
     *                               name: "历史穿越"
     *                           },
     *                           {
     *                               id: 30,
     *                               name: "青春爱情"
     *                           }
     *                       ]
     *                   },
     *                   {
     *                   id: 2,
     *                   name: "女频",
     *                   children: [
     *                           {
     *                               id: 26,
     *                               name: "豪门总裁"
     *                           },
     *                           {
     *                               id: 35,
     *                               name: "民国爱情"
     *                           }
     *                       ]
     *                   }
     *               ]
     *       }
     */
    public function getCategory(Request $request){
        $res = BookCategoryService::getCategory(true);
        return response()->success($res);
    }
}