作者 赵彬吉
正在显示 34 个修改的文件 包含 1052 行增加81 行删除
@@ -79,7 +79,13 @@ class ProjectImport extends Command @@ -79,7 +79,13 @@ class ProjectImport extends Command
79 //读取csv文件 79 //读取csv文件
80 $line_of_text = []; 80 $line_of_text = [];
81 try { 81 try {
82 - $file_handle = fopen($task->file_url, 'r'); 82 + $opts = [
  83 + 'http' => [
  84 + 'method' => 'GET',
  85 + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
  86 + ]
  87 + ];
  88 + $file_handle = fopen($task->file_url, 'r', null, stream_context_create($opts));
83 while (!feof($file_handle)) { 89 while (!feof($file_handle)) {
84 $line_of_text[] = fgetcsv($file_handle, 0, ','); 90 $line_of_text[] = fgetcsv($file_handle, 0, ',');
85 } 91 }
@@ -183,7 +189,7 @@ class ProjectImport extends Command @@ -183,7 +189,7 @@ class ProjectImport extends Command
183 protected function get_code_type($file) 189 protected function get_code_type($file)
184 { 190 {
185 $list = array('GBK', 'UTF-8'); 191 $list = array('GBK', 'UTF-8');
186 - $str = file_get_contents($file); 192 + $str = curl_c($file, false);
187 foreach ($list as $item) { 193 foreach ($list as $item) {
188 $tmp = mb_convert_encoding($str, $item, $item); 194 $tmp = mb_convert_encoding($str, $item, $item);
189 if (md5($tmp) == md5($str)) { 195 if (md5($tmp) == md5($str)) {
@@ -41,7 +41,7 @@ class HtmlCollect extends Command @@ -41,7 +41,7 @@ class HtmlCollect extends Command
41 public function handle() 41 public function handle()
42 { 42 {
43 while (true) { 43 while (true) {
44 - $this->start_collect(); 44 + $this->start_collect();
45 } 45 }
46 } 46 }
47 47
@@ -268,6 +268,14 @@ class HtmlCollect extends Command @@ -268,6 +268,14 @@ class HtmlCollect extends Command
268 $check_vc_b && $source[] = $check_vc_b; 268 $check_vc_b && $source[] = $check_vc_b;
269 } 269 }
270 270
  271 + //a标签下载资源
  272 + preg_match_all('/<a\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_a);
  273 + $down = $result_a[2] ?? [];
  274 + foreach ($down as $vd) {
  275 + $check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url);
  276 + $check_vd && $source[] = $check_vd;
  277 + }
  278 +
271 return $source; 279 return $source;
272 } 280 }
273 281
@@ -286,7 +294,7 @@ class HtmlCollect extends Command @@ -286,7 +294,7 @@ class HtmlCollect extends Command
286 (empty($host) || $host == $web_url_domain || $host == $home_url) 294 (empty($host) || $host == $web_url_domain || $host == $home_url)
287 && $path 295 && $path
288 && (strpos($path, '.') !== false) 296 && (strpos($path, '.') !== false)
289 - && (end($path_arr) != 'html') 297 + && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml']))
290 ) { 298 ) {
291 $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); 299 $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
292 if (!$source) { 300 if (!$source) {
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleCategoryController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 15:54
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\CustomModule;
  11 +
  12 +use App\Http\Controllers\Bside\BaseController;
  13 +use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic;
  14 +use App\Models\CustomModule\CustomModuleCategory;
  15 +
  16 +class CustomModuleCategoryController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取自定义模块列表
  20 + * @name :ModuleList
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/12/4 15:43
  24 + */
  25 + public function lists(CustomModuleCategory $customModuleCategory){
  26 + $this->request->validate([
  27 + 'module_id'=>['required'],
  28 + ],[
  29 + 'module_id.required' => 'module_id不能为空',
  30 + ]);
  31 + $this->map['project_id'] = $this->user['project_id'];
  32 + $lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order);
  33 + $this->response('success',Code::SUCCESS,$lists);
  34 + }
  35 +
  36 + /**
  37 + * @remark :添加/编辑分类时获取分类列表
  38 + * @name :getCateList
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2023/12/5 17:11
  42 + */
  43 + public function getCateList(CustomModuleCategoryLogic $logic){
  44 + $list = $logic->getCateList();
  45 + $this->response('success',Code::SUCCESS,$list);
  46 + }
  47 +
  48 + /**
  49 + * @remark :获取当前数据详情
  50 + * @name :info
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/12/4 16:09
  54 + */
  55 + public function info(CustomModuleCategoryLogic $logic){
  56 + $this->request->validate([
  57 + 'id'=>['required'],
  58 + ],[
  59 + 'id.required' => '主键不能为空',
  60 + ]);
  61 + $info = $logic->categoryInfo();
  62 + $this->response('success',Code::SUCCESS,$info);
  63 + }
  64 +
  65 + /**
  66 + * @remark :保存数据
  67 + * @name :save
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2023/12/4 15:45
  71 + */
  72 + public function save(CustomModuleCategoryLogic $logic){
  73 + $this->request->validate([
  74 + 'name'=>['required'],
  75 + 'route'=>['required'],
  76 + 'module_id'=>['required']
  77 + ],[
  78 + 'name.required' => '分类名称不能为空',
  79 + 'route.required' => '分类路由不能为空',
  80 + 'module_id.required' => '所选模块id不能为空'
  81 + ]);
  82 + $logic->categorySave();
  83 + $this->response('success');
  84 + }
  85 +
  86 + /**
  87 + * @remark :删除数据
  88 + * @name :del
  89 + * @author :lyh
  90 + * @method :post
  91 + * @time :2023/12/4 16:14
  92 + */
  93 + public function del(CustomModuleCategoryLogic $logic){
  94 + $this->request->validate([
  95 + 'id'=>['required'],
  96 + ],[
  97 + 'id.required' => 'ID不能为空',
  98 + ]);
  99 + $logic->categoryDel();
  100 + $this->response('success');
  101 + }
  102 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleContentController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 15:55
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\CustomModule;
  11 +
  12 +use App\Http\Controllers\Bside\BaseController;
  13 +use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
  14 +use App\Models\CustomModule\CustomModuleContent;
  15 +
  16 +class CustomModuleContentController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取自定义模块列表
  20 + * @name :ModuleList
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/12/4 15:43
  24 + */
  25 + public function lists(CustomModuleContent $customModuleContent){
  26 + $this->request->validate([
  27 + 'module_id'=>['required'],
  28 + ],[
  29 + 'module_id.required' => 'module_id不能为空',
  30 + ]);
  31 + $this->map['project_id'] = $this->user['project_id'];
  32 + $lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order);
  33 + $this->response('success',Code::SUCCESS,$lists);
  34 + }
  35 +
  36 + /**
  37 + * @remark :获取当前数据详情
  38 + * @name :info
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2023/12/4 16:09
  42 + */
  43 + public function info(CustomModuleContentLogic $logic){
  44 + $this->request->validate([
  45 + 'id'=>['required'],
  46 + ],[
  47 + 'id.required' => 'ID不能为空',
  48 + ]);
  49 + $info = $logic->getCustomModuleContentInfo();
  50 + $this->response('success',Code::SUCCESS,$info);
  51 + }
  52 +
  53 + /**
  54 + * @remark :保存数据
  55 + * @name :save
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2023/12/4 15:45
  59 + */
  60 + public function save(CustomModuleContentLogic $logic){
  61 + $this->request->validate([
  62 + 'name'=>['required'],
  63 + 'route'=>['required'],
  64 + 'module_id'=>['required']
  65 + ],[
  66 + 'name.required' => '分类名称不能为空',
  67 + 'route.required' => '分类路由不能为空',
  68 + 'module_id.required' => '所选模块id不能为空'
  69 + ]);
  70 + $logic->customModuleContentSave();
  71 + $this->response('success');
  72 + }
  73 +
  74 + /**
  75 + * @remark :删除数据
  76 + * @name :del
  77 + * @author :lyh
  78 + * @method :post
  79 + * @time :2023/12/4 16:14
  80 + */
  81 + public function del(CustomModuleContentLogic $logic){
  82 + $this->request->validate([
  83 + 'id'=>['required'],
  84 + ],[
  85 + 'id.required' => 'ID不能为空',
  86 + ]);
  87 + $logic->customModuleContentDel();
  88 + $this->response('success');
  89 + }
  90 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 15:42
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\CustomModule;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\CustomModule\CustomModuleLogic;
  15 +use App\Models\CustomModule\CustomModule;
  16 +
  17 +/**
  18 + * @remark :自定义模块
  19 + * @name :CustomModuleController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2023/12/4 15:42
  23 + */
  24 +class CustomModuleController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :获取自定义模块列表
  28 + * @name :ModuleList
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/12/4 15:43
  32 + */
  33 + public function lists(CustomModule $customModule){
  34 + $this->map['project_id'] = $this->user['project_id'];
  35 + $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
  36 + $this->response('success',Code::SUCCESS,$lists);
  37 + }
  38 +
  39 + /**
  40 + * @remark :获取当前数据详情
  41 + * @name :info
  42 + * @author :lyh
  43 + * @method :post
  44 + * @time :2023/12/4 16:09
  45 + */
  46 + public function info(CustomModuleLogic $logic){
  47 + $this->request->validate([
  48 + 'id'=>['required'],
  49 + ],[
  50 + 'id.required' => 'ID不能为空',
  51 + ]);
  52 + $info = $logic->getCustomModuleInfo();
  53 + $this->response('success',Code::SUCCESS,$info);
  54 + }
  55 +
  56 + /**
  57 + * @remark :保存数据
  58 + * @name :save
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2023/12/4 15:45
  62 + */
  63 + public function save(CustomModuleLogic $logic){
  64 + $this->request->validate([
  65 + 'name'=>['required'],
  66 + ],[
  67 + 'name.required' => '模块名称不能为空',
  68 + ]);
  69 + $logic->customModuleSave();
  70 + $this->response('success');
  71 + }
  72 +
  73 + /**
  74 + * @remark :删除
  75 + * @name :del
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2023/12/5 9:53
  79 + */
  80 + public function del(CustomModuleLogic $logic){
  81 + $this->request->validate([
  82 + 'id'=>['required'],
  83 + ],[
  84 + 'id.required' => 'ID不能为空',
  85 + ]);
  86 + $logic->customModuleDel();
  87 + $this->response('success');
  88 + }
  89 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleExtentController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 15:58
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\CustomModule;
  11 +
  12 +use App\Http\Controllers\Bside\BaseController;
  13 +use App\Http\Logic\Bside\CustomModule\CustomModuleExtendLogic;
  14 +use App\Models\CustomModule\CustomModuleExtend;
  15 +
  16 +class CustomModuleExtentController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取自定义模块列表
  20 + * @name :ModuleList
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/12/4 15:43
  24 + */
  25 + public function list(CustomModuleExtend $customModuleExtend){
  26 + $this->map['project_id'] = $this->user['project_id'];
  27 + $lists = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order);
  28 + $this->response('success',Code::SUCCESS,$lists);
  29 + }
  30 +
  31 + /**
  32 + * @remark :获取当前数据详情
  33 + * @name :info
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2023/12/4 16:09
  37 + */
  38 + public function info(CustomModuleExtendLogic $logic){
  39 + $this->request->validate([
  40 + 'id'=>['required'],
  41 + ],[
  42 + 'id.required' => 'ID不能为空',
  43 + ]);
  44 + $info = $logic->getCustomModuleExtendInfo();
  45 + $this->response('success',Code::SUCCESS,$info);
  46 + }
  47 +
  48 + /**
  49 + * @remark :保存数据
  50 + * @name :save
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/12/4 15:45
  54 + */
  55 + public function save(CustomModuleExtendLogic $logic){
  56 + $logic->customModuleExtendSave();
  57 + $this->response('success');
  58 + }
  59 +
  60 + /**
  61 + * @remark :删除数据
  62 + * @name :del
  63 + * @author :lyh
  64 + * @method :post
  65 + * @time :2023/12/4 16:14
  66 + */
  67 + public function del(CustomModuleExtendLogic $logic){
  68 + $this->request->validate([
  69 + 'id'=>['required'],
  70 + ],[
  71 + 'id.required' => 'ID不能为空',
  72 + ]);
  73 + $logic->customModuleExtendDel();
  74 + $this->response('success');
  75 + }
  76 +}
@@ -21,11 +21,11 @@ class NavController extends BaseController @@ -21,11 +21,11 @@ class NavController extends BaseController
21 21
22 22
23 /** 23 /**
24 - * 列表数据  
25 - * @throws \Psr\Container\ContainerExceptionInterface  
26 - * @throws \Psr\Container\NotFoundExceptionInterface  
27 - * @author:dc  
28 - * @time 2023/5/8 16:37 24 + * @remark :获取列表数据
  25 + * @name :index
  26 + * @author :lyh
  27 + * @method :post
  28 + * @time :2023/12/4 15:00
29 */ 29 */
30 public function index(BNav $nav){ 30 public function index(BNav $nav){
31 $this->map['project_id'] = $this->user['project_id']; 31 $this->map['project_id'] = $this->user['project_id'];
@@ -42,6 +42,19 @@ class NavController extends BaseController @@ -42,6 +42,19 @@ class NavController extends BaseController
42 } 42 }
43 43
44 44
  45 +
  46 + /**
  47 + * @remark :获取当前id下的所有子集
  48 + * @name :getSubList
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/12/4 15:04
  52 + */
  53 + public function getSubList(NavLogic $logic){
  54 + $data = $logic->getSubList();
  55 + $this->response('success',Code::SUCCESS,$data);
  56 + }
  57 +
45 /** 58 /**
46 * @remark :保存数据 59 * @remark :保存数据
47 * @name :save 60 * @name :save
@@ -36,7 +36,6 @@ class NewsController extends BaseController @@ -36,7 +36,6 @@ class NewsController extends BaseController
36 $user = new User(); 36 $user = new User();
37 foreach ($lists['list'] as $k => $v){ 37 foreach ($lists['list'] as $k => $v){
38 $v['category_name'] = $this->categoryName($v['category_id'],$data); 38 $v['category_name'] = $this->categoryName($v['category_id'],$data);
39 - $v['seo_mate'] =  
40 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']); 39 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
41 $v['image_link'] = getImageUrl($v['image']); 40 $v['image_link'] = getImageUrl($v['image']);
42 $v['operator_name'] = $user->getName($v['operator_id']); 41 $v['operator_name'] = $user->getName($v['operator_id']);
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Template; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Template;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic; 7 use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic;
  8 +use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
8 use App\Models\Template\BModuleProject; 9 use App\Models\Template\BModuleProject;
9 10
10 /** 11 /**
@@ -22,15 +23,14 @@ class BTemplateModuleController extends BaseController @@ -22,15 +23,14 @@ class BTemplateModuleController extends BaseController
22 * @method :post 23 * @method :post
23 * @time :2023/6/29 11:33 24 * @time :2023/6/29 11:33
24 */ 25 */
25 - public function lists(BTemplateModuleLogic $BTemplateModuleLogic){ 26 + public function lists(BTemplateModuleLogic $bTemplateModuleLogic,BTemplateModuleProjectLogic $bTemplateModuleProjectLogic){
26 if(!isset($this->map['test_model'])){ 27 if(!isset($this->map['test_model'])){
27 $this->map['test_model'] = ['in',[0,1]]; 28 $this->map['test_model'] = ['in',[0,1]];
28 } 29 }
29 $data = []; 30 $data = [];
30 - $list = $BTemplateModuleLogic->ModuleList($this->map,$this->order); 31 + $list = $bTemplateModuleLogic->ModuleList($this->map,$this->order);
31 $data['list'] = $list; 32 $data['list'] = $list;
32 - $moduleProjectModel = new BModuleProject();  
33 - $module_list = $moduleProjectModel->list(['project_id'=>$this->user['project_id']]); 33 + $module_list = $bTemplateModuleProjectLogic->ModuleList(['project_id'=>$this->user['project_id']]);
34 $data['module_list'] = $module_list; 34 $data['module_list'] = $module_list;
35 $this->response('success',Code::SUCCESS,$data); 35 $this->response('success',Code::SUCCESS,$data);
36 } 36 }
@@ -195,6 +195,9 @@ class ImageController extends Controller @@ -195,6 +195,9 @@ class ImageController extends Controller
195 //保存路径 195 //保存路径
196 $url = $this->config['root'].$this->path; 196 $url = $this->config['root'].$this->path;
197 $image_type = $files->getClientOriginalExtension(); 197 $image_type = $files->getClientOriginalExtension();
  198 + if(strlen($image_type) > 7){
  199 + $this->response('不支持当前格式',Code::SYSTEM_ERROR);
  200 + }
198 $fileName = uniqid().rand(10000,99999).'.'.$image_type; 201 $fileName = uniqid().rand(10000,99999).'.'.$image_type;
199 //上传到cos 202 //上传到cos
200 if($this->upload_location == 1){ 203 if($this->upload_location == 1){
@@ -35,7 +35,7 @@ class OnlineCheckLogic extends BaseLogic @@ -35,7 +35,7 @@ class OnlineCheckLogic extends BaseLogic
35 $optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]); 35 $optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]);
36 //查看当前用户是否有权限审核 36 //查看当前用户是否有权限审核
37 if($this->param['type'] == 'optimist'){ 37 if($this->param['type'] == 'optimist'){
38 - if(($info['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){ 38 + if(($optimizeInfo['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){
39 $this->fail('你无权限提交审核'); 39 $this->fail('你无权限提交审核');
40 } 40 }
41 }else{ 41 }else{
@@ -43,7 +43,7 @@ class OnlineCheckLogic extends BaseLogic @@ -43,7 +43,7 @@ class OnlineCheckLogic extends BaseLogic
43 if($info['optimist_status'] != 1){ 43 if($info['optimist_status'] != 1){
44 $this->fail('请先优化师审核'); 44 $this->fail('请先优化师审核');
45 } 45 }
46 - if($info['qa_mid'] != 0 && $info['qa_mid'] != $this->manager['id']){ 46 + if(($info['qa_mid'] != 0) && ($info['qa_mid'] != $this->manager['id'])){
47 $this->fail('你无权限提交审核'); 47 $this->fail('你无权限提交审核');
48 } 48 }
49 if(isset($this->param['project_type']) && !empty($this->param['project_type'])){ 49 if(isset($this->param['project_type']) && !empty($this->param['project_type'])){
@@ -72,9 +72,9 @@ class OnlineCheckLogic extends BaseLogic @@ -72,9 +72,9 @@ class OnlineCheckLogic extends BaseLogic
72 if($info !== false){ 72 if($info !== false){
73 $this->fail('已提交,请勿重复提交'); 73 $this->fail('已提交,请勿重复提交');
74 }else{ 74 }else{
75 - $projectModel = new Project();  
76 - //提交审核修改状态为审核中  
77 - $projectModel->edit(['status'=>1],['id'=>$this->param['id']]); 75 + if(($this->param['optimist_mid'] == 0) || ($this->param['qa_mid'] == 0)){
  76 + $this->fail('请先选择优化师和品控,在提交审核');
  77 + }
78 //组装数据 78 //组装数据
79 $data = [ 79 $data = [
80 'project_id' => $this->param['id'], 80 'project_id' => $this->param['id'],
@@ -88,6 +88,9 @@ class OnlineCheckLogic extends BaseLogic @@ -88,6 +88,9 @@ class OnlineCheckLogic extends BaseLogic
88 $this->fail('error'); 88 $this->fail('error');
89 } 89 }
90 } 90 }
  91 + $projectModel = new Project();
  92 + //提交审核修改状态为审核中
  93 + $projectModel->edit(['status'=>1],['id'=>$this->param['id']]);
91 return $this->success(); 94 return $this->success();
92 } 95 }
93 } 96 }
@@ -379,7 +379,7 @@ class BTemplateLogic extends BaseLogic @@ -379,7 +379,7 @@ class BTemplateLogic extends BaseLogic
379 } 379 }
380 } 380 }
381 $this->addUpdateNotify($type,$route); 381 $this->addUpdateNotify($type,$route);
382 - return $this->curlDelRoute($route); 382 + return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
383 } 383 }
384 384
385 /** 385 /**
@@ -22,6 +22,19 @@ class BTemplateModuleProjectLogic extends BaseLogic @@ -22,6 +22,19 @@ class BTemplateModuleProjectLogic extends BaseLogic
22 } 22 }
23 23
24 /** 24 /**
  25 + * @remark :获取左侧模块列表
  26 + * @name :ModuleList
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/6/29 13:35
  30 + */
  31 + public function ModuleList($map,$order = 'created_at',$filed = ['id','name','sort','status','image','html']){
  32 + $map['status'] = 0;
  33 + $lists = $this->model->list($map,$order,$filed);
  34 + return $this->success($lists);
  35 + }
  36 +
  37 + /**
25 * @remark :保存私有化左侧模块 38 * @remark :保存私有化左侧模块
26 * @name :moduleProjectSave 39 * @name :moduleProjectSave
27 * @author :lyh 40 * @author :lyh
@@ -113,7 +113,7 @@ class CustomTemplateLogic extends BaseLogic @@ -113,7 +113,7 @@ class CustomTemplateLogic extends BaseLogic
113 } 113 }
114 //通知 114 //通知
115 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']); 115 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
116 - $this->curlDelRoute($info['url']); 116 + $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]);
117 return $this->success(); 117 return $this->success();
118 } 118 }
119 119
@@ -213,7 +213,7 @@ class CustomTemplateLogic extends BaseLogic @@ -213,7 +213,7 @@ class CustomTemplateLogic extends BaseLogic
213 } 213 }
214 if($info['url'] != $route){ 214 if($info['url'] != $route){
215 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route); 215 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
216 - $this->curlDelRoute($info['url']); 216 + $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
217 } 217 }
218 return true; 218 return true;
219 } 219 }
@@ -259,7 +259,7 @@ class CustomTemplateLogic extends BaseLogic @@ -259,7 +259,7 @@ class CustomTemplateLogic extends BaseLogic
259 RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); 259 RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
260 //生成一条删除路由记录 260 //生成一条删除路由记录
261 $info = $this->model->read(['id' => $id], ['id', 'url']); 261 $info = $this->model->read(['id' => $id], ['id', 'url']);
262 - $this->curlDelRoute($info['url']); 262 + $this->curlDelRoute(['route'=>$info['url']]);
263 return $this->success(); 263 return $this->success();
264 } 264 }
265 265
@@ -284,46 +284,71 @@ class VisualizationLogic extends BaseLogic @@ -284,46 +284,71 @@ class VisualizationLogic extends BaseLogic
284 $type = $this->getType($this->param['source'],$this->param['source_id']); 284 $type = $this->getType($this->param['source'],$this->param['source_id']);
285 try { 285 try {
286 if(in_array($type,$page_array)){//定制页面 286 if(in_array($type,$page_array)){//定制页面
287 - $bTemplateModel = new BTemplate();  
288 - $templateInfo = $bTemplateModel->read([  
289 - 'source'=>$this->param['source'],  
290 - 'project_id'=>$this->user['project_id'],  
291 - 'source_id'=>$this->param['source_id'],  
292 - 'template_id'=>0  
293 - ]);  
294 - if($templateInfo === false){  
295 - $this->param['project_id'] = $this->user['project_id'];  
296 - $this->param['template_id'] = 0;  
297 - $bTemplateModel->add($this->param);  
298 - }else{  
299 - $bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);  
300 - } 287 + $this->saveVisualizationHtml();
301 }else{ 288 }else{
302 - $bTemplateModel = new BTemplate();  
303 - $templateInfo = $bTemplateModel->read([  
304 - 'source'=>$this->param['source'],  
305 - 'project_id'=>$this->user['project_id'],  
306 - 'source_id'=>$this->param['source_id'],  
307 - 'template_id'=>$this->param['template_id'],  
308 - ]);  
309 - $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');  
310 - $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');  
311 - //保存头部  
312 - $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);  
313 - if($templateInfo === false){  
314 - $this->param['project_id'] = $this->user['project_id'];  
315 - $bTemplateModel->add($this->param);  
316 - }else{  
317 - $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);  
318 - }  
319 - $this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);  
320 - $this->homeOrProduct($this->param['source'],$this->param['source_id']); 289 + $this->saveTemplateHtml();
321 } 290 }
322 }catch (\Exception $e){ 291 }catch (\Exception $e){
323 $this->fail('系统错误,请联系管理员'); 292 $this->fail('系统错误,请联系管理员');
324 } 293 }
325 return $this->success(); 294 return $this->success();
  295 + }
326 296
  297 + /**
  298 + * @remark :保存定制界面
  299 + * @name :saveVisualizationHtml
  300 + * @author :lyh
  301 + * @method :post
  302 + * @time :2023/12/5 15:42
  303 + */
  304 + public function saveVisualizationHtml(){
  305 + $bTemplateModel = new BTemplate();
  306 + $templateInfo = $bTemplateModel->read([
  307 + 'source'=>$this->param['source'], 'project_id'=>$this->user['project_id'],
  308 + 'source_id'=>$this->param['source_id'], 'template_id'=>0
  309 + ]);
  310 + if($templateInfo === false){
  311 + $this->param['project_id'] = $this->user['project_id'];
  312 + $this->param['template_id'] = 0;
  313 +// $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  314 +// $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  315 + $bTemplateModel->add($this->param);
  316 + }else{
  317 +// $param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  318 +// $param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  319 + $param['html'] = $this->param['html'];
  320 + $bTemplateModel->edit($param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
  321 + }
  322 + return $this->success();
  323 + }
  324 +
  325 + /**
  326 + * @remark :非定制界面保存数据
  327 + * @name :saveTemplateHtml
  328 + * @author :lyh
  329 + * @method :post
  330 + * @time :2023/12/5 15:44
  331 + */
  332 + public function saveTemplateHtml(){
  333 + $bTemplateModel = new BTemplate();
  334 + $templateInfo = $bTemplateModel->read([
  335 + 'source'=>$this->param['source'],
  336 + 'project_id'=>$this->user['project_id'],
  337 + 'source_id'=>$this->param['source_id'],
  338 + 'template_id'=>$this->param['template_id'],
  339 + ]);
  340 + $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  341 + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  342 + //保存头部
  343 + $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
  344 + if($templateInfo === false){
  345 + $this->param['project_id'] = $this->user['project_id'];
  346 + $bTemplateModel->add($this->param);
  347 + }else{
  348 + $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
  349 + }
  350 + $this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
  351 + $this->homeOrProduct($this->param['source'],$this->param['source_id']);
327 } 352 }
328 353
329 /** 354 /**
@@ -357,12 +382,12 @@ class VisualizationLogic extends BaseLogic @@ -357,12 +382,12 @@ class VisualizationLogic extends BaseLogic
357 $newsInfo = $newsModel->read(['id'=>$source_id],['url']); 382 $newsInfo = $newsModel->read(['id'=>$source_id],['url']);
358 $route = $newsInfo['url']; 383 $route = $newsInfo['url'];
359 }else{ 384 }else{
360 - $type = 0; 385 + $type = 'all';
361 $route = 'all'; 386 $route = 'all';
362 } 387 }
363 } 388 }
364 $this->addUpdateNotify($type,$route); 389 $this->addUpdateNotify($type,$route);
365 - return $this->curlDelRoute($route); 390 + return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
366 } 391 }
367 392
368 /** 393 /**
@@ -169,8 +169,10 @@ class BaseLogic extends Logic @@ -169,8 +169,10 @@ class BaseLogic extends Logic
169 * @method :post 169 * @method :post
170 * @time :2023/11/30 14:43 170 * @time :2023/11/30 14:43
171 */ 171 */
172 - public function curlDelRoute($route){  
173 - $url = $this->user['domain'].'api/delHtml/?project_id='.$this->user['project_id'].'&route='.$route; 172 + public function curlDelRoute($data){
  173 + $data['project_id'] = $this->user['project_id'];
  174 + $str = http_build_query($data);
  175 + $url = $this->user['domain'].'api/delHtml/?'.$str;
174 curlGet($url); 176 curlGet($url);
175 return $this->success(); 177 return $this->success();
176 } 178 }
@@ -113,7 +113,7 @@ class BlogCategoryLogic extends BaseLogic @@ -113,7 +113,7 @@ class BlogCategoryLogic extends BaseLogic
113 $info = $this->model->read(['id'=>$id],['id','alias']); 113 $info = $this->model->read(['id'=>$id],['id','alias']);
114 if($info['alias'] != $route){ 114 if($info['alias'] != $route){
115 $this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route); 115 $this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route);
116 - $this->curlDelRoute($info['alias']); 116 + $this->curlDelRoute(['route'=>$info['alias'],'new_route'=>$route]);
117 } 117 }
118 return true; 118 return true;
119 } 119 }
@@ -306,7 +306,7 @@ class BlogCategoryLogic extends BaseLogic @@ -306,7 +306,7 @@ class BlogCategoryLogic extends BaseLogic
306 RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); 306 RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
307 //生成一条删除路由记录 307 //生成一条删除路由记录
308 $info = $this->model->read(['id'=>$id],['id','alias']); 308 $info = $this->model->read(['id'=>$id],['id','alias']);
309 - $this->curlDelRoute($info['alias']); 309 + $this->curlDelRoute(['route'=>$info['alias']]);
310 return $this->success(); 310 return $this->success();
311 } 311 }
312 312
@@ -63,7 +63,7 @@ class BlogLogic extends BaseLogic @@ -63,7 +63,7 @@ class BlogLogic extends BaseLogic
63 $info = $this->model->read(['id'=>$id],['id','url']); 63 $info = $this->model->read(['id'=>$id],['id','url']);
64 if($info['url'] != $route){ 64 if($info['url'] != $route){
65 $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route); 65 $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
66 - $this->curlDelRoute($info['url']); 66 + $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
67 } 67 }
68 return true; 68 return true;
69 } 69 }
@@ -155,7 +155,7 @@ class BlogLogic extends BaseLogic @@ -155,7 +155,7 @@ class BlogLogic extends BaseLogic
155 RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); 155 RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
156 //生成一条删除路由记录 156 //生成一条删除路由记录
157 $info = $this->model->read(['id'=>$id],['id','url']); 157 $info = $this->model->read(['id'=>$id],['id','url']);
158 - $this->curlDelRoute($info['url']); 158 + $this->curlDelRoute(['route'=>$info['url']]);
159 return $this->success(); 159 return $this->success();
160 } 160 }
161 161
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleCategoryLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 16:07
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\CustomModule;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\CustomModule\CustomModuleCategory;
  14 +use App\Models\RouteMap\RouteMap;
  15 +
  16 +class CustomModuleCategoryLogic extends BaseLogic
  17 +{
  18 + public function __construct()
  19 + {
  20 + parent::__construct();
  21 + $this->param = $this->requestAll;
  22 + $this->model = new CustomModuleCategory();
  23 + }
  24 +
  25 + /**
  26 + * @remark :添加/编辑获取分类列表
  27 + * @name :getCateList
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2023/12/5 17:12
  31 + */
  32 + public function getCateList(){
  33 + $this->param['status'] = 0;
  34 + if(isset($this->param['id']) && !empty($this->param['id'])){
  35 + $str = [];
  36 + //排序掉当前id下所有子集
  37 + $str = $this->getAllSub($this->param['id'],$str);
  38 + $str[] = (int)$this->param['id'];
  39 + $this->param['id'] = ['not in',$str];
  40 + }
  41 + $menu = array();
  42 + $list = $this->model->list($this->param);
  43 + if(!empty($list)){
  44 + foreach ($list as $k => $v){
  45 + if($v['pid'] == 0){
  46 + $v['sub'] = _get_child($v['id'],$list);
  47 + $menu[] = $v;
  48 + }
  49 + }
  50 + }
  51 + return $this->success($menu);
  52 + }
  53 +
  54 + /**
  55 + * @remark :获取当前id下所有子集
  56 + * @name :getAllSub
  57 + * @author :lyh
  58 + * @method :post
  59 + * @time :2023/10/18 15:10
  60 + */
  61 + public function getAllSub($id,&$str = []){
  62 + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
  63 + if(!empty($list)){
  64 + foreach ($list as $v){
  65 + $str[] = $v['id'];
  66 + $this->getAllSub($v['id'],$str);
  67 + }
  68 + }
  69 + return $str;
  70 + }
  71 +
  72 + /**
  73 + * @remark :获取当前数据详情
  74 + * @name :getCustomModuleInfo
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2023/12/4 16:10
  78 + */
  79 + public function categoryInfo(){
  80 + $info = $this->model->read($this->param);
  81 + if($info === false){
  82 + $this->fail('当前数据不存在或已被删除');
  83 + }
  84 + return $this->success($info);
  85 + }
  86 +
  87 + /**
  88 + * @remark :保存数据
  89 + * @name :ModuleSave
  90 + * @author :lyh
  91 + * @method :post
  92 + * @time :2023/12/4 15:47
  93 + */
  94 + public function categorySave(){
  95 + if(isset($this->param['id']) && !empty($this->param['id'])){
  96 + $this->categoryEdit();
  97 + }else{
  98 + $this->categoryAdd();
  99 + }
  100 + return $this->success();
  101 + }
  102 +
  103 + /**
  104 + * @remark :添加分类
  105 + * @name :categoryAdd
  106 + * @author :lyh
  107 + * @method :post
  108 + * @time :2023/12/5 10:55
  109 + */
  110 + public function categoryAdd(){
  111 + try {
  112 + $id = $this->model->addReturnId($this->param);
  113 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']);
  114 + $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
  115 + $this->edit(['url' => $route], ['id' => $id]);
  116 + }catch (\Exception $e){
  117 + $this->fail('系统错误,请联系管理员');
  118 + }
  119 + return $this->success();
  120 + }
  121 +
  122 + /**
  123 + * @remark :编辑分类
  124 + * @name :categoryEdit
  125 + * @author :lyh
  126 + * @method :post
  127 + * @time :2023/12/5 10:55
  128 + */
  129 + public function categoryEdit(){
  130 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']);
  131 + $this->editNewsRoute($this->param['id'],$route);
  132 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  133 + if($rs === false){
  134 + $this->fail('系统错误,请连续管理员');
  135 + }
  136 + return $this->success();
  137 + }
  138 +
  139 + /**
  140 + * @remark :查看是否编辑路由
  141 + * @name :editCategoryRoute
  142 + * @author :lyh
  143 + * @method :post
  144 + * @time :2023/9/7 11:05
  145 + */
  146 + public function editNewsRoute($id, $route)
  147 + {
  148 + //生成一条删除路由记录
  149 + $info = $this->model->read(['id' => $id], ['id', 'route']);
  150 + if ($info['route'] != $route) {
  151 + $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
  152 + $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
  153 + }
  154 + return true;
  155 + }
  156 +
  157 + /**
  158 + * @name :(添加分类时处理子集分类)addProcessingSon
  159 + * @author :lyh
  160 + * @method :post
  161 + * @time :2023/6/13 11:34
  162 + */
  163 + public function addProcessingSon($cate_id){
  164 + if(isset($this->param['pid']) && !empty($this->param['pid'])) {
  165 + $this->param['pid'] = 0;
  166 + }
  167 + //判断为子分类时
  168 + if($this->param['pid'] != 0) {
  169 + //查看当前上级分类下是否有其他分类
  170 + $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
  171 + if ($cate_info === false) {
  172 + //查看当前上一级分类下是否有关联模块内容
  173 + $newsModel = new NewsModel();
  174 + $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
  175 + if ($news_count > 0) {
  176 + $replacement = ',' . $cate_id . ',';
  177 + $old = ',' . $this->param['pid'] . ',';
  178 + //更新所有商品到当前分类
  179 + $newsModel->where('category_id', 'like', '%' . $old . '%')
  180 + ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
  181 + }
  182 + }
  183 + }
  184 + return $this->success();
  185 + }
  186 +
  187 + /**
  188 + * @remark :删除数据
  189 + * @name :ModuleDel
  190 + * @author :lyh
  191 + * @method :post
  192 + * @time :2023/12/4 15:47
  193 + */
  194 + public function categoryDel(){
  195 + $info = $this->model->read(['pid' => $this->param['id']], ['id', 'route']);
  196 + if($info === false){
  197 + $this->fail('当前分类拥有下级');
  198 + }
  199 + $rs = $this->model->del($this->param);
  200 + if($rs === false){
  201 + $this->fail('系统错误,请连续管理员');
  202 + }
  203 + return $this->success();
  204 + }
  205 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleContentLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 16:06
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\CustomModule;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\CustomModule\CustomModuleContent;
  14 +
  15 +class CustomModuleContentLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->param = $this->requestAll;
  21 + $this->model = new CustomModuleContent();
  22 + }
  23 +
  24 + /**
  25 + * @remark :获取当前数据详情
  26 + * @name :getCustomModuleInfo
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/12/4 16:10
  30 + */
  31 + public function getCustomModuleContentInfo(){
  32 + $info = $this->model->read($this->param);
  33 + if($info === false){
  34 + $this->fail('当前数据不存在或已被删除');
  35 + }
  36 + return $this->success($info);
  37 + }
  38 +
  39 + /**
  40 + * @remark :保存数据
  41 + * @name :ModuleSave
  42 + * @author :lyh
  43 + * @method :post
  44 + * @time :2023/12/4 15:47
  45 + */
  46 + public function customModuleContentSave(){
  47 +
  48 + }
  49 +
  50 + /**
  51 + * @remark :删除数据
  52 + * @name :ModuleDel
  53 + * @author :lyh
  54 + * @method :post
  55 + * @time :2023/12/4 15:47
  56 + */
  57 + public function customModuleContentDel(){
  58 +
  59 + }
  60 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleExtendLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 16:07
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\CustomModule;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\CustomModule\CustomModuleExtend;
  14 +
  15 +class CustomModuleExtendLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->param = $this->requestAll;
  21 + $this->model = new CustomModuleExtend();
  22 + }
  23 +
  24 + /**
  25 + * @remark :获取当前数据详情
  26 + * @name :getCustomModuleInfo
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/12/4 16:10
  30 + */
  31 + public function getCustomModuleExtendInfo(){
  32 +
  33 + }
  34 +
  35 + /**
  36 + * @remark :保存数据
  37 + * @name :ModuleSave
  38 + * @author :lyh
  39 + * @method :post
  40 + * @time :2023/12/4 15:47
  41 + */
  42 + public function customModuleExtendSave(){
  43 +
  44 + }
  45 +
  46 + /**
  47 + * @remark :删除数据
  48 + * @name :ModuleDel
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/12/4 15:47
  52 + */
  53 + public function customModuleExtendDel(){
  54 +
  55 + }
  56 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/4 15:46
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\CustomModule;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\CustomModule\CustomModule;
  14 +use App\Models\CustomModule\CustomModuleCategory;
  15 +use App\Models\CustomModule\CustomModuleContent;
  16 +
  17 +class CustomModuleLogic extends BaseLogic
  18 +{
  19 + public function __construct()
  20 + {
  21 + parent::__construct();
  22 + $this->param = $this->requestAll;
  23 + $this->model = new CustomModule();
  24 + }
  25 +
  26 + /**
  27 + * @remark :获取当前数据详情
  28 + * @name :getCustomModuleInfo
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/12/4 16:10
  32 + */
  33 + public function getCustomModuleInfo(){
  34 + $info = $this->model->read($this->param);
  35 + if($info === false){
  36 + $this->fail('当前数据不存在或已被删除');
  37 + }
  38 + return $this->success($info);
  39 + }
  40 +
  41 + /**
  42 + * @remark :保存数据
  43 + * @name :ModuleSave
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2023/12/4 15:47
  47 + */
  48 + public function customModuleSave(){
  49 + if(isset($this->param['id']) && !empty($this->param['id'])){
  50 + $this->moduleEdit();
  51 + }else{
  52 + $this->moduleAdd();
  53 + }
  54 + return $this->success();
  55 + }
  56 +
  57 + /**
  58 + * @remark :新增
  59 + * @name :moduleAdd
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/12/5 9:39
  63 + */
  64 + public function moduleAdd(){
  65 + $rs = $this->model->add($this->param);
  66 + if($rs === false){
  67 + $this->fail('系统错误,请联系管理员');
  68 + }
  69 + return $this->success();
  70 + }
  71 +
  72 + /**
  73 + * @remark :编辑
  74 + * @name :moduleEdit
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2023/12/5 9:39
  78 + */
  79 + public function moduleEdit(){
  80 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  81 + if($rs === false){
  82 + $this->fail('系统错误,请联系管理员');
  83 + }
  84 + return $this->success();
  85 + }
  86 +
  87 + /**
  88 + * @remark :删除数据
  89 + * @name :ModuleDel
  90 + * @author :lyh
  91 + * @method :post
  92 + * @time :2023/12/4 15:47
  93 + */
  94 + public function customModuleDel(){
  95 + //查看当前模块是否拥有数据
  96 + $contentModel = new CustomModuleContent();
  97 + $contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
  98 + if($contentInfo !== false){
  99 + $this->fail('当前模块拥有内容不允许删除');
  100 + }
  101 + $categoryModel = new CustomModuleCategory();
  102 + $categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
  103 + if($categoryInfo !== false){
  104 + $this->fail('当前模块拥有分类不允许删除');
  105 + }
  106 + $rs = $this->model->del($this->param);
  107 + if($rs === false){
  108 + $this->fail('系统错误,请联系管理员');
  109 + }
  110 + return $this->success();
  111 + }
  112 +}
