作者 lyh

gx

@@ -42,7 +42,7 @@ class KeywordController extends BaseController @@ -42,7 +42,7 @@ class KeywordController extends BaseController
42 foreach ($data['list'] as &$v){ 42 foreach ($data['list'] as &$v){
43 $v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['id'].',%')->count(); 43 $v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['id'].',%')->count();
44 $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); 44 $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
45 - $v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']); 45 + $v['url'] = $this->user['domain'] . $v['url'];
46 } 46 }
47 } 47 }
48 return $this->response('success',Code::SUCCESS,$data); 48 return $this->response('success',Code::SUCCESS,$data);
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Product; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Exceptions\BsideGlobalException; 6 use App\Exceptions\BsideGlobalException;
7 use App\Helper\Arr; 7 use App\Helper\Arr;
  8 +use App\Helper\Common;
8 use App\Http\Controllers\Bside\BaseController; 9 use App\Http\Controllers\Bside\BaseController;
9 use App\Http\Logic\Bside\Product\ProductLogic; 10 use App\Http\Logic\Bside\Product\ProductLogic;
10 use App\Http\Requests\Bside\Product\ProductRequest; 11 use App\Http\Requests\Bside\Product\ProductRequest;
@@ -18,6 +19,7 @@ use App\Models\Template\BTemplate; @@ -18,6 +19,7 @@ use App\Models\Template\BTemplate;
18 use App\Models\User\User; 19 use App\Models\User\User;
19 use App\Rules\Ids; 20 use App\Rules\Ids;
20 use Illuminate\Http\Request; 21 use Illuminate\Http\Request;
  22 +use Illuminate\Support\Facades\Cache;
21 use Illuminate\Support\Facades\DB; 23 use Illuminate\Support\Facades\DB;
22 24
23 /** 25 /**
@@ -111,13 +113,17 @@ class ProductController extends BaseController @@ -111,13 +113,17 @@ class ProductController extends BaseController
111 * @time :2023/9/14 13:56 113 * @time :2023/9/14 13:56
112 */ 114 */
113 public function getCategoryList(){ 115 public function getCategoryList(){
114 - $categoryModel = new Category();  
115 - $data = [];  
116 - $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);  
117 - if(!empty($cateList)){  
118 - foreach ($cateList as $value){  
119 - $data[$value['id']] = $value['title']; 116 + $data = Common::get_user_cache('product_category',$this->user['project_id']);
  117 + if(empty($data)){
  118 + $categoryModel = new Category();
  119 + $data = [];
  120 + $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);
  121 + if(!empty($cateList)){
  122 + foreach ($cateList as $value){
  123 + $data[$value['id']] = $value['title'];
  124 + }
120 } 125 }
  126 + Common::set_user_cache($data,'product_category',$this->user['project_id']);
121 } 127 }
122 return $data; 128 return $data;
123 } 129 }
@@ -130,13 +136,17 @@ class ProductController extends BaseController @@ -130,13 +136,17 @@ class ProductController extends BaseController
130 * @time :2023/9/14 13:56 136 * @time :2023/9/14 13:56
131 */ 137 */
132 public function getKeywordsList(){ 138 public function getKeywordsList(){
133 - $keywordModel = new Keyword();  
134 - $data = [];  
135 - $cateList = $keywordModel->list(['project_id'=>$this->user['project_id']],['id','title']);  
136 - if(!empty($cateList)){  
137 - foreach ($cateList as $value){  
138 - $data[$value['id']] = $value['title']; 139 + $data = Common::get_user_cache('product_keyword',$this->user['project_id']);
  140 + if(empty($data)) {
  141 + $keywordModel = new Keyword();
  142 + $data = [];
  143 + $cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);
  144 + if (!empty($cateList)) {
  145 + foreach ($cateList as $value) {
  146 + $data[$value['id']] = $value['title'];
  147 + }
139 } 148 }
  149 + Common::set_user_cache($data,'product_keyword',$this->user['project_id']);
140 } 150 }
141 return $data; 151 return $data;
142 } 152 }
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Logic\Bside\Product; 3 namespace App\Http\Logic\Bside\Product;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
  6 +use App\Helper\Common;
6 use App\Http\Logic\Bside\BaseLogic; 7 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\Product\Category; 8 use App\Models\Product\Category;
8 use App\Models\Product\Product; 9 use App\Models\Product\Product;
@@ -77,6 +78,8 @@ class CategoryLogic extends BaseLogic @@ -77,6 +78,8 @@ class CategoryLogic extends BaseLogic
77 //路由映射 78 //路由映射
78 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); 79 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
79 $this->edit(['route'=>$route],['id'=>$id]); 80 $this->edit(['route'=>$route],['id'=>$id]);
  81 + //清除缓存
  82 + Common::del_user_cache('product_category',$this->user['project_id']);
80 DB::commit(); 83 DB::commit();
81 } catch (\Exception $e){ 84 } catch (\Exception $e){
82 DB::rollBack(); 85 DB::rollBack();
@@ -158,6 +161,8 @@ class CategoryLogic extends BaseLogic @@ -158,6 +161,8 @@ class CategoryLogic extends BaseLogic
158 $this->delRoute($id); 161 $this->delRoute($id);
159 $this->model->del(['id'=>$id]); 162 $this->model->del(['id'=>$id]);
160 } 163 }
  164 + //清除缓存
  165 + Common::del_user_cache('product_category',$this->user['project_id']);
161 DB::commit(); 166 DB::commit();
162 }catch (\Exception $e){ 167 }catch (\Exception $e){
163 DB::rollBack(); 168 DB::rollBack();
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product; @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product;
4 4
5 use App\Exceptions\BsideGlobalException; 5 use App\Exceptions\BsideGlobalException;
6 use App\Helper\Arr; 6 use App\Helper\Arr;
  7 +use App\Helper\Common;
7 use App\Http\Logic\Bside\BaseLogic; 8 use App\Http\Logic\Bside\BaseLogic;
8 use App\Models\Product\Keyword; 9 use App\Models\Product\Keyword;
9 use App\Models\Product\KeywordRelated; 10 use App\Models\Product\KeywordRelated;
@@ -63,6 +64,8 @@ class KeywordLogic extends BaseLogic @@ -63,6 +64,8 @@ class KeywordLogic extends BaseLogic
63 $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); 64 $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
64 } 65 }
65 $this->model->edit(['route'=>$route],['id'=>$id]); 66 $this->model->edit(['route'=>$route],['id'=>$id]);
  67 + //清除缓存
  68 + Common::del_user_cache('product_keyword',$this->user['project_id']);
66 DB::commit(); 69 DB::commit();
67 }catch (\Exception $e){ 70 }catch (\Exception $e){
68 DB::rollBack(); 71 DB::rollBack();
@@ -132,6 +135,8 @@ class KeywordLogic extends BaseLogic @@ -132,6 +135,8 @@ class KeywordLogic extends BaseLogic
132 $this->delRoute($id); 135 $this->delRoute($id);
133 $this->model->del(['id'=>$id]); 136 $this->model->del(['id'=>$id]);
134 } 137 }
  138 + //清除缓存
  139 + Common::del_user_cache('product_keyword',$this->user['project_id']);
135 return $this->success(); 140 return $this->success();
136 } 141 }
137 142