作者 lyh

gx

... ... @@ -7,6 +7,8 @@ use App\Exceptions\BsideGlobalException;
use App\Helper\Common;
use App\Http\Controllers\Controller;
use App\Http\Requests\Scene;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Exceptions\HttpResponseException;
... ... @@ -170,4 +172,53 @@ class BaseController extends Controller
return \Illuminate\Support\Facades\Request::isMethod('post');
}
/**
* @remark :获取当前用户选择的模版
* @name :getTemplateId
* @author :lyh
* @method :post
* @time :2024/1/3 10:52
*/
public function getTemplateId($source,$is_list){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return $this->success($template_id);
}
}
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先选择模版');
}
$template_id = $info['template_id'];
return $this->success($template_id);
}
/**
* @remark :查看是否已装修
* @name :getIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getIsRenovation($source,$is_list,$template_id,$id){
$webTemplateModel = new BTemplate();
$param = [
'source'=>$source,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$template_id,
'is_list'=>$is_list
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
return 0;
}
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Blog\BlogCategoryRequest;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
class BlogCategoryController extends BaseController
{
... ... @@ -25,9 +26,11 @@ class BlogCategoryController extends BaseController
$data = [];
if(!empty($lists)){
$blogModel = new BlogModel();
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
foreach ($lists as $k => $v){
$v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG_CATE,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST,$template_id,$v['id']);
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
... ...
... ... @@ -32,18 +32,15 @@ class BlogController extends BaseController
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
// //获取当前项目的所有分类
$data = $this->getCategoryList();
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL);
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
}
}
... ... @@ -51,31 +48,6 @@ class BlogController extends BaseController
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>BTemplate::SOURCE_BLOG,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id'],
'is_list'=>0
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return 0;
}
/**
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\News\NewsCategoryRequest;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
class NewsCategoryController extends BaseController
{
... ... @@ -25,9 +26,11 @@ class NewsCategoryController extends BaseController
$data = [];
if(!empty($lists)){
$newsModel = new NewsModel();
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
foreach ($lists as $k => $v){
$v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_LIST,$template_id,$v['id']);
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
... ...
... ... @@ -36,15 +36,14 @@ class NewsController extends BaseController
// //获取当前项目的所有分类
$data = $this->getCategoryList();
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
}
}
... ... @@ -52,31 +51,6 @@ class NewsController extends BaseController
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>4,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id'],
'is_list'=>0
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return 0;
}
/**
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Rules\Ids;
use Illuminate\Http\Request;
... ... @@ -36,10 +37,12 @@ class CategoryController extends BaseController
$list = $category->list($this->map,['sort','id'],$filed);
$data = [];
if(!empty($list)){
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
}
if(!isset($this->map['title'])){
... ...
... ... @@ -7,6 +7,7 @@ use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
use App\Http\Logic\Bside\Product\ProductLogic;
use App\Http\Requests\Bside\Product\ProductRequest;
use App\Models\Product\Category;
... ... @@ -52,15 +53,13 @@ class ProductController extends BaseController
$lists = $lists->toArray();
$cate_data = $this->getCategoryList();//分类
$key_data = $this->getKeywordsList();//关键字
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v['url'] = $this->user['domain'].$v['route'].'/';
$lists['list'][$k] = $v;
}
... ... @@ -119,31 +118,6 @@ class ProductController extends BaseController
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>2,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id'],
'is_list'=>0
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return 0;
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
... ... @@ -266,9 +240,8 @@ class ProductController extends BaseController
}
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']);
$template_id = $this->getTemplateId(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
$v['is_renovation'] = $this->getIsRenovation(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v['url'] = $this->user['domain'].$v['route'];
//获取当前数据扩展字段及值
$v['extend'] = $this->getExtendInfo($v['id']);
... ...
... ... @@ -45,6 +45,7 @@ class BTemplate extends Base
* 其他相关定义
*/
const IS_LIST = 1;//列表页
const IS_DETAIL = 0;//详情页
const IS_HEADER = 1;//独立头部底部
const IS_NO_HEADER = 0;//非独立头部底部
const IS_CUSTOM = 1;//为扩展模块
... ...