作者 lyh

gx

<?php
/**
* @remark :
* @name :BProjectIsComController.php
* @author :lyh
* @method :post
* @time :2024/8/1 14:24
*/
namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BProjectIsComLogic;
class BProjectIsComController extends BaseController
{
/**
* @remark :获取头部底部配置
* @name :getIsComConfig
* @author :lyh
* @method :post
* @time :2024/8/1 15:08
*/
public function getIsComConfig(BProjectIsComLogic $logic){
$data = $logic->getIsComConfig();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -93,9 +93,11 @@ class CustomModuleLogic extends BaseLogic
'name'=>$this->param['route'],
'module_id'=>$id,
'project_id'=>$this->param['project_id'],
'route'=>RouteMap::setRoute($this->param['route'],RouteMap::SOURCE_MODULE_CATE,$id,$this->param['project_id'])
'route'=>$this->param['route']
];
$customModuleCateModel->add($data);
$cateId = $customModuleCateModel->addReturnId($data);
$route = RouteMap::setRoute($this->param['route'],RouteMap::SOURCE_MODULE_CATE,$cateId,$this->param['project_id']);
$customModuleCateModel->edit(['route'=>$route],['id'=>$cateId]);
}
return $this->success();
}
... ...
<?php
/**
* @remark :
* @name :BProjectIsComLogic.php
* @author :lyh
* @method :post
* @time :2024/8/1 14:25
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\IsCom\ProjectIsCom;
use App\Models\Template\BTemplate;
/**
* @remark :独立头部——底部设置
* @name :BProjectIsComLogic
* @author :lyh
* @method :post
* @time :2024/8/1 14:43
*/
class BProjectIsComLogic extends BaseLogic
{
/**
* 初始化数据
*/
public function __construct()
{
parent::__construct();
$this->model = new ProjectIsCom();
$this->param = $this->requestAll;
}
const PUB_STATUS = 0;//公共
const PRO_STATUS = 1;//獨立
const IS_LIST = 1;
const IS_DETAIL = 0;
const IS_NO_CUSTOM = 0;
const IS_CUSTOM = 1;//扩展模块
/**
* @remark :获取初始数据
* @name :getIsComSetting
* @author :lyh
* @method :post
* @time :2024/8/1 15:02
*/
public function getIsComConfig(){
$data = [];
$data = $this->initParamData($data);
$data = $this->initPageParamData($data);
$data = $this->initCustomData($data);
return $this->success($data);
}
/**
* @remark :(独立头底)初始数据
* @name :initializedData
* @author :lyh
* @method :post
* @time :2024/8/1 11:52
*/
public function initParamData(&$data){
//默认模块
$initParam = $this->model->initParam;
foreach ($initParam as $pKey => $pValue){
$is_list = [self::IS_LIST,self::IS_DETAIL];
foreach ($is_list as $isValue){
//查询当前数据是否已保存
$info = $this->read(['source'=>$pValue,'is_list'=>$isValue,'is_custom'=>BTemplate::IS_NO_CUSTOM],['name','source','is_list','is_custom','header_status','footer_status']);
if($info !== false){
$data[] = $info;
}else{
$data[] = [
'name'=>$pKey.($isValue == 0 ? '详情' : '列表'),
'source'=>$pValue,
'is_list'=>$isValue,
'is_custom'=>self::IS_NO_CUSTOM,
'header_status'=>self::PUB_STATUS,
'footer_status'=>self::PUB_STATUS,
];
}
}
}
return $this->success($data);
}
/**
* @remark :单页面初始化
* @name :initPageParamData
* @author :lyh
* @method :post
* @time :2024/8/1 14:37
*/
public function initPageParamData(&$data){
$initPageParam = $this->model->initPageParam;
foreach($initPageParam as $key => $value){
$info = $this->read(['source'=>$value,'is_list'=>self::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM],['name','source','is_list','is_custom','header_status','footer_status']);
if($info !== false){
$data[] = $info;
}else{
$data[] = [
'name'=>$key,
'source'=>$value,
'is_list'=>self::IS_DETAIL,
'is_custom'=>self::IS_NO_CUSTOM,
'header_status'=>self::PUB_STATUS,
'footer_status'=>self::PUB_STATUS,
];
}
}
return $this->success($data);
}
/**
* @remark :获取扩展模块初始数据
* @name :initCustomData
* @author :lyh
* @method :post
* @time :2024/8/1 14:42
*/
public function initCustomData(&$data){
$customModel = new CustomModule();
$customList = $customModel->list(['status'=>0]);
$is_list = [self::IS_LIST,self::IS_DETAIL];
foreach($customList as $value){
foreach ($is_list as $isValue){
$info = $this->model->read(['source'=>$value['id'],'is_list'=>$isValue,'is_custom'=>BTemplate::IS_CUSTOM],['id','name','source','is_list','is_custom','header_status','footer_status']);
if($info !== false){
$data[] = $info;
}else{
$data[] = [
'name'=>$value['name'].($isValue == self::IS_DETAIL ? '详情' : '列表'),
'source'=>$value['id'],
'is_list'=>$isValue,
'is_custom'=>self::IS_CUSTOM,
'header_status'=>self::PUB_STATUS,
'footer_status'=>self::PUB_STATUS,
];
}
}
}
return $this->success($data);
}
}
... ...
... ... @@ -23,13 +23,13 @@ use App\Models\Template\Template;
*/
class ProjectIsCom extends Base
{
protected $table = 'gl_project_is_com';
protected $table = 'gl_project_com_config';
/**
* @name :(包含详情页+列表页)
* @var array
*/
protected $initParam = [
public $initParam = [
'首页'=>BTemplate::SOURCE_HOME,
'产品'=>BTemplate::SOURCE_PRODUCT,
'博客'=>BTemplate::SOURCE_BLOG,
... ... @@ -40,34 +40,8 @@ class ProjectIsCom extends Base
* @name : 单一界面
* @var array
*/
protected $initPageParam = [
public $initPageParam = [
'单页面'=>BTemplate::SOURCE_PAGE,
];
/**
* @remark :初始数据
* @name :initializedData
* @author :lyh
* @method :post
* @time :2024/8/1 11:52
*/
public function initializedData(){
$data = [];
$initParam = $this->initParam;
foreach ($initParam as $pKey => $pValue){
$is_list = [BTemplate::IS_LIST,BTemplate::IS_DETAIL];
foreach ($is_list as $isValue){
$name = $pKey.($isValue == 0 ? '详情' : '列表');
$data[] = [
'name'=>$name,
'source'=>$pValue,
'is_list'=>$isValue,
'header_status'=>0,
'footer_status'=>0,
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
}
}
}
}
... ...
... ... @@ -554,6 +554,10 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'save'])->name('template_label_save');
Route::any('/del', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'del'])->name('template_label_del');
});
//设置公共头部+底部配置
Route::prefix('com_config')->group(function () {
Route::any('/getIsComConfig', [\App\Http\Controllers\Bside\Template\BProjectIsComController::class, 'getIsComConfig'])->name('template_label_getUserLists');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...