调整字典表数据接口
parent
02f37d22c1
commit
1910bd568e
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Peidikeji\Keywords\Models\Keywords;
|
||||
use Peidikeji\Keywords\Http\Resources\KeywordResource;
|
||||
|
||||
class KeywordController extends Controller
|
||||
{
|
||||
/**
|
||||
* 农作物
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crops(Request $request){
|
||||
$list = Keywords::filter($request->all())->where('type_key', 'like', 'crops-cate-%')->get();
|
||||
|
||||
return $this->json(KeywordResource::collection($list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 农作物产业分类
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cropsCate(Request $request){
|
||||
$cropsId = $request->input('crops_id', 0);
|
||||
$crops = null;
|
||||
if($cropsId){
|
||||
$crops = Keywords::find($cropsId);
|
||||
}
|
||||
|
||||
$query = Keywords::filter($request->all())->where('type_key', 'crops-category');
|
||||
|
||||
if($crops){
|
||||
$query->where('id', $crops->parent_id);
|
||||
}
|
||||
|
||||
$list = $query->get();
|
||||
return $this->json(KeywordResource::collection($list));
|
||||
}
|
||||
}
|
||||
|
|
@ -33,14 +33,14 @@ class KeywordsTableSeeder extends Seeder
|
|||
['key' => 'crops-buzhihuo', 'name' => '不知火', 'type_key'=>'crops-cate-nongye', 'value' => '']
|
||||
]],
|
||||
['key' => 'crops-cate-yuye', 'name' => '渔业', 'type_key'=>'crops-category', 'value' => '', 'list' =>[
|
||||
['key' => 'crops-shengzhu', 'name' => '生猪', 'type_key'=>'crops-cate-xumuye', 'value' => ''],
|
||||
]],
|
||||
['key' => 'crops-cate-xumuye', 'name' => '畜牧业', 'type_key'=>'crops-category', 'value' => '', 'list' => [
|
||||
['key' => 'crops-huocaoyu', 'name' => '活草鱼', 'type_key'=>'crops-cate-yuye', 'value' => ''],
|
||||
['key' => 'crops-daoxia', 'name' => '稻虾', 'type_key'=>'crops-cate-yuye', 'value' => ''],
|
||||
['key' => 'crops-wuyu', 'name' => '乌鱼', 'type_key'=>'crops-cate-yuye', 'value' => ''],
|
||||
['key' => 'crops-luyu', 'name' => '鲈鱼', 'type_key'=>'crops-cate-yuye', 'value' => ''],
|
||||
]],
|
||||
['key' => 'crops-cate-xumuye', 'name' => '畜牧业', 'type_key'=>'crops-category', 'value' => '', 'list' => [
|
||||
['key' => 'crops-shengzhu', 'name' => '生猪', 'type_key'=>'crops-cate-xumuye', 'value' => ''],
|
||||
]],
|
||||
['key' => 'crops-cate-lingye', 'name' => '林业', 'type_key'=>'crops-category', 'value' => ''],
|
||||
]],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ use Illuminate\Support\Facades\Route;
|
|||
Route::post('auth/login', [AuthController::class, 'login']);
|
||||
|
||||
Route::group(['middleware' => 'auth:sanctum'], function () {
|
||||
Route::get('keywords-crops', [KeywordController::class, 'crops']);
|
||||
Route::get('keywords-crops-cate', [KeywordController::class, 'cropsCate']);
|
||||
|
||||
Route::prefix('users')->group(function () {
|
||||
Route::put('reset-password', [UserController::class, 'resetPwd']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue