Commit 7e1c6263 by 杨树贤

品牌接口

parent 907bca22
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Services; namespace App\Http\Services;
use Fuse\Fuse;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
class BrandService class BrandService
...@@ -14,7 +15,17 @@ class BrandService ...@@ -14,7 +15,17 @@ class BrandService
return json_decode($value, true); return json_decode($value, true);
}, $standardBrandCache); }, $standardBrandCache);
ksort($standardBrandCache); ksort($standardBrandCache);
$standardBrandCache = array_values($standardBrandCache);
$standardBrandCache = array_map(function ($item) {
return \Arr::only($item, ['brand_name_en', 'standard_brand_id', 'brand_short_name_en', 'brand_logo']);
}, $standardBrandCache);
if (!empty($map['brand_name'])) { if (!empty($map['brand_name'])) {
$fuse = new Fuse($standardBrandCache, [
'keys' => ['brand_name_en'],
'minMatchCharLength' => 3,
'threshold' => 0
]);
return $fuse->search($map['brand_name']);
} }
return $standardBrandCache; return $standardBrandCache;
} }
......
...@@ -21,6 +21,7 @@ Route::middleware(['api'])->namespace('Api')->group(function () { ...@@ -21,6 +21,7 @@ Route::middleware(['api'])->namespace('Api')->group(function () {
Route::POST('auth/forget_password', 'AuthApiController@forgetPassword'); Route::POST('auth/forget_password', 'AuthApiController@forgetPassword');
Route::POST('auth/set_forget_password', 'AuthApiController@setForgetPassword'); Route::POST('auth/set_forget_password', 'AuthApiController@setForgetPassword');
Route::get('country/list', 'CountryApiController@list'); Route::get('country/list', 'CountryApiController@list');
Route::get('brand/list', 'BrandApiController@list');
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment