Initial commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\service\CategoryService;
|
||||
use fast\Tree;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\Validate;
|
||||
|
||||
class Catalog extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['index'];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @param string $desc 需求描述
|
||||
* @param array $images 图片数组
|
||||
* @param array $files 文件数组
|
||||
* @param string $contact 联系方式
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->get();
|
||||
$cateList = CategoryService::getOptions();
|
||||
$res = [
|
||||
['text' => '全部', 'key' => 0]
|
||||
];
|
||||
foreach ($cateList as $key => $val) {
|
||||
$res[] = ['text' => $val, 'key' => $key];
|
||||
}
|
||||
$this->success('', $res);
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof HttpResponseException) {
|
||||
throw $e;
|
||||
}
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user