quanwei
2025-10-28 36cacbaf78e510713002fcd5e3d61cece2e01421
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace app\api\controller\plus\business;
 
use app\api\controller\Controller;
use app\api\model\plus\business\Industry as IndustryModel;
 
class Industry extends Controller
{
    /**
     * 获取所有行业(树状结构)
     */
    public function getIndustryTree()
    {
        $tree = IndustryModel::getCacheTree();
        return $this->renderSuccess(compact('tree'));
    }
 
    /**
     * 获取所有行业列表
     */
    public function getIndustryList()
    {
        $list = IndustryModel::getCacheAll();
        return $this->renderSuccess(compact('list'));
    }
 
    /**
     * 获取行业详情
     */
    public function detail($industry_id)
    {
        $industry = IndustryModel::detail($industry_id);
        if (!$industry) {
            return $this->renderError('行业不存在');
        }
        return $this->renderSuccess(compact('industry'));
    }
 
    /**
     * 获取一级行业列表
     */
    public function getFirstIndustry()
    {
        $list = IndustryModel::getFirstIndustry();
        return $this->renderSuccess(compact('list'));
    }
 
    /**
     * 根据上级ID获取子行业
     */
    public function getSubIndustry($parent_id = 0)
    {
        $model = new IndustryModel;
        $list = $model->where('parent_id', '=', $parent_id)->where('status', '=', 1)
            ->order(['sort' => 'asc', 'create_time' => 'asc'])->select();
        return $this->renderSuccess(compact('list'));
    }
}