@@ -26,6 +26,52 @@ class NavLogic extends BaseLogic @@ -26,6 +26,52 @@ class NavLogic extends BaseLogic
26 $this->model = new BNav(); 26 $this->model = new BNav();
27 } 27 }
28 28
  29 + /**
  30 + * @remark :获取当前id下所有子集
  31 + * @name :getSubList
  32 + * @author :lyh
  33 + * @method :post
  34 + * @time :2023/12/4 15:11
  35 + */
  36 + public function getSubList(){
  37 + //编辑时
  38 + if(isset($this->param['id']) && !empty($this->param['id'])) {
  39 + $str = [];
  40 + //排序掉当前id下所有子集
  41 + $str = $this->getAllSub($this->param['id'], $str);
  42 + $str[] = $this->param['id'];
  43 + $this->param['id'] = ['not in', $str];
  44 + }
  45 + $this->param['project_id'] = $this->user['project_id'];
  46 + $list = $this->model->list($this->param);
  47 + $data = array();
  48 + foreach ($list as $v){
  49 + $v = (array)$v;
  50 + if ($v['pid'] == 0) {
  51 + $v['sub'] = _get_child($v['id'], $list);
  52 + $data[] = $v;
  53 + }
  54 + }
  55 + return $this->success($data);
  56 + }
  57 +
  58 + /**
  59 + * @remark :获取当前id下所有子集
  60 + * @name :getAllSub
  61 + * @author :lyh
  62 + * @method :post
  63 + * @time :2023/10/18 15:10
  64 + */
  65 + public function getAllSub($id,&$str = []){
  66 + $list = $this->model->list(['pid'=>$id,'status'=>1],['id','pid']);
  67 + if(!empty($list)){
  68 + foreach ($list as $v){
  69 + $str[] = $v['id'];
  70 + $this->getAllSub($v['id'],$str);
  71 + }
  72 + }
  73 + return $str;
  74 + }
