作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

正在显示 32 个修改的文件 包含 873 行增加383 行删除
... ... @@ -68,13 +68,13 @@ class UpdateRoute extends Command
*/
public function getProductKeyword(){
$keywordModel = new Keyword();
$lists = $keywordModel->list(['route'=>null]);
$lists = $keywordModel->list(['route'=>'']);
if(!empty($lists)){
foreach ($lists as $v){
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], 75);
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);
$this->curlDelRoute(['new_route'=>$route]);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
$this->model->edit(['route'=>$route],['id'=>$v['id']]);
echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL;
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleController.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:42
*/
namespace App\Http\Controllers\Aside\CustomModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\CustomModule\CustomModuleLogic;
use App\Models\CustomModule\CustomModule;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
/**
* @remark :自定义模块
* @name :CustomModuleController
* @author :lyh
* @method :post
* @time :2023/12/4 15:42
*/
class CustomModuleController extends BaseController
{
/**
* @remark :获取自定义模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/12/4 15:43
*/
public function lists(){
ProjectServer::useProject($this->param['project_id']);
$customModule = new CustomModule();
$this->map['status'] = 0;
$lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
DB::disconnect('custom_mysql');
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取当前数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/12/4 16:09
*/
public function info(CustomModuleLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$info = $logic->getCustomModuleInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/12/4 15:45
*/
public function save(CustomModuleLogic $logic){
$this->request->validate([
'name'=>['required'],
],[
'name.required' => '模块名称不能为空',
]);
$logic->customModuleSave();
$this->response('success');
}
/**
* @remark :删除
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/5 9:53
*/
public function del(CustomModuleLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$logic->customModuleDel();
$this->response('success');
}
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\UserLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
... ... @@ -53,6 +54,24 @@ class ComController extends BaseController
$this->response('当前用户菜单列表',Code::SUCCESS,$menu);
}
/**
* @remark :获取当前菜单的自定义模块
* @name :getProjectCustomMenu
* @author :lyh
* @method :post
* @time :2023/12/13 16:48
*/
public function getCustomMenu(){
$customModel = new CustomModule();
$list = $customModel->list(['status'=>0],['sort','id']);
if(!empty($list)){
foreach ($list as $k=>$v){
$v['sub'] = [$v['name'].'管理',$v['name'].'分类'];
$list[$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$list);
}
/**
* @name :获取当前项目详情
... ... @@ -78,6 +97,9 @@ class ComController extends BaseController
$code = $this->getIsHome();
$projectRoleModel = new ProjectRoleModel();
$info = $projectRoleModel->read(['id'=>$this->user['role_id']]);
if($info === false){
$this->fail('当前登录角色不存在');
}else{
if($code != 1){
$info['role_menu'] = trim(str_replace(',11,',',',','.$info['role_menu'].','),',');
}
... ... @@ -86,6 +108,7 @@ class ComController extends BaseController
'is_role'=>0,
'id'=>['in',explode(',',$info['role_menu'])]
];
}
return $this->map;
}
... ... @@ -114,9 +137,6 @@ class ComController extends BaseController
* @time :2023/9/6 11:30
*/
public function getIsHome(){
if(isset($this->user['manager_id'])){
return 1;
}
$deployBuild = new DeployBuild();
$info = $deployBuild->read(['project_id'=>$this->user['project_id']]);
if(!empty($info['configuration'])){
... ...
... ... @@ -127,19 +127,9 @@ class BaseController extends Controller
* @param bool $objectData
* @return JsonResponse
*/
function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
function success($data) :array
{
if ($objectData) {
$data = (object)$data;
}
$code = Code::fromValue($code);
$response = [
'code' => $code->value,
'data' => $data,
'message' => $code->description,
];
$this->header['token'] = $this->token;
return response()->json($response,200,$this->header);
return $data;
}
/**
... ...
... ... @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\User\User;
class CustomModuleCategoryController extends BaseController
{
... ...
... ... @@ -14,6 +14,7 @@ use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\User\User;
class CustomModuleContentController extends BaseController
{
... ... @@ -31,9 +32,15 @@ class CustomModuleContentController extends BaseController
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order);
foreach ($lists as $v){
//获取分类名称
$lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order = ['sort','id']);
if(!empty($lists)){
$data = $this->getAllCategoryName();
foreach ($lists['list'] as $k=>$v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = (new User())->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -52,7 +59,27 @@ class CustomModuleContentController extends BaseController
foreach ($list as $v){
$data[$v['id']] = $v['name'];
}
return $this->success($data);
return $data;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
*/
public function categoryName($category_id,$data){
$category_name = '';
if(!empty($category_id) && !empty($data)){
foreach ($category_id as $v){
if(isset($data[$v])){
$category_name .= $data[$v].',';
}
}
$category_name = trim($category_name,',');
}
return $category_name;
}
/**
... ... @@ -131,4 +158,23 @@ class CustomModuleContentController extends BaseController
$logic->contentDel();
$this->response('success');
}
/**
* @remark :排序
* @name :sort
* @author :lyh
* @method :post
* @time :2023/12/15 17:46
*/
public function sort(CustomModuleContentLogic $logic){
$this->request->validate([
'id'=>['required'],
'sort'=>['required']
],[
'id.required' => 'ID不能为空',
'sort.required' => '排序不能为空',
]);
$logic->contentSort();
$this->response('success');
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Bside\Inquiry;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Inquiry\InquiryLogic;
use App\Models\Inquiry\InquiryForm;
... ... @@ -31,7 +32,7 @@ class InquiryController extends BaseController
}
$item['field_text'] = $field_text;
}
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
public function index(InquiryLogic $logic)
... ... @@ -43,7 +44,7 @@ class InquiryController extends BaseController
}else{
$data = $logic->getApiList();
}
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
public function info(Request $request, InquiryLogic $logic){
... ... @@ -60,8 +61,7 @@ class InquiryController extends BaseController
}else{
$data = $logic->getInfo($this->param['id']);
}
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
public function delete(Request $request, InquiryLogic $logic)
... ... @@ -79,7 +79,7 @@ class InquiryController extends BaseController
$logic->delete($this->param['ids']);
}
return $this->success();
$this->response('success');
}
/**
... ... @@ -141,6 +141,6 @@ class InquiryController extends BaseController
}
$fileurl = Storage::disk('runtime')->url($file);
// return Storage::disk('runtime')->download($file); //直接下载
return $this->success(['url' => $fileurl]);
$this->response('success',Code::SUCCESS,['url' => $fileurl]);
}
}
... ...
... ... @@ -299,4 +299,5 @@ class LoginController extends BaseController
}
return $data;
}
}
... ...
... ... @@ -102,7 +102,7 @@ class MailController extends BaseController
$arr[] = $v['mail_id'];
}
$mailModel = new MailModel();
$mail_list = $mailModel->list(['id'=>['not in',$arr]]);
$mail_list = $mailModel->list(['id'=>['not in',$arr],'user_list'=>['like',','.$this->user['id'].',']]);
$data = [];
foreach ($mail_list as $k => $v){
$data[] = [
... ...
... ... @@ -66,7 +66,6 @@ class NavController extends BaseController
$request->validated();
$logic->navSave();
$this->response('success');
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\AttrLogic;
... ... @@ -26,7 +27,7 @@ class AttrController extends BaseController
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'title', 'attrs'],$this->row);
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
public function info(Request $request, AttrLogic $logic){
... ... @@ -36,14 +37,14 @@ class AttrController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'attrs']));
$this->response('success',Code::SUCCESS,Arr::twoKeepKeys($data, ['id', 'title', 'attrs']));
}
public function save(AttrRequest $request, AttrLogic $logic)
{
$request->validated();
$data = $logic->attrSave();
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
public function delete(Request $request, AttrLogic $logic)
... ... @@ -55,7 +56,7 @@ class AttrController extends BaseController
]);
$data = $logic->delete($this->param['ids']);
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -110,7 +110,7 @@ class CategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getCateInfo($this->param['id']);
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
/**
... ... @@ -159,6 +159,6 @@ class CategoryController extends BaseController
'ids.required' => 'ID不能为空'
]);
$data = $logic->categoryDelete();
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -37,7 +37,7 @@ class DescribeController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at']));
$this->response('success',Code::SUCCESS,Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at']));
}
/**
... ... @@ -51,7 +51,7 @@ class DescribeController extends BaseController
{
$request->validated();
$logic->describeSave();
return $this->success();
$this->response('success');
}
public function delete(Request $request, DescribeLogic $logic)
... ... @@ -61,9 +61,8 @@ class DescribeController extends BaseController
],[
'ids.required' => 'ID不能为空'
]);
$data = $logic->delete($this->param['ids']);
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -66,7 +66,7 @@ class KeywordController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getKeywordInfo();
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
/**
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Bside\RankData;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\GoogleSpeedApi;
use App\Helper\QuanqiusouApi;
... ... @@ -30,7 +31,7 @@ class RankDataController extends BaseController
public function index(RankDataLogic $logic)
{
$data = $logic->index();
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
/**
... ... @@ -42,7 +43,7 @@ class RankDataController extends BaseController
*/
public function keywords_rank_list(RankDataLogic $logic){
$data = $logic->keywords_rank_list();
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -73,7 +74,7 @@ class RankDataController extends BaseController
}else{
$data = [];
}
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
/**
... ... @@ -121,7 +122,7 @@ class RankDataController extends BaseController
}
$fileurl = Storage::disk('runtime')->url($file);
// return Storage::disk('runtime')->download($file); //直接下载
return $this->success(['url' => $fileurl]);
$this->response('success',Code::SUCCESS,['url' => $fileurl]);
}
/**
... ... @@ -169,7 +170,8 @@ class RankDataController extends BaseController
}
$fileurl = Storage::disk('runtime')->url($file);
// return Storage::disk('runtime')->download($file); //直接下载
return $this->success(['url' => $fileurl]);
$this->response('success',Code::SUCCESS,['url' => $fileurl]);
}
/**
... ... @@ -221,6 +223,6 @@ class RankDataController extends BaseController
$data['position'] = $res['position'];
}
}
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -4,6 +4,7 @@
namespace App\Http\Controllers\Bside\Route;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\RouteMap\RouteMap;
use Illuminate\Http\Request;
... ... @@ -23,8 +24,7 @@ class RouteController extends BaseController
$source = $request->input('source');
$source_id = $request->input('source_id');
$project_id = $this->user['project_id'];
$route = RouteMap::generateRoute($title, $source, $source_id, $project_id);
return $this->success(['route' => $route]);
$this->response('success',Code::SUCCESS,['route' => $route]);
}
}
... ...
... ... @@ -36,12 +36,15 @@ class BTemplateLogController extends BaseController
unset($this->map['template_id']);
$this->map['project_id'] = $this->user['project_id'];
$this->map['source'] = 1;
$this->map['is_custom'] = 0;
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
if(!empty($lists['list'])){
$templateModel = new Template();
$userModel = new User();
foreach ($lists['list'] as $k => $v){
if(!empty($v['template_id'])){
$v['template_name'] = $templateModel->read(['id'=>$v['template_id']],['name'])['name'];
}
$v['operator_name'] = $userModel->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Controllers\Bside\User;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\DeptLogic;
... ... @@ -26,7 +27,7 @@ class DeptController extends BaseController
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'pid', 'title'],0);
return $this->success(Arr::listToTree($data));
$this->response('success',Code::SUCCESS,Arr::listToTree($data));
}
public function info(Request $request, DeptLogic $logic){
... ... @@ -36,13 +37,13 @@ class DeptController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'manager_uids', 'remark']));
$this->response('success',Code::SUCCESS,Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'manager_uids', 'remark']));
}
public function save(DeptRequest $request, DeptLogic $logic)
{
$data = $logic->save($this->param);
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
public function delete(DeptLogic $logic)
... ... @@ -54,6 +55,6 @@ class DeptController extends BaseController
]);
$data = $logic->delete($this->param['ids']);
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleLogic.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:46
*/
namespace App\Http\Logic\Aside\CustomModule;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class CustomModuleLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
}
/**
* @remark :获取当前数据详情
* @name :getCustomModuleInfo
* @author :lyh
* @method :post
* @time :2023/12/4 16:10
*/
public function getCustomModuleInfo(){
ProjectServer::useProject($this->param['project_id']);
$info = (new CustomModule())->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
DB::disconnect('custom_mysql');
return $this->success($info);
}
/**
* @remark :保存数据
* @name :ModuleSave
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleSave(){
$this->param = $this->handleParam($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->moduleEdit();
}else{
$this->moduleAdd();
}
return $this->success();
}
/**
* @name :(参数处理)paramProcessing
* @author :lyh
* @method :post
* @time :2023/6/13 11:30
*/
public function handleParam($param)
{
$param['operator_id'] = $this->manager['id'];
if(!isset($param['id']) || empty($param['id'])){
$param['project_id'] = $this->param['project_id'];
}
return $this->success($param);
}
/**
* @remark :新增
* @name :moduleAdd
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleAdd(){
ProjectServer::useProject($this->param['project_id']);
$rs = (new CustomModule())->add($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
DB::disconnect('custom_mysql');
return $this->success();
}
/**
* @remark :编辑
* @name :moduleEdit
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleEdit(){
ProjectServer::useProject($this->param['project_id']);
$rs = (new CustomModule())->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
DB::disconnect('custom_mysql');
return $this->success();
}
/**
* @remark :删除数据
* @name :ModuleDel
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleDel(){
ProjectServer::useProject($this->param['project_id']);
//查看当前模块是否拥有数据
$contentModel = new CustomModuleContent();
$contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
if($contentInfo !== false){
$this->fail('当前模块拥有内容不允许删除');
}
$categoryModel = new CustomModuleCategory();
$categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
if($categoryInfo !== false){
$this->fail('当前模块拥有分类不允许删除');
}
$rs = (new CustomModule())->del($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
DB::disconnect('custom_mysql');
return $this->success();
}
}
... ...
... ... @@ -706,7 +706,7 @@ class ProjectLogic extends BaseLogic
public function saveOtherProject(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
$this->fail('保存失败,请联系管理员');
}
return $this->success($this->param);
}
... ...
... ... @@ -55,8 +55,7 @@ class BTemplateLogLogic extends BaseLogic
}
try {
$data = $this->setParam($info);
$BTemplateModel = new BTemplate();
$BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$bTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\PageSetting;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplateCommon;
... ... @@ -61,99 +62,144 @@ class BTemplateLogic extends BaseLogic
* @time :2023/6/29 9:44
*/
public function getTemplate(){
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先选择模版');
$template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id
$data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);
return $this->success($data);
}
if($this->param['source'] == $this->model::SOURCE_HOME){//首页
$TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
/**
* @remark :获取可视化装修的html
* @name :getTemplateHtml
* @author :lyh
* @method :post
* @time :2023/12/13 10:47
*/
public function getHtml($template_id,$source,$source_id,$is_custom){
$templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom);
if($templateInfo === false){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
$html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
$mainInfo = $this->getCommonMain($source,$source_id,$is_custom);//获取中间部分代码
}else{
$TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
$type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型
$commonInfo = $this->getCommonPage(0,$this->user['project_id'],$type);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
return $this->success($TemplateInfo);
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
}
$commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
/**
* @remark :根据参数获取数据详情
* @name :webTemplateInfo
* @remark :返回整个html截取代码
* @name :handleAllHtml
* @author :lyh
* @method :post
* @time :2023/7/25 16:41
* @time :2023/12/13 15:39
*/
public function webTemplateInfo($template_id,$source,$source_id){
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->model->read([
'template_id'=>$template_id,
'source'=>$source,
'project_id'=>$this->user['project_id'],
'source_id'=>$source_id,
]);
return $this->success($TemplateInfo);
public function handleAllHtml($commonInfo,$html){
if(!empty($commonInfo)){
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
}
return $html;
}
/**
* @remark :处理首页数据
* @name :homeHtml
* @remark :页面是否为定制页面获取初始代码
* @name :watchProjectIsCustomized
* @author :lyh
* @method :post
* @time :2023/7/25 16:36
* @time :2023/12/13 10:55
*/
public function homeHtml($info,$source,$source_id){
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
//获取模板详情
$ATemplateModel = new Template();
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
}else{
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
if($commonInfo !== false){
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
public function isCustomizedPage($source,$source_id)
{
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
//TODO::获取初始代码
$bTemplateMainModel = new BTemplateMain();
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$type]);
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$ATemplateModel = new Template();
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']);
$TemplateInfo['name'] = $ATemplateInfo['name'];
$TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
return $customHtmlInfo['main_html'];
}
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
return $this->success($TemplateInfo);
return [];
}
/**
* @remark :处理其他页数据
* @name :ProductHtml
* @remark :定制界面根据source+source_id获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/7/25 16:40
* @time :2023/11/16 11:20
*/
public function otherHtml($info,$source,$source_id){
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
public function getCustomizedType($source,$source_id){
$type = BTemplate::TYPE_ONE;
if($source == BTemplate::SOURCE_PRODUCT){
if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;}
}
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
$mainInfo = $this->getCommonMain($source,$source_id);
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
$TemplateInfo['template_id'] = $info['template_id'];
}else{
$main_html = $TemplateInfo['main_html'];
$main_style = $TemplateInfo['main_css'];
if($source == BTemplate::SOURCE_BLOG){
if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
}
$commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']);
if($commonInfo !== false){
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html);
if($source == BTemplate::SOURCE_NEWS){
if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
}
return $type;
}
/**
* @remark :获取当前项目设置的模版
* @name :getSettingTemplate
* @author :lyh
* @method :post
* @time :2023/12/13 10:48
*/
public function getSettingTemplate($source,$source_id){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return 0;
}
}
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先选择模版');
}
return $info['template_id'];
}
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
/**
* @remark :根据参数获取数据详情
* @name :webTemplateInfo
* @author :lyh
* @method :post
* @time :2023/7/25 16:41
*/
public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->model->read([
'template_id'=>$template_id,
'source'=>$source,
'project_id'=>$this->user['project_id'],
'source_id'=>$source_id,
'is_custom'=>$is_custom
]);
return $this->success($TemplateInfo);
}
... ... @@ -164,12 +210,16 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/10/24 15:58
*/
public function getCommonMain($source,$source_id){
public function getCommonMain($source,$source_id,$is_custom){
$data = [];
if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}}
if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}}
if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}
if ($source == 5) {$type = 8;}
if($is_custom == BTemplate::SOURCE_CUSTOM){
if($source_id != 0){$type = BTemplate::TYPE_SIX;}else{$type = BTemplate::TYPE_SEVEN;}
}else{
if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}
if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}
if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}
if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;}
}
//查询有没有公共详情模板
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
... ... @@ -201,23 +251,23 @@ class BTemplateLogic extends BaseLogic
'template_id' => $template_id,
'project_id' => $this->user['project_id']
];
if ($source == 2) {//产品页
if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 3) {//博客页
if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 4) {//新闻页
if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 5) {//聚合页
$data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
if ($source == BTemplate::SOURCE_PRODUCT) {//产品页
if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == BTemplate::SOURCE_BLOG) {//博客页
if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == BTemplate::SOURCE_NEWS) {//新闻页
if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
$data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
}
}
//获取首页公共的头部和底部
if(!isset($commonInfo) || $commonInfo === false){
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]);
}
return $commonInfo;
}
... ... @@ -230,86 +280,220 @@ class BTemplateLogic extends BaseLogic
* @time :2023/6/29 11:05
*/
public function templateSave(){
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$this->model->mobile)) && ($this->param['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
//演示项目不允许修改
$this->showProjectNoEdit($this->param['source']);
// DB::beginTransaction();
// try {
$this->param = $this->handleDefaultString($this->param);//设置默认字符
$templateInfo = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],
$this->param['source_id'],$this->param['is_custom']);
if($templateInfo === false){//执行新增
$this->templateAddHtml($this->param['html'], $this->param['source'], $this->param['source_id'],
$this->param['template_id'], $this->param['section_list_id'], $this->param['is_custom']);
}else{//执行编辑
$this->templateEditHtml($this->param['html'],$this->param['source'],$this->param['source_id'],
$this->param['template_id'],$this->param['section_list_id'], $this->param['is_custom']);
}
//更新头部信息
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']);
return $this->success();
}
//查询当前模版是否已保存
DB::beginTransaction();
try {
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
//字符串截取
$this->param = $this->stringProcessing($this->param);
//保存头部信息
$this->saveCommonTemplate($this->param);
$param = $this->templateSaveParam($this->param);//组装数据
if($info === false){
$this->model->add($param);
/**
* @remark :保存数据时设置默认字符
* @name :saveDefaultString
* @author :lyh
* @method :post
* @time :2023/12/15 10:30
*/
public function handleDefaultString($param){
if(!isset($param['template_id'])){
$param['template_id'] = 0;
}
if(!isset($param['is_custom'])){
$param['is_custom'] = 0;
}
if(!isset($param['section_list_id'])){
$param['section_list_id'] = '';
}
return $this->success($param);
}
/**
* @remark :可视化添加数据
* @name :templateAddHtml
* @author :lyh
* @method :post
* @time :2023/12/15 10:15
*/
public function templateAddHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){
$data = [
'source'=>$source, 'source_id'=>$source_id,'type'=>BTemplate::PAGE_HTML,
'template_id'=>$template, 'project_id'=>$this->user['project_id'],
'section_list_id'=>$section_list_id,'is_custom'=>$is_custom,
];
$data = $this->handleVisualizationParam($html,$source,$source_id,$data);
$this->model->add($data);
return true;
}
/**
* @remark :可视化更新html
* @name :templateEditHtml
* @author :lyh
* @method :post
* @time :2023/12/15 10:26
*/
public function templateEditHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){
$condition = [
'source'=>$source, 'source_id'=>$source_id,
'is_custom'=>$is_custom, 'template_id'=>$template
];
$data = [
'section_list_id'=>$section_list_id
];
$data = $this->handleVisualizationParam($html,$source,$source_id,$data);
$this->model->edit($data,$condition);
return true;
}
/**
* @remark :处理可视化数据
* @name :handleProjectParam
* @author :lyh
* @method :post
* @time :2023/12/15 10:59
*/
public function handleVisualizationParam($html,$source, $source_id,$data){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//当前页面是定制界面
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
}else{
$this->model->edit($param,['id'=>$info['id']]);
$mainInfo = $this->handleTemplateHtml($html);
$data['main_html'] = $mainInfo['main_html'];
$data['main_css'] = $mainInfo['main_css'];
}
//写入操作模版记录
$this->setTemplateLog($this->param);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}else{
$mainInfo = $this->handleTemplateHtml($html);
$data['main_html'] = $mainInfo['main_html'];
$data['main_css'] = $mainInfo['main_css'];
}
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
return $this->success();
return $data;
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @remark :保存公共头部底部
* @name :saveCommonHtml
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
* @time :2023/12/13 17:05
*/
public function saveCommonTemplate($param){
$type = $this->getType($param['source'],$param['source_id']);
public function saveCommonHtml($html,$source,$source_id,$template_id){
$type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面)
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$param['head_html'],
'head_css'=>$param['head_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
];
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
$data['type'] = $type;
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$param['template_id']]);
return $this->success();
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
}
/**
* @remark :演示项目不允许修改首页
* @name :showProject
* @author :lyh
* @method :post
* @time :2023/12/12 11:27
*/
public function showProjectNoEdit($source){
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$this->model->mobile)) && ($source == BTemplate::SOURCE_HOME)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
return true;
}
/**
* @remark :保存时字符串处理
* @name :handleCommonParam
* @author :lyh
* @method :post
* @time :2023/6/29 15:35
*/
public function handleCommonParam($html){
//字符串截取
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
$param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
return $this->success($param);
}
/**
* @remark :保存时字符串处理
* @name :handleSaveParam
* @author :lyh
* @method :post
* @time :2023/6/29 15:35
*/
public function handleTemplateHtml($html){
//字符串截取
$param['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
return $this->success($param);
}
/**
* @remark :获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$source_id){
public function getType($source,$source_id,$template_id){
$type = 1;//首页公共头部底部
if($template_id == 0){//保存上传的代码块时,默认为独立头部
$this->user['configuration']['is_head'] == 1;
}
//查看页面是否设置自定义头部底部
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo !== false) {
if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}}
if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}}
if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}}
if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}}
}
}
return $type;
... ... @@ -322,22 +506,24 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/8/23 11:16
*/
public function setTemplateLog($param){
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
$data = [
'template_id'=>$param['template_id'],
'template_id'=>$template_id,
'project_id'=>$this->user['project_id'],
'operator_id'=>$this->user['id'],
'text'=>$param['html'],
'source'=>$param['source'],
'source_id'=>$param['source_id'],
'head_html'=>$param['head_html'],
'head_css'=>$param['head_css'],
'main_html'=>$param['main_html'],
'main_css'=>$param['main_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'text'=>$html,
'type'=>$type,
'is_custom'=>$is_custom,
'source'=>$source,
'source_id'=>$source_id,
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
];
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
... ... @@ -350,52 +536,30 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/7/31 16:05
*/
public function homeOrProduct($source,$source_id = ''){
public function homeOrProduct($source,$source_id = '',$is_custom = 0){
if($is_custom == 0){
if($source == BTemplate::SOURCE_HOME){
$type = 'index';
$route = 'index';
//路由映射
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
}else{
//其他界面通知更新
if($source == 2 && $source_id != 0){
$type = RouteMap::SOURCE_INDEX;
}elseif($source == BTemplate::SOURCE_PRODUCT){
$type = RouteMap::SOURCE_PRODUCT;
$productModel = new Product();
$productInfo = $productModel->read(['id'=>$source_id],['route']);
$route = $productInfo['route'];
}elseif($source == 3 && $source_id != 0){
}elseif($source == BTemplate::SOURCE_BLOG){
$type = RouteMap::SOURCE_BLOG;
$blogModel = new Blog();
$blogInfo = $blogModel->read(['id'=>$source_id],['url']);
$route = $blogInfo['url'];
}elseif($source == 4 && $source_id != 0){
}elseif($source == BTemplate::SOURCE_NEWS){
$type = RouteMap::SOURCE_NEWS;
$newsModel = new News();
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
$route = $newsInfo['url'];
}else{
$type = 'all';
$route = 'all';
}
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
}else{
$type = RouteMap::SOURCE_MODULE;
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
}
$this->addUpdateNotify($type,$route);
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
}
/**
* @remark :处理保存模版数据
* @name :templateParam
* @author :lyh
* @method :post
* @time :2023/7/21 16:30
*/
public function templateSaveParam($param){
$param['project_id'] = $this->user['project_id'];
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
return $this->success($param);
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
... ... @@ -419,13 +583,13 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :字符串处理
* @name :StringProcessing
* @remark :保存时字符串处理
* @name :handleSaveParam
* @author :lyh
* @method :post
* @time :2023/6/29 15:35
*/
public function stringProcessing($param){
public function handleSaveParam($param){
//字符串截取
$param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
$param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
... ... @@ -433,6 +597,10 @@ class BTemplateLogic extends BaseLogic
$param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
if(!isset($param['is_custom'])){
$param['is_custom'] = BTemplate::SOURCE_NO_CUSTOM;
}
$param['type'] = BTemplate::PAGE_HTML;//不显示整个HTML
return $this->success($param);
}
... ... @@ -444,7 +612,6 @@ class BTemplateLogic extends BaseLogic
* @time :2023/7/27 15:08
*/
public function getModule($type){
//获取公共主题头部底部
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type]);
return $info['main_html'];
... ... @@ -529,7 +696,7 @@ class BTemplateLogic extends BaseLogic
$this->param['test_model'] = 2;//未审核模版
$this->param['operator_id'] = $this->user['manager_id'] ?? 0;
$this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s');
$this->param = $this->stringProcessing($this->param);
$this->param = $this->handleSaveParam($this->param);
$publicTemplateModel = new Template();
$rs = $publicTemplateModel->add($this->param);
if($rs === false){
... ... @@ -551,20 +718,8 @@ class BTemplateLogic extends BaseLogic
if($bSettingInfo === false){
$this->fail('请先设置模板');
}
//获取首页公共部分
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
if($commonInfo === false){
$this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页');
}
//判断当前项目是否有设置独立头部的权限
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
//有权限时,获取独立头部
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($commonTypeInfo !== false){
$commonInfo = $commonTypeInfo;
}
}
$is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
$commonInfo = $this->getTypeCommonHtml($bSettingInfo['template_id'],$is_custom);
//获取设置的默认中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
... ... @@ -582,6 +737,31 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :根据type获取html
* @name :getHeaderFooter
* @author :lyh
* @method :post
* @time :2023/12/15 18:06
*/
public function getTypeCommonHtml($template_id,$is_custom){
//获取首页公共部分
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
//判断当前项目是否有设置独立头部的权限
if($is_custom == BTemplate::SOURCE_CUSTOM){
return $this->success($commonInfo);
}
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
//有权限时,获取独立头部
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($commonTypeInfo !== false){
$commonInfo = $commonTypeInfo;
}
}
return $this->success($commonInfo);
}
/**
* @remark :保存详情模板数据
* @name :saveDetail
* @author :lyh
... ... @@ -594,6 +774,7 @@ class BTemplateLogic extends BaseLogic
if($bSettingInfo === false){
$this->fail('请先设置模板');
}
$is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
$data = [
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
... ... @@ -601,37 +782,53 @@ class BTemplateLogic extends BaseLogic
$data['section_list_id'] = $this->param['section_list_id'];
//保存中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);
if($mainInfo === false){
$data['project_id'] = $this->user['project_id'];
$data['type'] = $this->param['type'];
$data['is_custom'] = $is_custom;
$bTemplateMainModel->add($data);
}else{
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
}
$this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']);
return $this->success();
}
/**
* @remark :保存详情页模版头部底部
* @name :saveDetailCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/15 18:12
*/
public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){
$publicData = [
'head_html' => characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html' => characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'other'=>str_replace('<header','',characterTruncation($this->param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块
$this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM;
}
$templateCommonModel = new BTemplateCommon();
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
$templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
$templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
if($templateCommonInfo === false){
$publicData['type'] = $this->param['type'];
$publicData['type'] = $type;
$publicData['project_id'] = $this->user['project_id'];
$publicData['template_id'] = $bSettingInfo['template_id'];
$publicData['template_id'] = $template_id;
$templateCommonModel->add($publicData);
}else{
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
}
}else{
//更新首页头部底部
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
}
return $this->success();
return true;
}
}
... ...
... ... @@ -42,51 +42,17 @@ class VisualizationLogic extends BaseLogic
* @time :2023/11/17 14:44
*/
public function getVisualizationInfo(){
$data = $this->getSource($this->param['type']);
$source = $data['source'];
$source_id = $data['source_id'];
$type = $this->getType($source,$source_id);
$typeArray = [BTemplate::TYPE_ONE,BTemplate::TYPE_THREE,BTemplate::TYPE_FIVE,BTemplate::TYPE_SEVEN];//单页数据
if(in_array($type,$typeArray)){
$bTemplateModel = new BTemplate();
$info = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);
if($info === false){
$html = '';
}else{
$html = $info['html'];
}
}else{//模块数据
$bTemplateMainModel = new BTemplateMain();
$info = $bTemplateMainModel->read(['type'=>$type]);
$info = $bTemplateMainModel->read(['type'=>$this->param['type']]);
if($info === false){
$html = '';
}else{
$html = $info['main_html'];
}
}
return $this->success(['html'=>$html]);
}
/**
* @remark :根据type获取source类型
* @name :getSource
* @author :lyh
* @method :post
* @time :2023/12/6 11:25
*/
public function getSource($type){
$source_id = 0;
if ($type == 2){$source = 2;$source_id = 1;
}elseif ($type == 3){$source = 2;
}elseif ($type == 4){$source = 3;$source_id = 1;
}elseif ($type == 5){$source = 3;
}elseif ($type == 6){$source = 4;$source_id = 1;
}elseif ($type == 7){$source = 4;
}else{$source = 1;}
return ['source'=>$source,'source_id'=>$source_id];
}
/**
* @remark :保存定制html
* @name :saveHtml
* @author :lyh
... ... @@ -95,24 +61,7 @@ class VisualizationLogic extends BaseLogic
*/
public function saveVisualization(){
try {
$sourceData = $this->getSource($this->param['type']);
$source = $sourceData['source'];
$source_id = $sourceData['source_id'];
$type = $this->param['type'];
$typeArray = [1,3,5,7];//单页数据
if(in_array($type,$typeArray)){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);
if($templateInfo === false){
$data = [
'html'=>$this->param['html'], 'project_id'=>$this->user['project_id'],
'source'=>$source, 'source_id'=>$source_id,
];
$bTemplateModel->add($data);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]);
}
}else{//模块数据
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
if($mainInfo === false){
... ... @@ -125,7 +74,6 @@ class VisualizationLogic extends BaseLogic
}else{
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
... ... @@ -158,6 +106,7 @@ class VisualizationLogic extends BaseLogic
* @time :2023/12/6 11:47
*/
public function getVisualizationHtml($type){
if(in_array($type,[1,3,5,7])){//单页
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块
if($templateInfo === false){
... ... @@ -270,15 +219,15 @@ class VisualizationLogic extends BaseLogic
* @time :2023/11/16 11:20
*/
public function getType($source,$source_id){
$type = 1;
if($source == 2){
if($source_id == 0){$type = 3;}else{$type = 2;}
$type = BTemplate::TYPE_ONE;
if($source == BTemplate::SOURCE_PRODUCT){
if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;}
}
if($source == 3){
if($source_id == 0){$type = 5;}else{$type = 4;}
if($source == BTemplate::SOURCE_BLOG){
if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
}
if($source == 4){
if($source_id == 0){$type = 7;}else{$type = 6;}
if($source == BTemplate::SOURCE_NEWS){
if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
}
return $type;
}
... ... @@ -323,7 +272,10 @@ class VisualizationLogic extends BaseLogic
if(in_array($type,$page_array)){//定制页面
$this->saveVisualizationHtml($type);
}else{
$this->saveTemplateHtml();
if(!isset($this->param['is_custom'])){
$this->param['is_custom'] = 0;
}
$this->saveTemplateHtml($this->param);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
... ... @@ -396,26 +348,29 @@ class VisualizationLogic extends BaseLogic
* @method :post
* @time :2023/12/5 15:44
*/
public function saveTemplateHtml(){
public function saveTemplateHtml($param){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'source'=>$param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
'template_id'=>$this->param['template_id'],
'source_id'=>$param['source_id'],
'template_id'=>$param['template_id'],
'is_custom'=>$param['is_custom']
]);
$this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$this->param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
//保存头部
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
if($param['is_custom'] == BTemplate::SOURCE_NO_CUSTOM){//非扩展模块才可以保存头底
$this->saveCommonTemplate($param['html'],$param['source'],$param['source_id'],$param['template_id']);
}
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
$param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($param);
}else{
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
$bTemplateModel->edit($param,['source'=>$param['source'],'source_id'=>$param['source_id'],'is_custom'=>$param['is_custom']]);
}
$this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
$this->setTemplateLog($param['template_id'],$param['html'],$param['source'],$param['source_id'],$param['is_custom']);
$this->homeOrProduct($param['source'],$param['source_id'],$param['is_custom']);
}
/**
... ... @@ -425,33 +380,24 @@ class VisualizationLogic extends BaseLogic
* @method :post
* @time :2023/7/31 16:05
*/
public function homeOrProduct($source,$source_id = ''){
public function homeOrProduct($source,$source_id = '',$is_custom = 0){
if($is_custom == 0){
if($source == BTemplate::SOURCE_HOME){
$type = 'index';
$route = '';
//路由映射
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
}else{
//其他界面通知更新
if($source == 2 && $source_id != 0){
$type = RouteMap::SOURCE_INDEX;
}elseif($source == BTemplate::SOURCE_PRODUCT){
$type = RouteMap::SOURCE_PRODUCT;
$productModel = new Product();
$productInfo = $productModel->read(['id'=>$source_id],['route']);
$route = $productInfo['route'];
}elseif($source == 3 && $source_id != 0){
}elseif($source == BTemplate::SOURCE_BLOG){
$type = RouteMap::SOURCE_BLOG;
$blogModel = new Blog();
$blogInfo = $blogModel->read(['id'=>$source_id],['url']);
$route = $blogInfo['url'];
}elseif($source == 4 && $source_id != 0){
}elseif($source == BTemplate::SOURCE_NEWS){
$type = RouteMap::SOURCE_NEWS;
$newsModel = new News();
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
$route = $newsInfo['url'];
}else{
$type = 'all';
$route = 'all';
}
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
}else{
$type = RouteMap::SOURCE_MODULE;
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
}
$this->addUpdateNotify($type,$route);
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
... ... @@ -464,7 +410,7 @@ class VisualizationLogic extends BaseLogic
* @method :post
* @time :2023/8/23 11:16
*/
public function setTemplateLog($template_id,$html,$source,$source_id){
public function setTemplateLog($template_id,$html,$source,$source_id,$is_custom){
$data = [
'template_id'=>$template_id,
'project_id'=>$this->user['project_id'],
... ... @@ -478,6 +424,7 @@ class VisualizationLogic extends BaseLogic
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'is_custom'=>$is_custom
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
... ...
... ... @@ -325,4 +325,16 @@ class CustomModuleContentLogic extends BaseLogic
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
}
/**
* @remark :排序
* @name :contentSort
* @author :lyh
* @method :post
* @time :2023/12/15 17:47
*/
public function contentSort(){
$this->model->edit(['sort' => $this->param['sort']], ['id'=>$this->param['id']]);
return $this->success();
}
}
... ...
... ... @@ -82,23 +82,23 @@ class NavLogic extends BaseLogic
*/
public function navSave()
{
$data = $this->handleParam($this->param);//处理保存字符串
if(!empty($this->param['location'])){
if($this->param['location'] == 'header'){
$this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID;
$data['group_id'] = BNavGroup::DEFAULT_HEADER_ID;
}
if($this->param['location'] == 'footer'){
$this->param['group_id'] = BNavGroup::DEFAULT_FOOTER_ID;
$data['group_id'] = BNavGroup::DEFAULT_FOOTER_ID;
}
}
unset($this->param['able_import']);
$this->param['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : '');
$this->param['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : '');
$data['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : '');
$data['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : '');
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->handleEditParam();//验证是否可编辑分类
$this->model->edit($this->param,['id'=>$this->param['id']]);
$this->model->edit($data,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
$data['project_id'] = $this->user['project_id'];
$this->model->add($data);
}
//编辑菜单后,通知更新
$this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all');
... ... @@ -106,6 +106,26 @@ class NavLogic extends BaseLogic
}
/**
* @remark :保存时处理数据
* @name :saveHandleParam
* @author :lyh
* @method :post
* @time :2023/12/15 14:26
*/
public function handleParam($param){
$data = [
'pid'=>$param['pid'] ?? 0,
'name'=>$param['name'] ?? '',
'location'=>$param['location'] ?? '',
'url'=>$param['url'],
'status'=>$param['status'] ?? 1,
'target'=>$param['target'] ?? 1,
'remark'=>$param['remark'] ?? '',
];
return $this->success($data);
}
/**
* @remark :验证是否可编辑
* @name :handleEditParam
* @author :lyh
... ... @@ -117,10 +137,6 @@ class NavLogic extends BaseLogic
if($this->param['pid'] == $info['id']){
$this->fail('不允许成为自己的上级');
}
// $pid_info = $this->model->read(['pid'=>$this->param['id']]);
// if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
// $this->fail('当前菜单拥有子集不允许修改上级');
// }
return $this->success();
}
... ...
... ... @@ -71,7 +71,7 @@ class KeywordLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败,请连续管理员');
$this->fail('保存失败');
}
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route);
$this->curlDelRoute(['new_route'=>$route]);
... ... @@ -137,12 +137,12 @@ class KeywordLogic extends BaseLogic
$param['title'] = $v;
$id = $this->model->insertGetId($param);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
// $this->curlDelRoute(['new_route'=>$route]);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
$this->fail('error');
}
return $this->success();
}
... ... @@ -181,8 +181,8 @@ class KeywordLogic extends BaseLogic
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
//生成一条删除路由记录
// $info = $this->model->read(['id'=>$id],['id','route']);
// $this->curlDelRoute(['route'=>$info['route']]);
$info = $this->model->read(['id'=>$id],['id','route']);
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
}
... ... @@ -197,7 +197,7 @@ class KeywordLogic extends BaseLogic
*/
public function importProductKeyword($project_id,$keyword){
$return = [];
$keyword_arr = explode('^v6sp$',$keyword);
$keyword_arr = explode(',',$keyword);
foreach ($keyword_arr as $v){
if($v){
$keyword_info = $this->model->read(['title'=>$v]);
... ...
... ... @@ -19,6 +19,6 @@ class CustomModuleContent extends Base
protected $connection = 'custom_mysql';
public function getCategoryIdAttribute($value){
return Arr::setToArr(trim($value,','));
return explode(',',trim($value,','));
}
}
... ...
... ... @@ -16,6 +16,7 @@ class Project extends Base
const DATABASE_NAME_FIX = 'gl_data_';
const CUSTOMIZED_ONE = 1;//定制项目
const DEMO_PROJECT_ID = 1;
const STATUS_ONE = 1;//审核通过
... ...
... ... @@ -54,7 +54,6 @@ class RouteMap extends Base
* @date 2023/4/17
*/
public static function generateRoute($title, $source, $source_id, $project_id){
// 所有的都需要翻译成为英文
$title = Translate::tran($title, 'en');
$i=1;
$sign = generateRoute($title);
... ...
... ... @@ -12,21 +12,29 @@ use App\Models\Base;
*/
class BTemplate extends Base
{
const SOURCE_CUSTOM = 1;//自定义模块
const SOURCE_HOME = 1;//首页
const SOURCE_PRODUCT = 2;//产品
const SOURCE_BLOG = 3;//博客
const SOURCE_NEWS = 4;//新闻详情页
const SOURCE_KEYWORD = 5;//聚合页
const ALL_HTML = 1;//无需拼接数据,获取整个html
const PAGE_HTML = 0;//默认保存方式为0,
const SOURCE_VISUALIZATION = 1;//定制项目
const SOURCE_NO_CUSTOM = 0;//默认模块
const STATUS = 0;
const TYPE_ONE = 1;
const TYPE_TWO = 2;
const TYPE_THREE = 3;
const TYPE_FOUR = 4;
const TYPE_FIVE = 5;
const TYPE_SIX = 6;
const TYPE_SEVEN = 7;
const TYPE_EIGHT = 8;
const TYPE_ONE = 1;//首页类型
const TYPE_TWO = 2;//产品详情
const TYPE_THREE = 3;//产品列表
const TYPE_FOUR = 4;//博客详情
const TYPE_FIVE = 5;//博客列表
const TYPE_SIX = 6;//新闻详情
const TYPE_SEVEN = 7;//新闻列表
const TYPE_EIGHT = 8;//自定义页面
protected $table = 'gl_web_template';
//连接数据库
... ... @@ -96,5 +104,12 @@ class BTemplate extends Base
],
]
];
public function typeMap()
{
return [
self::SOURCE_HOME => 'xxxx',
];
}
}
... ...
... ... @@ -301,6 +301,13 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/getTimeZone', [Aside\Optimize\InquiryInfoController::class, 'getTimeZone'])->name('admin.inquiry_getTimeZone');
Route::any('/getInternalCount', [Aside\Optimize\InquiryInfoController::class, 'getInternalCount'])->name('admin.inquiry_getInternalCount');
});
Route::prefix('custom_module')->group(function () {
Route::any('/', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
Route::any('/save', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
Route::any('/del', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
});
// 公共主题模版
Route::prefix('template')->group(function () {
Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists');
... ...
... ... @@ -13,6 +13,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/unbindWechat', [\App\Http\Controllers\Bside\BCom\ComController::class, 'unbindWechat'])->name('unbindWechat');
//获取当前登录用户菜单
Route::any('/get_menu', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_menu'])->name('get_menu');
//自定义菜单
Route::any('/getCustomMenu', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getCustomMenu'])->name('get_getCustomMenu');
//获取当前登录用户项目详情
Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project');
Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
... ... @@ -443,6 +445,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/getCategoryList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCategoryList'])->name('custom_content_getCategoryList');
Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save');
Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'sort'])->name('custom_content_sort');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
});
... ...