Commit 68b6e897 by 杨树贤

分类修改

parent a74a4919
Showing with 29 additions and 20 deletions
...@@ -22,11 +22,11 @@ DB_Self_PORT=3306 ...@@ -22,11 +22,11 @@ DB_Self_PORT=3306
DB_Self_PREFIX=lie_ DB_Self_PREFIX=lie_
//采购系统数据库 //采购系统数据库
DB_Pur_HOST=192.168.1.232 DB_PUR_HOST=192.168.2.232
DB_Pur_DATABASE=liexin_wms DB_PUR_DATABASE=liexin_wms
DB_Pur_USERNAME=root DB_PUR_USERNAME=liexin_wms
DB_Pur_PASSWORD=123456 DB_PUR_PASSWORD=liexin_wms#zsyM
DB_Pur_PORT=3306 DB_PUR_PORT=3306
DB_Pur_PREFIX=lie_ DB_Pur_PREFIX=lie_
......
...@@ -52,22 +52,31 @@ class SelfClassifyModel extends Model ...@@ -52,22 +52,31 @@ class SelfClassifyModel extends Model
public function getClassList() public function getClassList()
{ {
$classificationsExpireMinute = 5; $classificationsExpireMinute = 5;
//先去缓存里面取
$Redis = new RedisModel;
$classList = $Redis->hgetall('Self_SelfClassInfo');
$classList = array_map(function ($value) {
return json_decode($value, true);
}, $classList);
return Cache::remember('classList', $classificationsExpireMinute, function () { if (!$classList) {
$field = [ return Cache::remember('classList', $classificationsExpireMinute, function () {
'class_id', $field = [
'class_name', 'class_id',
'status', 'class_name',
'class_icon', 'status',
]; 'class_icon',
];
return $this->select($field)->with([
'sub_class' => function ($query) use ($field) {
array_push($field, 'parent_id');
$query->select($field);
},
])->where('status', 1)->where('parent_id', 0)
->orderBy('sort', 'desc')->get()->toArray();
});
}
return $this->select($field)->with([
'sub_class' => function ($query) use ($field) {
array_push($field, 'parent_id');
$query->select($field);
},
])->where('status', 1)->where('parent_id', 0)
->orderBy('sort', 'desc')->get()->toArray();
});
} }
} }
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