feat:material_category

This commit is contained in:
LAPTOP-7SGDREK0\shiweijun
2025-02-27 17:34:05 +08:00
parent 604c6ff799
commit 09603ee33a
2 changed files with 21 additions and 2 deletions

View File

@@ -111,8 +111,22 @@ class MaterialCategoryService extends BaseService{
->when($cityId > 0,function($query) use($cityId){ ->when($cityId > 0,function($query) use($cityId){
$query->where('city_id',$cityId); $query->where('city_id',$cityId);
}) })
->where('is_del',MaterialCode::IS_NO_DEL)->get(); ->where('is_del',MaterialCode::IS_NO_DEL)->get()->toArray();
return $this->return->success('success',['list' => $list->toArray()]); $tree = [];
$map = [];
foreach ($list as &$category) {
$category['children'] = [];
$map[$category['id']] = &$category;
if ($category['parent_id'] && isset($map[$category['parent_id']])) {
$map[$category['parent_id']]['children'][] = &$category;
} else {
$tree[] = &$category;
}
}
return $this->return->success('success',$tree);
} }
} }

View File

@@ -324,6 +324,11 @@ GET {{host}}/admin/material_category/findById?query_id=1
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
Authorization: Bearer {{admin_token}} Authorization: Bearer {{admin_token}}
### 材料种类列表
GET {{host}}/admin/material_category/list?query_city_id=1
content-type: application/json
Authorization: Bearer {{admin_token}}
### 材料列表 ### 材料列表
GET {{host}}/admin/material/list?limit=10 GET {{host}}/admin/material/list?limit=10
content-type: application/json content-type: application/json