29 75
30 /** 76 /**
31 * @remark :保存数据 77 * @remark :保存数据
@@ -71,10 +117,10 @@ class NavLogic extends BaseLogic @@ -71,10 +117,10 @@ class NavLogic extends BaseLogic
71 if($this->param['pid'] == $info['id']){ 117 if($this->param['pid'] == $info['id']){
72 $this->fail('不允许成为自己的上级'); 118 $this->fail('不允许成为自己的上级');
73 } 119 }
74 - $pid_info = $this->model->read(['pid'=>$this->param['id']]);  
75 - if(($pid_info !== false) && $this->param['pid'] != $info['pid']){  
76 - $this->fail('当前菜单拥有子集不允许修改上级');  
77 - } 120 +// $pid_info = $this->model->read(['pid'=>$this->param['id']]);
  121 +// if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
  122 +// $this->fail('当前菜单拥有子集不允许修改上级');
  123 +// }
78 return $this->success(); 124 return $this->success();
79 } 125 }
80 126
@@ -123,7 +123,7 @@ class NewsCategoryLogic extends BaseLogic @@ -123,7 +123,7 @@ class NewsCategoryLogic extends BaseLogic
123 $info = $this->model->read(['id'=>$id],['id','alias']); 123 $info = $this->model->read(['id'=>$id],['id','alias']);
124 if($info['alias'] != $route){ 124 if($info['alias'] != $route){
125 $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route); 125 $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
126 - $this->curlDelRoute($info['alias']); 126 + $this->curlDelRoute(['route'=>$info['alias'],'new_route'=>$route]);
127 } 127 }
128 return true; 128 return true;
129 } 129 }
@@ -287,7 +287,7 @@ class NewsCategoryLogic extends BaseLogic @@ -287,7 +287,7 @@ class NewsCategoryLogic extends BaseLogic
287 //删除路由映射 287 //删除路由映射
288 RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 288 RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
289 $info = $this->model->read(['id'=>$id],['id','alias']); 289 $info = $this->model->read(['id'=>$id],['id','alias']);
290 - $this->curlDelRoute($info['alias']); 290 + $this->curlDelRoute(['route'=>$info['alias']]);
291 return $this->success(); 291 return $this->success();
292 } 292 }
293 293
@@ -95,7 +95,7 @@ class NewsLogic extends BaseLogic @@ -95,7 +95,7 @@ class NewsLogic extends BaseLogic
95 $info = $this->model->read(['id' => $id], ['id', 'url']); 95 $info = $this->model->read(['id' => $id], ['id', 'url']);
96 if ($info['url'] != $route) { 96 if ($info['url'] != $route) {
97 $this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route); 97 $this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
98 - $this->curlDelRoute($info['url']); 98 + $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
99 } 99 }
100 return true; 100 return true;
101 } 101 }
@@ -267,7 +267,7 @@ class NewsLogic extends BaseLogic @@ -267,7 +267,7 @@ class NewsLogic extends BaseLogic
267 RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); 267 RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
268 //生成一条删除路由记录 268 //生成一条删除路由记录
269 $info = $this->model->read(['id' => $id], ['id', 'url']); 269 $info = $this->model->read(['id' => $id], ['id', 'url']);
270 - $this->curlDelRoute($info['url']); 270 + $this->curlDelRoute(['route'=>$info['url']]);
271 return $this->success(); 271 return $this->success();
272 } 272 }
273 273
@@ -233,7 +233,7 @@ class CategoryLogic extends BaseLogic @@ -233,7 +233,7 @@ class CategoryLogic extends BaseLogic
233 $info = $this->model->read(['id'=>$id],['id','route']); 233 $info = $this->model->read(['id'=>$id],['id','route']);
234 if($info['route'] != $route){ 234 if($info['route'] != $route){
235 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route); 235 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route);
236 - $this->curlDelRoute($info['route']); 236 + $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
237 } 237 }
238 return true; 238 return true;
239 } 239 }
@@ -278,7 +278,7 @@ class CategoryLogic extends BaseLogic @@ -278,7 +278,7 @@ class CategoryLogic extends BaseLogic
278 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); 278 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
279 //生成一条删除路由记录 279 //生成一条删除路由记录
280 $info = $this->model->read(['id'=>$id],['id','route']); 280 $info = $this->model->read(['id'=>$id],['id','route']);
281 - $this->curlDelRoute($info['route']); 281 + $this->curlDelRoute(['route'=>$info['route']]);
282 return $this->success(); 282 return $this->success();
283 } 283 }
284 284
@@ -185,7 +185,7 @@ class KeywordLogic extends BaseLogic @@ -185,7 +185,7 @@ class KeywordLogic extends BaseLogic
185 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); 185 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
186 //生成一条删除路由记录 186 //生成一条删除路由记录
187 $info = $this->model->read(['id'=>$id],['id','route']); 187 $info = $this->model->read(['id'=>$id],['id','route']);
188 - $this->curlDelRoute($info['route']); 188 + $this->curlDelRoute(['route'=>$info['route']]);
189 return $this->success(); 189 return $this->success();
190 } 190 }
191 191
@@ -294,7 +294,7 @@ class ProductLogic extends BaseLogic @@ -294,7 +294,7 @@ class ProductLogic extends BaseLogic
294 $info = $this->model->read(['id'=>$id]); 294 $info = $this->model->read(['id'=>$id]);
295 if($info['route'] != $route){ 295 if($info['route'] != $route){
296 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route); 296 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
297 - $this->curlDelRoute($info['route']); 297 + $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
298 } 298 }
299 return $route; 299 return $route;
300 } 300 }
@@ -341,7 +341,7 @@ class ProductLogic extends BaseLogic @@ -341,7 +341,7 @@ class ProductLogic extends BaseLogic
341 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 341 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
342 //生成一条删除路由记录 342 //生成一条删除路由记录
343 $info = $this->model->read(['id'=>$id],['id','route']); 343 $info = $this->model->read(['id'=>$id],['id','route']);
344 - $this->curlDelRoute($info['route']); 344 + $this->curlDelRoute(['route'=>$info['route']]);
345 return $this->success(); 345 return $this->success();
346 } 346 }
347 347
@@ -648,6 +648,32 @@ class ProductLogic extends BaseLogic @@ -648,6 +648,32 @@ class ProductLogic extends BaseLogic
648 'description' => $data[10]??'' 648 'description' => $data[10]??''
649 ]; 649 ];
650 650
  651 + //处理描述切换栏
  652 + $describe = [];
  653 + if($data[11]){
  654 + //处理描述切换栏中的图片
  655 + $describe = json_decode($data[11],true);
  656 +
  657 + foreach ($describe as &$v_desc){
  658 +
  659 + preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc);
  660 +
  661 + if($result_desc[2]??[]){
  662 + foreach ($result_desc[2] as $vdesc_img){
  663 + $v_desc['text'] = str_replace($vdesc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_img)),$v_desc['text']);
  664 + }
  665 + }
  666 +
  667 + //处理描述切换栏中的视频
  668 + preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc_video);
  669 + if($result_desc_video[2]??[]){
  670 + foreach ($result_desc_video[2] as $vdesc_video){
  671 + $v_desc['text'] = str_replace($vdesc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_video)),$v_desc['text']);
  672 + }
  673 + }
  674 + }
  675 + }
  676 +
651 $id = $this->model->addReturnId( 677 $id = $this->model->addReturnId(
652 [ 678 [
653 'project_id' => $project_id, 679 'project_id' => $project_id,
@@ -659,6 +685,7 @@ class ProductLogic extends BaseLogic @@ -659,6 +685,7 @@ class ProductLogic extends BaseLogic
659 'keyword_id' => $keyword_id, 685 'keyword_id' => $keyword_id,
660 'intro' => $intro, 686 'intro' => $intro,
661 'content' => $content, 687 'content' => $content,
  688 + 'describe' => Arr::a2s($describe),
662 'seo_mate' => Arr::a2s($seo_mate), 689 'seo_mate' => Arr::a2s($seo_mate),
663 'created_uid' => $user_id, 690 'created_uid' => $user_id,
664 'status' => Product::STATUS_ON 691 'status' => Product::STATUS_ON
@@ -14,4 +14,6 @@ use App\Models\Base; @@ -14,4 +14,6 @@ use App\Models\Base;
14 class CustomModule extends Base 14 class CustomModule extends Base
15 { 15 {
16 protected $table = 'gl_custom_module'; 16 protected $table = 'gl_custom_module';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
17 } 19 }
@@ -14,4 +14,6 @@ use App\Models\Base; @@ -14,4 +14,6 @@ use App\Models\Base;
14 class CustomModuleCategory extends Base 14 class CustomModuleCategory extends Base
15 { 15 {
16 protected $table = 'gl_custom_module_category'; 16 protected $table = 'gl_custom_module_category';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
17 } 19 }
@@ -14,4 +14,6 @@ use App\Models\Base; @@ -14,4 +14,6 @@ use App\Models\Base;
14 class CustomModuleContent extends Base 14 class CustomModuleContent extends Base
15 { 15 {
16 protected $table = 'gl_custom_module_content'; 16 protected $table = 'gl_custom_module_content';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
17 } 19 }
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :CustomModuleLabel.php 4 + * @name :CustomModuleExtend.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 - * @time :2023/11/6 10:05 7 + * @time :2023/12/4 15:42
8 */ 8 */
9 9
10 namespace App\Models\CustomModule; 10 namespace App\Models\CustomModule;
11 11
12 use App\Models\Base; 12 use App\Models\Base;
13 13
14 -class CustomModuleLabel extends Base 14 +class CustomModuleExtend extends Base
15 { 15 {
16 - protected $table = 'gl_custom_module_label'; 16 + protected $table = 'gl_custom_module_extent';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
17 } 19 }
@@ -38,6 +38,11 @@ class RouteMap extends Base @@ -38,6 +38,11 @@ class RouteMap extends Base
38 38
39 const SOURCE_NAV = 'nav'; 39 const SOURCE_NAV = 'nav';
40 40
  41 + //自定义模块
  42 + const SOURCE_MODULE = 'module_';
  43 +
  44 + //自定义模块分类
  45 + const SOURCE_MODULE_CATE = 'module_cate_';
