作者 lyh

gx

... ... @@ -42,7 +42,7 @@ class KeywordController extends BaseController
foreach ($data['list'] as &$v){
$v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['id'].',%')->count();
$v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
$v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$v['url'] = $this->user['domain'] . $v['url'];
}
}
return $this->response('success',Code::SUCCESS,$data);
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\ProductLogic;
use App\Http\Requests\Bside\Product\ProductRequest;
... ... @@ -18,6 +19,7 @@ use App\Models\Template\BTemplate;
use App\Models\User\User;
use App\Rules\Ids;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -111,6 +113,8 @@ class ProductController extends BaseController
* @time :2023/9/14 13:56
*/
public function getCategoryList(){
$data = Common::get_user_cache('product_category',$this->user['project_id']);
if(empty($data)){
$categoryModel = new Category();
$data = [];
$cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);
... ... @@ -119,6 +123,8 @@ class ProductController extends BaseController
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_category',$this->user['project_id']);
}
return $data;
}
... ... @@ -130,14 +136,18 @@ class ProductController extends BaseController
* @time :2023/9/14 13:56
*/
public function getKeywordsList(){
$data = Common::get_user_cache('product_keyword',$this->user['project_id']);
if(empty($data)) {
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['project_id'=>$this->user['project_id']],['id','title']);
if(!empty($cateList)){
foreach ($cateList as $value){
$cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_keyword',$this->user['project_id']);
}
return $data;
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Logic\Bside\Product;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Category;
use App\Models\Product\Product;
... ... @@ -77,6 +78,8 @@ class CategoryLogic extends BaseLogic
//路由映射
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
$this->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
} catch (\Exception $e){
DB::rollBack();
... ... @@ -158,6 +161,8 @@ class CategoryLogic extends BaseLogic
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
... ... @@ -63,6 +64,8 @@ class KeywordLogic extends BaseLogic
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
}
$this->model->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -132,6 +135,8 @@ class KeywordLogic extends BaseLogic
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
return $this->success();
}
... ...