Files
code-bang/backend/application/api/controller/Catalog.php
T

44 lines
1.1 KiB
PHP
Raw Normal View History

2026-09-17 16:25:31 +08:00
<?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());
}
}
}