<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use JiGuang\JSMS as JSMS;
use Illuminate\Support\Facades\Redis;
use Dingo\Api\Http\Response;
use Validator;
use DB;
use App\Models\User;
use App\Models\Suggestion;
use App\Services\CategoryService;

/**
 * 
* Copyright: Copyright (c) 2019 LanRu-Caifu
* 
* @Description: 分类控制器
* @version: v1.0.0
* @author: fengyichao
* @date: 2019年8月5日 下午6:52:40 
*
* Modification History:
* Date         Author          Version            Description
*---------------------------------------------------------*
* 2019年8月5日     fengyichao           v1.0.0               修改原因
 */
class CategoryController extends ApiController {
	public function __construct(CategoryService $categoryService) {
		$this->categoryService = $categoryService;
	}
	
	/**
	 *
	 * @api {post} category/list  商品分类（检测前需要选择疾病分类）
	 * @apiName category/list
	 * @apiGroup category
	 * @apiSuccess {List[Map]} categorys 商品分类
	 * @apiSuccess (categorys) {int}  id 分类id
	 * @apiSuccess (categorys) {int}  name 分类名称
	 * @apiParamExample {curl} Example usage:
	 * http://59.110.137.245:8080/api/category/list
	 */
	function list(Request $request){
		$categorys = $this->categoryService->getCategoryTree ();
		$resData ['categorys'] = $categorys;
		return $this->success ( $resData );
	}
}