41 /** 46 /**
42 * 生成路由标识 47 * 生成路由标识
43 * @param $title 48 * @param $title
@@ -364,6 +364,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -364,6 +364,7 @@ Route::middleware(['bloginauth'])->group(function () {
364 // 导航栏编辑 364 // 导航栏编辑
365 Route::prefix('nav')->group(function () { 365 Route::prefix('nav')->group(function () {
366 Route::get('/', [\App\Http\Controllers\Bside\Nav\NavController::class, 'index'])->name('nav'); 366 Route::get('/', [\App\Http\Controllers\Bside\Nav\NavController::class, 'index'])->name('nav');
  367 + Route::any('/get', [\App\Http\Controllers\Bside\Nav\NavController::class, 'getSubList'])->name('nav_getSubList');
367 Route::post('/create', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_create'); 368 Route::post('/create', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_create');
368 Route::post('/update', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_update'); 369 Route::post('/update', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_update');
369 Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete'); 370 Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete');
@@ -422,6 +423,28 @@ Route::middleware(['bloginauth'])->group(function () { @@ -422,6 +423,28 @@ Route::middleware(['bloginauth'])->group(function () {
422 Route::prefix('language')->group(function () { 423 Route::prefix('language')->group(function () {
423 Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists'); 424 Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists');
424 }); 425 });
  426 +
  427 + //自定义模板
  428 + Route::prefix('custom')->group(function () {
  429 + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
  430 + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
  431 + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
  432 +
  433 + Route::prefix('category')->group(function () {
  434 + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'lists'])->name('custom_category_lists');
  435 + Route::any('/getCateList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'getCateList'])->name('custom_category_getCateList');
  436 + Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'info'])->name('custom_category_info');
  437 + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_category_save');
  438 + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_category_del');
  439 + });
  440 +
  441 + Route::prefix('content')->group(function () {
  442 + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists');
  443 + Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info');
  444 + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save');
  445 + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
  446 + });
  447 + });
425 }); 448 });
426 //无需登录验证的路由组 449 //无需登录验证的路由组
427 Route::group([], function () { 450 Route::group([], function () {