作者 赵彬吉
@@ -39,6 +39,7 @@ class HtmlCollect extends Command @@ -39,6 +39,7 @@ class HtmlCollect extends Command
39 39
40 public function handle() 40 public function handle()
41 { 41 {
  42 + ini_set('memory_limit', '512M');
42 while (true) { 43 while (true) {
43 $this->start_collect(); 44 $this->start_collect();
44 } 45 }
@@ -294,6 +295,7 @@ class HtmlCollect extends Command @@ -294,6 +295,7 @@ class HtmlCollect extends Command
294 (empty($scheme) || $scheme == 'https' || $scheme == 'http') 295 (empty($scheme) || $scheme == 'https' || $scheme == 'http')
295 && (empty($host) || $host == $web_url_domain || $host == $home_url) 296 && (empty($host) || $host == $web_url_domain || $host == $home_url)
296 && $path 297 && $path
  298 + && (substr($path,0,1) == '/')
297 && (strpos($path, '.') !== false) 299 && (strpos($path, '.') !== false)
298 && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml'])) 300 && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml']))
299 ) { 301 ) {
@@ -350,11 +352,11 @@ class HtmlCollect extends Command @@ -350,11 +352,11 @@ class HtmlCollect extends Command
350 if ($js_css_source) { 352 if ($js_css_source) {
351 foreach ($js_css_source as $vjs) { 353 foreach ($js_css_source as $vjs) {
352 $vjs_down = str_replace('"', '', $vjs); 354 $vjs_down = str_replace('"', '', $vjs);
353 - if(strpos($vjs_down,'data:') !== false){ 355 + if (strpos($vjs_down, 'data:') !== false) {
354 //过滤二进制文件 356 //过滤二进制文件
355 continue; 357 continue;
356 } 358 }
357 - if(strlen($vjs_down) > 255){ 359 + if (strlen($vjs_down) > 255) {
358 //过滤太长文件 360 //过滤太长文件
359 continue; 361 continue;
360 } 362 }
@@ -365,7 +367,7 @@ class HtmlCollect extends Command @@ -365,7 +367,7 @@ class HtmlCollect extends Command
365 $cos = config('filesystems.disks.cos'); 367 $cos = config('filesystems.disks.cos');
366 $cosCdn = $cos['cdn']; 368 $cosCdn = $cos['cdn'];
367 369
368 - if ($vjs_down_host == $cosCdn) { 370 + if ($vjs_down_host && $vjs_down_host == $cosCdn) {
369 //过滤已经下载的 371 //过滤已经下载的
370 continue; 372 continue;
371 } 373 }
@@ -39,6 +39,7 @@ class HtmlLanguageCollect extends Command @@ -39,6 +39,7 @@ class HtmlLanguageCollect extends Command
39 39
40 public function handle() 40 public function handle()
41 { 41 {
  42 + ini_set('memory_limit', '512M');
42 while (true) { 43 while (true) {
43 $this->start_collect(); 44 $this->start_collect();
44 } 45 }
@@ -294,6 +295,7 @@ class HtmlLanguageCollect extends Command @@ -294,6 +295,7 @@ class HtmlLanguageCollect extends Command
294 (empty($scheme) || $scheme == 'https' || $scheme == 'http') 295 (empty($scheme) || $scheme == 'https' || $scheme == 'http')
295 && (empty($host) || $host == $web_url_domain || $host == $home_url) 296 && (empty($host) || $host == $web_url_domain || $host == $home_url)
296 && $path 297 && $path
  298 + && (substr($path,0,1) == '/')
297 && (strpos($path, '.') !== false) 299 && (strpos($path, '.') !== false)
298 && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml'])) 300 && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml']))
299 ) { 301 ) {
@@ -350,11 +352,11 @@ class HtmlLanguageCollect extends Command @@ -350,11 +352,11 @@ class HtmlLanguageCollect extends Command
350 if ($js_css_source) { 352 if ($js_css_source) {
351 foreach ($js_css_source as $vjs) { 353 foreach ($js_css_source as $vjs) {
352 $vjs_down = str_replace('"', '', $vjs); 354 $vjs_down = str_replace('"', '', $vjs);
353 - if(strpos($vjs_down,'data:') !== false){ 355 + if (strpos($vjs_down, 'data:') !== false) {
354 //过滤二进制文件 356 //过滤二进制文件
355 continue; 357 continue;
356 } 358 }
357 - if(strlen($vjs_down) > 255){ 359 + if (strlen($vjs_down) > 255) {
358 //过滤太长文件 360 //过滤太长文件
359 continue; 361 continue;
360 } 362 }
@@ -365,7 +367,7 @@ class HtmlLanguageCollect extends Command @@ -365,7 +367,7 @@ class HtmlLanguageCollect extends Command
365 $cos = config('filesystems.disks.cos'); 367 $cos = config('filesystems.disks.cos');
366 $cosCdn = $cos['cdn']; 368 $cosCdn = $cos['cdn'];
367 369
368 - if ($vjs_down_host == $cosCdn) { 370 + if ($vjs_down_host && $vjs_down_host == $cosCdn) {
369 //过滤已经下载的 371 //过滤已经下载的
370 continue; 372 continue;
371 } 373 }
@@ -49,6 +49,7 @@ class ProjectUpdate extends Command @@ -49,6 +49,7 @@ class ProjectUpdate extends Command
49 49
50 public function handle() 50 public function handle()
51 { 51 {
  52 + ini_set('memory_limit', '512M');
52 while (true) { 53 while (true) {
53 $this->start_update(); 54 $this->start_update();
54 } 55 }
@@ -54,157 +54,28 @@ class UpdateRoute extends Command @@ -54,157 +54,28 @@ class UpdateRoute extends Command
54 */ 54 */
55 public function handle(){ 55 public function handle(){
56 $projectModel = new Project(); 56 $projectModel = new Project();
57 - $lists = $projectModel->list(['is_upgrade'=>0,'id'=>['>',167],'type'=>['!=',0]]); 57 + $lists = $projectModel->list(['is_upgrade'=>0,'type'=>['!=',0]]);
58 foreach ($lists as $k => $v){ 58 foreach ($lists as $k => $v){
59 - echo date('Y-m-d H:i:s') . ' start: 项目id为' . $v['id'] . PHP_EOL;  
60 ProjectServer::useProject($v['id']); 59 ProjectServer::useProject($v['id']);
61 -// $this->setProductRoute($v['id']);  
62 - $this->setProductKeywordRoute($v['id']);  
63 -// $this->setBlogRoute($v['id']);  
64 -// $this->setNewsRoute($v['id']);  
65 -// $this->setBlogCateRoute($v['id']);  
66 -// $this->setNewsCateRoute($v['id']); 60 + $this->getProductKeyword($v['id']);
67 DB::disconnect('custom_mysql'); 61 DB::disconnect('custom_mysql');
68 } 62 }
69 echo date('Y-m-d H:i:s') . ' end: 项目id为' . $v['id'] . PHP_EOL; 63 echo date('Y-m-d H:i:s') . ' end: 项目id为' . $v['id'] . PHP_EOL;
70 } 64 }
71 65
72 /** 66 /**
73 - * @remark :设置路由  
74 - * @name :setRoute 67 + * @remark :产品关键字
  68 + * @name :getProductKeyword
75 * @author :lyh 69 * @author :lyh
76 * @method :post 70 * @method :post
77 - * @time :2023/11/20 15:30 71 + * @time :2023/12/8 11:13
78 */ 72 */
79 - public function setProductRoute($project_id){  
80 - $productModel = new Product();  
81 - $productList = $productModel->list(['status'=>['!=',2]],'id',['id','route']);  
82 - foreach ($productList as $v){  
83 - $route = preg_replace('/-2-1-product.*/', '', $v['route']);  
84 - $route = preg_replace('/-1-1-product.*/', '', $route);  
85 - $route = preg_replace('/-2-product.*/', '', $route);  
86 - $route = preg_replace('/-1-product.*/', '', $route);  
87 - $route = preg_replace('/-product.*/', '', $route);  
88 - $i = 0;  
89 - $routes = $this->productRoute($route,$v['id'],$i);  
90 - $route = RouteMap::setRoute($routes, RouteMap::SOURCE_PRODUCT, $v['id'], $project_id);  
91 - echo date('Y-m-d H:i:s') . ' 路由表返回的route:' . $route . PHP_EOL;  
92 - $productModel->edit(['route'=>$route],['id'=>$v['id']]);  
93 - }  
94 - return true;  
95 - }  
96 -  
97 - /**  
98 - * @remark :产品新增单独处理路由  
99 - * @name :setProductRoute  
100 - * @author :lyh  
101 - * @method :post  
102 - * @time :2023/11/21 18:48  
103 - */  
104 - public function productRoute($route,$id,$i){  
105 - echo date('Y-m-d H:i:s') . ' 打印$i:' . $i . PHP_EOL;  
106 - if($i == 0){  
107 - $routes = $route.'-product';  
108 - }else{  
109 - $routes = $route.'-'.$i.'-product';  
110 - }  
111 - $routeMapModel = new RouteMap();  
112 - $routeInfo = $routeMapModel->read(['route'=>$routes,'source'=>'product','source_id'=>['!=',$id]]);  
113 - if($routeInfo == false){  
114 - echo date('Y-m-d H:i:s') . ' route:' . $routes . PHP_EOL;  
115 - return $routes;  
116 - }else{  
117 - echo date('Y-m-d H:i:s') . ' 数据:' . $routeInfo['id'] . PHP_EOL;  
118 - $i = $i + 1;  
119 - return $this->productRoute($route,$id,$i);  
120 - }  
121 - }  
122 -  
123 - /**  
124 - * @remark :设置路由  
125 - * @name :setRoute  
126 - * @author :lyh  
127 - * @method :post  
128 - * @time :2023/11/20 15:30  
129 - */  
130 - public function setNewsRoute($project_id){  
131 - $newsModel = new News();  
132 - $newsList = $newsModel->list(['status'=>['!=',2]],'id',['id','url']);  
133 - foreach ($newsList as $v){  
134 - RouteMap::setRoute($v['url'], RouteMap::SOURCE_NEWS, $v['id'], $project_id);  
135 - }  
136 - return true;  
137 - }  
138 -  
139 - /**  
140 - * @remark :设置路由  
141 - * @name :setRoute  
142 - * @author :lyh  
143 - * @method :post  
144 - * @time :2023/11/20 15:30  
145 - */  
146 - public function setNewsCateRoute($project_id){  
147 - $newsCateModel = new NewsCategory();  
148 - $newsList = $newsCateModel->list([],'id',['id','alias']);  
149 - foreach ($newsList as $v){  
150 - RouteMap::setRoute($v['alias'], RouteMap::SOURCE_NEWS_CATE, $v['id'], $project_id);  
151 - }  
152 - return true;  
153 - }  
154 -  
155 - /**  
156 - * @remark :设置路由  
157 - * @name :setRoute  
158 - * @author :lyh  
159 - * @method :post  
160 - * @time :2023/11/20 15:30  
161 - */  
162 - public function setBlogRoute($project_id){  
163 - $blogModel = new Blog();  
164 - $blogList = $blogModel->list(['status'=>['!=',2]],'id',['id','url']);  
165 - foreach ($blogList as $v){  
166 - RouteMap::setRoute($v['url'], RouteMap::SOURCE_BLOG, $v['id'], $project_id);  
167 - }  
168 - return true;  
169 - }  
170 -  
171 - /**  
172 - * @remark :设置路由  
173 - * @name :setRoute  
174 - * @author :lyh  
175 - * @method :post  
176 - * @time :2023/11/20 15:30  
177 - */  
178 - public function setBlogCateRoute($project_id){  
179 - $blogCateModel = new BlogCategory();  
180 - $blogList = $blogCateModel->list([],'id',['id','alias']);  
181 - foreach ($blogList as $v){  
182 - RouteMap::setRoute($v['alias'], RouteMap::SOURCE_BLOG_CATE, $v['id'], $project_id);  
183 - }  
184 - return true;  
185 - }  
186 -  
187 - /**  
188 - * @remark :设置路由  
189 - * @name :setRoute  
190 - * @author :lyh  
191 - * @method :post  
192 - * @time :2023/11/20 15:30  
193 - */  
194 - public function setProductKeywordRoute($project_id){ 73 + public function getProductKeyword($id){
195 $keywordModel = new Keyword(); 74 $keywordModel = new Keyword();
196 - $keywordList = $keywordModel->list([],'id',['id','route']);  
197 - if(!empty($keywordList)){  
198 - foreach ($keywordList as $v){  
199 -// if(!ends_with($v['route'],'-tag')){  
200 -// $route = $v['route'].'-tag';  
201 -// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);  
202 -// }  
203 - $routeMapModel = new RouteMap();  
204 - $routeMapModel->edit(['route'=>$v['route']],['source_id'=>$v['id'],'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD]);  
205 - RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $project_id);  
206 - } 75 + $lists = $keywordModel->list(['route'=>['like','%-1-2-%']]);
  76 + if(!empty($lists)){
  77 + echo date('Y-m-d H:i:s') . ' 错误id:' . $id . PHP_EOL;
207 } 78 }
208 - return true;  
209 } 79 }
  80 +
210 } 81 }
@@ -646,3 +646,39 @@ function redis_add($key,$val,$ttl=3600){ @@ -646,3 +646,39 @@ function redis_add($key,$val,$ttl=3600){
646 "return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])", [$key, $val, $ttl], 1 646 "return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])", [$key, $val, $ttl], 1
647 ); 647 );
648 } 648 }
  649 +
  650 +/**
  651 + * 判断远程地址是否需要下载
  652 + * @param $url
  653 + * @author Akun
  654 + * @date 2023/12/08 14:17
  655 + */
  656 +function check_remote_url_down($url){
  657 + if(!$url){
  658 + return false;
  659 + }
  660 +
  661 + $arr = parse_url($url);
  662 + $scheme = $arr['scheme'] ?? '';
  663 + $host = $arr['host'] ?? '';
  664 + $path = $arr['path'] ?? '';
  665 +
  666 + if($scheme && !in_array($scheme,['http','https'])){
  667 + return false;
  668 + }
  669 +
  670 + if(!$host){
  671 + return false;
  672 + }
  673 +
  674 + $host_arr = explode('.',$host);
  675 + if(strpos($host_arr[0],'cnd') !== false){
  676 + return false;
  677 + }
  678 +
  679 + if(strpos($path, '.') === false){
  680 + return false;
  681 + }
  682 +
  683 + return true;
  684 +}
@@ -129,25 +129,23 @@ class OnlineController extends BaseController @@ -129,25 +129,23 @@ class OnlineController extends BaseController
129 * @time :2023/8/18 10:58 129 * @time :2023/8/18 10:58
130 */ 130 */
131 public function searchParam(&$query){ 131 public function searchParam(&$query){
  132 + if(isset($this->map['id'])){
  133 + $query->where('gl_project.id',$this->map['id']);
  134 + }
132 if(!empty($this->map['message']) && !empty($this->map['type'])){ 135 if(!empty($this->map['message']) && !empty($this->map['type'])){
133 - // 搜索域名  
134 if($this->map['type'] == 'test_domain'){ 136 if($this->map['type'] == 'test_domain'){
135 $query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['message'].'%'); 137 $query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['message'].'%');
136 } else { 138 } else {
137 - // 搜索名称  
138 $query->where('gl_project.title', 'like', '%' . $this->map['message'] . '%'); 139 $query->where('gl_project.title', 'like', '%' . $this->map['message'] . '%');
139 } 140 }
140 } 141 }
141 if(isset($this->map['qa_status'])){ 142 if(isset($this->map['qa_status'])){
142 - // 搜索状态  
143 $query->where('gl_project_online_check.qa_status',$this->map['qa_status']); 143 $query->where('gl_project_online_check.qa_status',$this->map['qa_status']);
144 } 144 }
145 if(isset($this->map['all_status'])){ 145 if(isset($this->map['all_status'])){
146 - // 搜索状态  
147 $query->where('gl_project_online_check.qa_status',$this->map['all_status']); 146 $query->where('gl_project_online_check.qa_status',$this->map['all_status']);
148 } 147 }
149 if(isset($this->map['optimist_status'])){ 148 if(isset($this->map['optimist_status'])){
150 - // 搜索状态  
151 $query->where('gl_project_online_check.optimist_status',$this->map['optimist_status']); 149 $query->where('gl_project_online_check.optimist_status',$this->map['optimist_status']);
152 } 150 }
153 $query = $query->where('gl_project.status',1);//TODO::已提交审核 151 $query = $query->where('gl_project.status',1);//TODO::已提交审核
@@ -24,7 +24,7 @@ class BlogController extends BaseController @@ -24,7 +24,7 @@ class BlogController extends BaseController
24 * @time :2023/9/14 10:45 24 * @time :2023/9/14 10:45
25 */ 25 */
26 public function lists(BlogModel $blogModel){ 26 public function lists(BlogModel $blogModel){
27 - $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url','release_at','is_upgrade']; 27 + $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url','release_at','is_upgrade','six_read'];
28 $this->order = 'sort'; 28 $this->order = 'sort';
29 $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); 29 $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc');
30 $query = $this->searchParam($query); 30 $query = $this->searchParam($query);
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Http\Controllers\Bside\CustomModule; 10 namespace App\Http\Controllers\Bside\CustomModule;
11 11
  12 +use App\Enums\Common\Code;
12 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
13 use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic; 14 use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic;
14 use App\Models\CustomModule\CustomModuleCategory; 15 use App\Models\CustomModule\CustomModuleCategory;
@@ -16,7 +17,7 @@ use App\Models\CustomModule\CustomModuleCategory; @@ -16,7 +17,7 @@ use App\Models\CustomModule\CustomModuleCategory;
16 class CustomModuleCategoryController extends BaseController 17 class CustomModuleCategoryController extends BaseController
17 { 18 {
18 /** 19 /**
19 - * @remark :获取自定义模块列表 20 + * @remark :获取自定义模块分类列表
20 * @name :ModuleList 21 * @name :ModuleList
21 * @author :lyh 22 * @author :lyh
22 * @method :post 23 * @method :post
@@ -29,8 +30,35 @@ class CustomModuleCategoryController extends BaseController @@ -29,8 +30,35 @@ class CustomModuleCategoryController extends BaseController
29 'module_id.required' => 'module_id不能为空', 30 'module_id.required' => 'module_id不能为空',
30 ]); 31 ]);
31 $this->map['project_id'] = $this->user['project_id']; 32 $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); 33 + $this->map['status'] = 0;
  34 + $list = $customModuleCategory->list($this->map);
  35 + if(!empty($list)){
  36 + foreach ($list as $k => $v){
  37 + $v['url'] = $this->user['domain'].$v['route'];
  38 + $list[$k] = $v;
  39 + }
  40 + }
  41 + $data = $this->getListSon($list);
  42 + $this->response('success',Code::SUCCESS,$data);
  43 + }
  44 +
  45 + /**
  46 + * @remark :无分页子集处理
  47 + * @name :getListSon
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2023/8/17 11:12
  51 + */
  52 + public function getListSon($list){
  53 + $data = array();
  54 + foreach ($list as $v){
  55 + $v = (array)$v;
  56 + if ($v['pid'] == 0) {
  57 + $v['sub'] = _get_child($v['id'], $list);
  58 + $data[] = $v;
  59 + }
  60 + }
  61 + return $data;
34 } 62 }
35 63
36 /** 64 /**
@@ -73,11 +101,13 @@ class CustomModuleCategoryController extends BaseController @@ -73,11 +101,13 @@ class CustomModuleCategoryController extends BaseController
73 $this->request->validate([ 101 $this->request->validate([
74 'name'=>['required'], 102 'name'=>['required'],
75 'route'=>['required'], 103 'route'=>['required'],
76 - 'module_id'=>['required'] 104 + 'module_id'=>['required'],
  105 + 'pid'=>['required']
77 ],[ 106 ],[
78 'name.required' => '分类名称不能为空', 107 'name.required' => '分类名称不能为空',
79 'route.required' => '分类路由不能为空', 108 'route.required' => '分类路由不能为空',
80 - 'module_id.required' => '所选模块id不能为空' 109 + 'module_id.required' => '所选模块id不能为空',
  110 + 'pid.required' => '上级不能为空'
81 ]); 111 ]);
82 $logic->categorySave(); 112 $logic->categorySave();
83 $this->response('success'); 113 $this->response('success');
@@ -11,6 +11,7 @@ namespace App\Http\Controllers\Bside\CustomModule; @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Bside\CustomModule;
11 11
12 use App\Http\Controllers\Bside\BaseController; 12 use App\Http\Controllers\Bside\BaseController;
13 use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; 13 use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
  14 +use App\Models\CustomModule\CustomModuleCategory;
14 use App\Models\CustomModule\CustomModuleContent; 15 use App\Models\CustomModule\CustomModuleContent;
15 16
16 class CustomModuleContentController extends BaseController 17 class CustomModuleContentController extends BaseController
@@ -34,6 +35,19 @@ class CustomModuleContentController extends BaseController @@ -34,6 +35,19 @@ class CustomModuleContentController extends BaseController
34 } 35 }
35 36
36 /** 37 /**
  38 + * @remark :添加/编辑内容时获取分类
  39 + * @name :getCategoryList
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2023/12/7 15:19
  43 + */
  44 + public function getCategoryList(){
  45 + $categoryModel = new CustomModuleCategory();
  46 + $list = $categoryModel->list(['project_id'=>$this->user['project_id'],'module_id'=>$this->param['module_id']],['id','name']);
  47 + $this->response('success',Code::SUCCESS,$list);
  48 + }
  49 +
  50 + /**
37 * @remark :获取当前数据详情 51 * @remark :获取当前数据详情
38 * @name :info 52 * @name :info
39 * @author :lyh 53 * @author :lyh
@@ -46,7 +60,7 @@ class CustomModuleContentController extends BaseController @@ -46,7 +60,7 @@ class CustomModuleContentController extends BaseController
46 ],[ 60 ],[
47 'id.required' => 'ID不能为空', 61 'id.required' => 'ID不能为空',
48 ]); 62 ]);
49 - $info = $logic->getCustomModuleContentInfo(); 63 + $info = $logic->getContentInfo();
50 $this->response('success',Code::SUCCESS,$info); 64 $this->response('success',Code::SUCCESS,$info);
51 } 65 }
52 66
@@ -67,7 +81,7 @@ class CustomModuleContentController extends BaseController @@ -67,7 +81,7 @@ class CustomModuleContentController extends BaseController
67 'route.required' => '分类路由不能为空', 81 'route.required' => '分类路由不能为空',
68 'module_id.required' => '所选模块id不能为空' 82 'module_id.required' => '所选模块id不能为空'
69 ]); 83 ]);
70 - $logic->customModuleContentSave(); 84 + $logic->contentSave();
71 $this->response('success'); 85 $this->response('success');
72 } 86 }
73 87
@@ -84,7 +98,7 @@ class CustomModuleContentController extends BaseController @@ -84,7 +98,7 @@ class CustomModuleContentController extends BaseController
84 ],[ 98 ],[
85 'id.required' => 'ID不能为空', 99 'id.required' => 'ID不能为空',
86 ]); 100 ]);
87 - $logic->customModuleContentDel(); 101 + $logic->contentDel();
88 $this->response('success'); 102 $this->response('success');
89 } 103 }
90 } 104 }
@@ -32,6 +32,7 @@ class CustomModuleController extends BaseController @@ -32,6 +32,7 @@ class CustomModuleController extends BaseController
32 */ 32 */
33 public function lists(CustomModule $customModule){ 33 public function lists(CustomModule $customModule){
34 $this->map['project_id'] = $this->user['project_id']; 34 $this->map['project_id'] = $this->user['project_id'];
  35 + $this->map['status'] = 0;
35 $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order); 36 $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
36 $this->response('success',Code::SUCCESS,$lists); 37 $this->response('success',Code::SUCCESS,$lists);
37 } 38 }
@@ -22,9 +22,15 @@ class CustomModuleExtentController extends BaseController @@ -22,9 +22,15 @@ class CustomModuleExtentController extends BaseController
22 * @method :post 22 * @method :post
23 * @time :2023/12/4 15:43 23 * @time :2023/12/4 15:43
24 */ 24 */
25 - public function list(CustomModuleExtend $customModuleExtend){ 25 + public function lists(CustomModuleExtend $customModuleExtend){
  26 + $this->request->validate([
  27 + 'module_id'=>['required'],
  28 + ],[
  29 + 'module_id.required' => 'module_id不能为空',
  30 + ]);
26 $this->map['project_id'] = $this->user['project_id']; 31 $this->map['project_id'] = $this->user['project_id'];
27 - $lists = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order); 32 + $filed = ['id','title','status','type','operator_id','project_id','module_id','created_at','updated_at'];
  33 + $lists = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order,$filed);
28 $this->response('success',Code::SUCCESS,$lists); 34 $this->response('success',Code::SUCCESS,$lists);
29 } 35 }
30 36
@@ -41,7 +47,7 @@ class CustomModuleExtentController extends BaseController @@ -41,7 +47,7 @@ class CustomModuleExtentController extends BaseController
41 ],[ 47 ],[
42 'id.required' => 'ID不能为空', 48 'id.required' => 'ID不能为空',
43 ]); 49 ]);
44 - $info = $logic->getCustomModuleExtendInfo(); 50 + $info = $logic->getExtendInfo();
45 $this->response('success',Code::SUCCESS,$info); 51 $this->response('success',Code::SUCCESS,$info);
46 } 52 }
47 53
@@ -53,7 +59,7 @@ class CustomModuleExtentController extends BaseController @@ -53,7 +59,7 @@ class CustomModuleExtentController extends BaseController
53 * @time :2023/12/4 15:45 59 * @time :2023/12/4 15:45
54 */ 60 */
55 public function save(CustomModuleExtendLogic $logic){ 61 public function save(CustomModuleExtendLogic $logic){
56 - $logic->customModuleExtendSave(); 62 + $logic->extendSave();
57 $this->response('success'); 63 $this->response('success');
58 } 64 }
59 65
@@ -70,7 +76,7 @@ class CustomModuleExtentController extends BaseController @@ -70,7 +76,7 @@ class CustomModuleExtentController extends BaseController
70 ],[ 76 ],[
71 'id.required' => 'ID不能为空', 77 'id.required' => 'ID不能为空',
72 ]); 78 ]);
73 - $logic->customModuleExtendDel(); 79 + $logic->extendDel();
74 $this->response('success'); 80 $this->response('success');
75 } 81 }
76 } 82 }
@@ -24,7 +24,7 @@ class NewsController extends BaseController @@ -24,7 +24,7 @@ class NewsController extends BaseController
24 * @method 24 * @method
25 */ 25 */
26 public function lists(NewsModel $news){ 26 public function lists(NewsModel $news){
27 - $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url', 'release_at','is_upgrade']; 27 + $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url', 'release_at','is_upgrade','six_read'];
28 $this->order = 'sort'; 28 $this->order = 'sort';
29 $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); 29 $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc');
30 $query = $this->searchParam($query); 30 $query = $this->searchParam($query);
@@ -43,7 +43,7 @@ class ProductController extends BaseController @@ -43,7 +43,7 @@ class ProductController extends BaseController
43 public function index(Product $product) 43 public function index(Product $product)
44 { 44 {
45 $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , 45 $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
46 - 'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at']; 46 + 'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read'];
47 $this->order = 'sort'; 47 $this->order = 'sort';
48 $query = $product->orderBy($this->order ,'desc')->orderBy('id','desc'); 48 $query = $product->orderBy($this->order ,'desc')->orderBy('id','desc');
49 $query = $this->searchParam($query); 49 $query = $this->searchParam($query);
@@ -253,19 +253,19 @@ class BlogLogic extends BaseLogic @@ -253,19 +253,19 @@ class BlogLogic extends BaseLogic
253 if (!$blog) { 253 if (!$blog) {
254 254
255 $category_id = ''; 255 $category_id = '';
256 - if ($data[2]) { 256 + if ($data[2]??'') {
257 //处理分类 257 //处理分类
258 $blogCategoryLogic = new BlogCategoryLogic(); 258 $blogCategoryLogic = new BlogCategoryLogic();
259 $category_id = $blogCategoryLogic->importBlogCategory($project_id, $user_id, $data[2]); 259 $category_id = $blogCategoryLogic->importBlogCategory($project_id, $user_id, $data[2]);
260 } 260 }
261 261
262 $text = ''; 262 $text = '';
263 - if($data[4]){ 263 + if($data[4]??''){
264 //处理内容中的图片 264 //处理内容中的图片
265 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result); 265 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result);
266 if($result[2]??[]){ 266 if($result[2]??[]){
267 foreach ($result[2] as $img){ 267 foreach ($result[2] as $img){
268 - $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); 268 + check_remote_url_down($img) && $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
269 } 269 }
270 } 270 }
271 271
@@ -273,20 +273,25 @@ class BlogLogic extends BaseLogic @@ -273,20 +273,25 @@ class BlogLogic extends BaseLogic
273 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result_video); 273 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result_video);
274 if($result_video[2]??[]){ 274 if($result_video[2]??[]){
275 foreach ($result_video[2] as $video){ 275 foreach ($result_video[2] as $video){
276 - $data[4] = str_replace($video,getImageUrl(CosService::uploadRemote($project_id,'image_news',$video)),$data[4]); 276 + check_remote_url_down($video) && $data[4] = str_replace($video,getImageUrl(CosService::uploadRemote($project_id,'image_news',$video)),$data[4]);
277 } 277 }
278 } 278 }
279 279
280 $text = $data[4]; 280 $text = $data[4];
281 } 281 }
282 282
  283 + $img = '';
  284 + if($data[5]??''){
  285 + $img = check_remote_url_down($data[5]) ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : $data[5];
  286 + }
  287 +
283 $id = $this->model->addReturnId( 288 $id = $this->model->addReturnId(
284 [ 289 [
285 'name' => $data[0], 290 'name' => $data[0],
286 'category_id' => $category_id, 291 'category_id' => $category_id,
287 'text' => $text, 292 'text' => $text,
288 'remark' => $data[3] ?? '', 293 'remark' => $data[3] ?? '',
289 - 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_blog', $data[5]) : '', 294 + 'image' => $img,
290 'seo_title' => $data[6] ?? '', 295 'seo_title' => $data[6] ?? '',
291 'seo_keywords' => $data[7] ?? '', 296 'seo_keywords' => $data[7] ?? '',
292 'seo_description' => $data[8] ?? '', 297 'seo_description' => $data[8] ?? '',
@@ -298,7 +303,7 @@ class BlogLogic extends BaseLogic @@ -298,7 +303,7 @@ class BlogLogic extends BaseLogic
298 ] 303 ]
299 ); 304 );
300 //更新路由 305 //更新路由
301 - $route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_BLOG, $id, $project_id); 306 + $route = RouteMap::setRoute((isset($data[1]) && $data[1]) ? $data[1] : $data[0], RouteMap::SOURCE_BLOG, $id, $project_id);
302 $this->edit(['url' => $route], ['id' => $id]); 307 $this->edit(['url' => $route], ['id' => $id]);
303 308
304 return true; 309 return true;
@@ -82,6 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -82,6 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic
82 if($info === false){ 82 if($info === false){
83 $this->fail('当前数据不存在或已被删除'); 83 $this->fail('当前数据不存在或已被删除');
84 } 84 }
  85 + $info['image_link'] = getImageUrl($info['image']);
85 return $this->success($info); 86 return $this->success($info);
86 } 87 }
87 88
@@ -93,6 +94,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -93,6 +94,7 @@ class CustomModuleCategoryLogic extends BaseLogic
93 * @time :2023/12/4 15:47 94 * @time :2023/12/4 15:47
94 */ 95 */
95 public function categorySave(){ 96 public function categorySave(){
  97 + $this->param = $this->handleParam($this->param);
96 if(isset($this->param['id']) && !empty($this->param['id'])){ 98 if(isset($this->param['id']) && !empty($this->param['id'])){
97 $this->categoryEdit(); 99 $this->categoryEdit();
98 }else{ 100 }else{
@@ -102,6 +104,24 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -102,6 +104,24 @@ class CustomModuleCategoryLogic extends BaseLogic
102 } 104 }
103 105
104 /** 106 /**
  107 + * @name :(参数处理)paramProcessing
  108 + * @author :lyh
  109 + * @method :post
  110 + * @time :2023/6/13 11:30
  111 + */
  112 + public function handleParam($param)
  113 + {
  114 + $param['operator_id'] = $this->user['id'];
  115 + if(!isset($param['id']) || empty($param['id'])){
  116 + $param['project_id'] = $this->user['project_id'];
  117 + }
  118 + if(isset($param['image']) && !empty($param['image'])){
  119 + $param['image'] = str_replace_url($param['image']);
  120 + }
  121 + return $this->success($param);
  122 + }
  123 +
  124 + /**
105 * @remark :添加分类 125 * @remark :添加分类
106 * @name :categoryAdd 126 * @name :categoryAdd
107 * @author :lyh 127 * @author :lyh
@@ -116,7 +136,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -116,7 +136,7 @@ class CustomModuleCategoryLogic extends BaseLogic
116 $this->handleAddSon($id); 136 $this->handleAddSon($id);
117 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route); 137 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
118 $this->curlDelRoute(['new_route'=>$route]); 138 $this->curlDelRoute(['new_route'=>$route]);
119 - $this->edit(['url' => $route], ['id' => $id]); 139 + $this->edit(['route' => $route], ['id' => $id]);
120 //处理上级分类商品 140 //处理上级分类商品
121 $this->handleAddSon($id); 141 $this->handleAddSon($id);
122 }catch (\Exception $e){ 142 }catch (\Exception $e){
@@ -135,7 +155,8 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -135,7 +155,8 @@ class CustomModuleCategoryLogic extends BaseLogic
135 public function categoryEdit(){ 155 public function categoryEdit(){
136 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], 156 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
137 $this->param['id'], $this->user['project_id']); 157 $this->param['id'], $this->user['project_id']);
138 - $this->editNewsRoute($this->param['id'],$route); 158 + $this->editHandleCategory($this->param['id'],$this->param['pid']);
  159 + $this->editRoute($this->param['id'],$route);
139 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 160 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
140 if($rs === false){ 161 if($rs === false){
141 $this->fail('系统错误,请连续管理员'); 162 $this->fail('系统错误,请连续管理员');
@@ -153,16 +174,16 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -153,16 +174,16 @@ class CustomModuleCategoryLogic extends BaseLogic
153 public function editHandleCategory($id,$pid){ 174 public function editHandleCategory($id,$pid){
154 $info = $this->model->read(['id'=>$id],['id','pid']); 175 $info = $this->model->read(['id'=>$id],['id','pid']);
155 if($info['pid'] != $pid){ 176 if($info['pid'] != $pid){
156 - //修改勒上级,先查看上级是否拥有博客 177 + //修改勒上级,先查看上级是否拥有产品
157 $contentModel = new CustomModuleContent(); 178 $contentModel = new CustomModuleContent();
158 - $newsCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();  
159 - //随机获取最后一级id  
160 - $replacement = $this->getLastId($id);  
161 - if($newsCount > 0){ 179 + $contentCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
  180 + if($contentCount > 0){
  181 + //随机获取最后一级id
  182 + $replacement = $this->getLastId($id);
162 //存在博客时,移动所有博客到当前分类最后一级 183 //存在博客时,移动所有博客到当前分类最后一级
163 - $newsCount->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%') 184 + $contentModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
164 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]); 185 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
165 - $newsCount->where('category_id', 'like', '%,' . $pid . ',%') 186 + $contentModel->where('category_id', 'like', '%,' . $pid . ',%')
166 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); 187 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
167 } 188 }
168 } 189 }
@@ -170,13 +191,29 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -170,13 +191,29 @@ class CustomModuleCategoryLogic extends BaseLogic
170 } 191 }
171 192
172 /** 193 /**
  194 + * @remark :随机获取当前id下最后一级的id
  195 + * @name :getLastId
  196 + * @author :lyh
  197 + * @method :post
  198 + * @time :2023/10/20 9:45
  199 + */
  200 + public function getLastId($id){
  201 + $info = $this->model->read(['pid'=>$id],['id']);
  202 + if($info !== false){
  203 + return $this->getLastId($info['id']);
  204 + }else{
  205 + return $id;
  206 + }
  207 + }
  208 +
  209 + /**
173 * @remark :查看是否编辑路由 210 * @remark :查看是否编辑路由
174 * @name :editCategoryRoute 211 * @name :editCategoryRoute
175 * @author :lyh 212 * @author :lyh
176 * @method :post 213 * @method :post
177 * @time :2023/9/7 11:05 214 * @time :2023/9/7 11:05
178 */ 215 */
179 - public function editNewsRoute($id, $route) 216 + public function editRoute($id, $route)
180 { 217 {
181 //生成一条删除路由记录 218 //生成一条删除路由记录
182 $info = $this->model->read(['id' => $id], ['id', 'route']); 219 $info = $this->model->read(['id' => $id], ['id', 'route']);
@@ -235,14 +272,37 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -235,14 +272,37 @@ class CustomModuleCategoryLogic extends BaseLogic
235 * @time :2023/12/4 15:47 272 * @time :2023/12/4 15:47
236 */ 273 */
237 public function categoryDel(){ 274 public function categoryDel(){
238 - $info = $this->model->read(['pid' => $this->param['id']], ['id', 'route']);  
239 - if($info === false){  
240 - $this->fail('当前分类拥有下级');  
241 - }  
242 - $rs = $this->model->del($this->param);  
243 - if($rs === false){  
244 - $this->fail('系统错误,请连续管理员'); 275 + $ids = $this->param['id'];
  276 + foreach ($ids as $id){
  277 + $info = $this->model->read(['pid'=>$id],['id']);
  278 + if($info !== false){
  279 + $this->fail('分类id:'.$id.'拥有子集不允许删除');
  280 + }
  281 + $contentModel = new CustomModuleContent();
  282 + $contentInfo = $contentModel->read(['category_id'=>['like','%,'.$id.',%']]);
  283 + if($contentInfo !== false){
  284 + $this->fail('当前分类拥有产品不允许删除');
  285 + }
  286 + //删除路由
  287 + $this->delRoute($id);
  288 + $this->model->del(['id'=>$id]);
245 } 289 }
246 return $this->success(); 290 return $this->success();
247 } 291 }
  292 +
  293 + /**
  294 + * @remark :删除路由
  295 + * @name :delRoute
  296 + * @author :lyh
  297 + * @method :post
  298 + * @time :2023/9/7 10:50
  299 + */
  300 + public function delRoute($id)
  301 + {
  302 + RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']);
  303 + //通知
  304 + $info = $this->model->read(['id' => $id], ['id', 'route']);
  305 + $this->curlDelRoute(['route'=>$info['route']]);
  306 + return $this->success();
  307 + }
248 } 308 }
@@ -10,7 +10,15 @@ @@ -10,7 +10,15 @@
10 namespace App\Http\Logic\Bside\CustomModule; 10 namespace App\Http\Logic\Bside\CustomModule;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\CustomModule\CustomModuleCategory;
13 use App\Models\CustomModule\CustomModuleContent; 14 use App\Models\CustomModule\CustomModuleContent;
  15 +use App\Models\CustomModule\CustomModuleExtend;
  16 +use App\Models\CustomModule\CustomModuleExtentContent;
  17 +use App\Models\Product\Extend;
  18 +use App\Models\Product\ExtendInfo;
  19 +use App\Models\RouteMap\RouteMap;
  20 +use Illuminate\Support\Facades\DB;
  21 +use mysql_xdevapi\Exception;
14 22
15 class CustomModuleContentLogic extends BaseLogic 23 class CustomModuleContentLogic extends BaseLogic
16 { 24 {
@@ -28,23 +36,257 @@ class CustomModuleContentLogic extends BaseLogic @@ -28,23 +36,257 @@ class CustomModuleContentLogic extends BaseLogic
28 * @method :post 36 * @method :post
29 * @time :2023/12/4 16:10 37 * @time :2023/12/4 16:10
30 */ 38 */
31 - public function getCustomModuleContentInfo(){ 39 + public function getContentInfo(){
32 $info = $this->model->read($this->param); 40 $info = $this->model->read($this->param);
33 if($info === false){ 41 if($info === false){
34 $this->fail('当前数据不存在或已被删除'); 42 $this->fail('当前数据不存在或已被删除');
35 } 43 }
  44 + $info['image_link'] = getImageUrl($info['image']);
  45 + $info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']);
36 return $this->success($info); 46 return $this->success($info);
37 } 47 }
38 48
39 /** 49 /**
  50 + * @remark :获取扩展字段详情
  51 + * @name :getExtendInfo
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2023/11/14 9:45
  55 + */
  56 + public function getExtendInfo($module_id,$content_id){
  57 + $extendModel = new CustomModuleExtend();
  58 + $list = $extendModel->list(['module_id'=>$module_id],'id',['id','type','key','title']);
  59 + if(empty($list)){
  60 + return [];
  61 + }
  62 + $extendContentModel = new CustomModuleExtentContent();
  63 + foreach ($list as $k=>$v){
  64 + $info = $extendContentModel->read(['key'=>$v['key'],'content_id'=>$content_id]);
  65 + if($info === false){
  66 + if($v['type'] == 3 || $v['type'] == 4){
  67 + $v['values'] = [];
  68 + }else{
  69 + $v['values'] = '';
  70 + }
  71 + }else{
  72 + $v = $this->setTypValues($v,$info);
  73 + }
  74 + $list[$k] = $v;
  75 + }
  76 + return $this->success($list);
  77 + }
  78 +
  79 + /**
  80 + * @remark :扩展字段根据type返回类型
  81 + * @name :setTypValues
  82 + * @author :lyh
  83 + * @method :post
  84 + * @time :2023/12/6 14:43
  85 + */
  86 + public function setTypValues($v,$info){
  87 + if($v['type'] == 3){
  88 + $arr = json_decode($info['values']);
  89 + foreach ($arr as $k1=>$v1){
  90 + $v1 = (array)$v1;
  91 + $v1['url'] = getImageUrl($v1['url']);
  92 + $arr[$k1] = $v1;
  93 + }
  94 + $v['values'] = $arr;
  95 + }elseif($v['type'] == 4){
  96 + $arr1 = json_decode($info['values']);
  97 + foreach ($arr1 as $k1=>$v1){
  98 + $v1 = getFileUrl($v1);
  99 + $arr1[$k1] = $v1;
  100 + }
  101 + $v['values'] = $arr1;
  102 + }else{
  103 + $v['values'] = $info['values'];
  104 + }
  105 + return $this->success($v);
  106 + }
  107 +
  108 + /**
40 * @remark :保存数据 109 * @remark :保存数据
41 * @name :ModuleSave 110 * @name :ModuleSave
42 * @author :lyh 111 * @author :lyh
43 * @method :post 112 * @method :post
44 * @time :2023/12/4 15:47 113 * @time :2023/12/4 15:47
45 */ 114 */
46 - public function customModuleContentSave(){ 115 + public function contentSave(){
  116 + $extend = $this->handleExtent();
  117 + $this->param = $this->handleParam($this->param);
  118 + if(isset($this->param['id']) && !empty($this->param['id'])){
  119 + $id = $this->contentEdit();
  120 + }else{
  121 + $id = $this->contentAdd();
  122 + }
  123 + //保存扩展字段
  124 + $this->saveExtendInfo($id,$extend);
  125 + return $this->success();
  126 + }
  127 +
  128 + /**
  129 + * @remark :处理扩展字段
  130 + * @name :handleExtent
  131 + * @author :lyh
  132 + * @method :post
  133 + * @time :2023/12/6 15:06
  134 + */
  135 + public function handleExtent(){
  136 + //扩展字段
  137 + $extend = [];
  138 + if(!empty($this->param['extend'])){
  139 + $extend = $this->param['extend'];
  140 + unset($this->param['extend']);
  141 + }
  142 + return $extend;
  143 + }
47 144
  145 + /**
  146 + * @remark :添加数据
  147 + * @name :contentAdd
  148 + * @author :lyh
  149 + * @method :post
  150 + * @time :2023/12/7 15:04
  151 + */
  152 + public function contentAdd(){
  153 + try {
  154 + $id = $this->model->addReturnId($this->param);
  155 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE.$this->param['module_id'],
  156 + $id, $this->user['project_id']);
  157 + $this->addUpdateNotify(RouteMap::SOURCE_MODULE.$this->param['module_id'],$route);
  158 + $this->curlDelRoute(['new_route'=>$route]);
  159 + $this->edit(['route' => $route], ['id' => $id]);
  160 + }catch (\Exception $e){
  161 + $this->fail('系统错误,请联系管理员');
  162 + }
  163 + return $id;
  164 + }
  165 +
  166 + /**
  167 + * @remark :编辑数据
  168 + * @name :contentEdit
  169 + * @author :lyh
  170 + * @method :post
  171 + * @time :2023/12/7 15:04
  172 + */
  173 + public function contentEdit(){
  174 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE.$this->param['module_id'],
  175 + $this->param['id'], $this->user['project_id']);
  176 + $this->editRoute($this->param['id'],$route);
  177 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  178 + if($rs === false){
  179 + $this->fail('系统错误,请连续管理员');
  180 + }
  181 + return $this->param['id'];
  182 + }
  183 +
  184 + /**
  185 + * @name :(参数处理)paramProcessing
  186 + * @author :lyh
  187 + * @method :post
  188 + * @time :2023/6/13 11:30
  189 + */
  190 + public function handleParam($param)
  191 + {
  192 + $param['operator_id'] = $this->user['id'];
  193 + if(!isset($param['id']) || empty($param['id'])){
  194 + $param['project_id'] = $this->user['project_id'];
  195 + }
  196 + if(isset($param['category_id']) && !empty($param['category_id'])){
  197 + $param['category_id'] = $this->getLastCategory($param['category_id']);
  198 + }
  199 + if(isset($param['image']) && !empty($param['image'])){
  200 + $param['image'] = str_replace_url($param['image']);
  201 + }
  202 + return $this->success($param);
  203 + }
  204 +
  205 + /**
  206 + * @remark :查看是否编辑路由
  207 + * @name :editCategoryRoute
  208 + * @author :lyh
  209 + * @method :post
  210 + * @time :2023/9/7 11:05
  211 + */
  212 + public function editRoute($id, $route)
  213 + {
  214 + //生成一条删除路由记录
  215 + $info = $this->model->read(['id' => $id], ['id', 'route']);
  216 + if ($info['route'] != $route) {
  217 + $this->addUpdateNotify(RouteMap::SOURCE_MODULE.$this->param['module_id'],$route);
  218 + $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
  219 + }
  220 + return true;
  221 + }
  222 +
  223 + /**
  224 + * @remark :获取最后一级分类id
  225 + * @name :getLastCategory
  226 + * @author :lyh
  227 + * @method :post
  228 + * @time :2023/10/20 9:02
  229 + */
  230 + public function getLastCategory($category){
  231 + $str = '';
  232 + $cateModel = new CustomModuleCategory();
  233 + foreach ($category as $v){
  234 + $info = $cateModel->read(['pid'=>$v]);
  235 + if($info === false){
  236 + $str .= $v.',';
  237 + }
  238 + }
  239 + return ','.$str;
  240 + }
  241 +
  242 + /**
  243 + * @remark :保存扩展字段
  244 + * @name :saveExtend
  245 + * @author :lyh
  246 + * @method :post
  247 + * @time :2023/11/9 15:02
  248 + */
  249 + public function saveExtendInfo($content_id,$extend){
  250 + //先删除以前的数据
  251 + $extendInfoModel = new ExtendInfo();
  252 + $extendInfoModel->del(['content_id'=>$content_id]);
  253 + if(empty($extend)) {
  254 + return $this->success();
  255 + }
  256 + foreach ($extend as $v){
  257 + if(empty($v['values'])){
  258 + continue;
  259 + }
  260 + $v = $this->saveHandleExtend($v,$content_id);
  261 + $extendInfoModel->add($v);
  262 + }
  263 + return $this->success();
  264 + }
  265 +
  266 + /**
  267 + * @remark :保存扩展字段时处理数据
  268 + * @name :saveHandleExtend
  269 + * @author :lyh
  270 + * @method :post
  271 + * @time :2023/12/6 15:11
  272 + */
  273 + public function saveHandleExtend(&$v,$content_id){
  274 + if($v['type'] == 3){
  275 + foreach ($v['values'] as $k1=>$v1){
  276 + $v1['url'] = str_replace_url($v1['url']);
  277 + $v['values'][$k1] = $v1;
  278 + }
  279 + $v['values'] = json_encode($v['values']);
  280 + }elseif ($v['type'] == 4){
  281 + foreach ($v['values'] as $k1=>$v1){
  282 + $v1 = str_replace_url($v1);
  283 + $v['values'][$k1] = $v1;
  284 + }
  285 + $v['values'] = json_encode($v['values']);
  286 + }
  287 + $v['project_id'] = $this->user['project_id'];
  288 + $v['content_id'] = $content_id;
  289 + return $this->success($v);
48 } 290 }
49 291
50 /** 292 /**
@@ -54,7 +296,34 @@ class CustomModuleContentLogic extends BaseLogic @@ -54,7 +296,34 @@ class CustomModuleContentLogic extends BaseLogic
54 * @method :post 296 * @method :post
55 * @time :2023/12/4 15:47 297 * @time :2023/12/4 15:47
56 */ 298 */
57 - public function customModuleContentDel(){ 299 + public function contentDel(){
  300 + DB::beginTransaction();
  301 + try {
  302 + foreach ($this->param['id'] as $id) {
  303 + $this->delRoute($id);
  304 + $this->model->del(['id' => $id]);
  305 + }
  306 + DB::commit();
  307 + } catch (Exception $e) {
  308 + DB::rollBack();
  309 + $this->fail('系统错误,请联系管理员');
  310 + }
  311 + return $this->success();
  312 + }
58 313
  314 + /**
  315 + * @remark :删除路由
  316 + * @name :delRoute
  317 + * @author :lyh
  318 + * @method :post
  319 + * @time :2023/9/7 10:50
  320 + */
  321 + public function delRoute($id)
  322 + {
  323 + RouteMap::delRoute(RouteMap::SOURCE_MODULE.$this->param['module_id'], $id, $this->user['project_id']);
  324 + //通知
  325 + $info = $this->model->read(['id' => $id], ['id', 'url']);
  326 + $this->curlDelRoute(['route'=>$info['url']]);
  327 + return $this->success();
59 } 328 }
60 } 329 }
@@ -28,8 +28,12 @@ class CustomModuleExtendLogic extends BaseLogic @@ -28,8 +28,12 @@ class CustomModuleExtendLogic extends BaseLogic
28 * @method :post 28 * @method :post
29 * @time :2023/12/4 16:10 29 * @time :2023/12/4 16:10
30 */ 30 */
31 - public function getCustomModuleExtendInfo(){  
32 - 31 + public function getExtendInfo(){
  32 + $info = $this->model->read($this->param,['id','title','status','type','operator_id','project_id','module_id']);
  33 + if($info === false){
  34 + $this->fail('当前数据不存在或者已被删除');
  35 + }
  36 + return $this->success($info);
33 } 37 }
34 38
35 /** 39 /**
@@ -39,8 +43,68 @@ class CustomModuleExtendLogic extends BaseLogic @@ -39,8 +43,68 @@ class CustomModuleExtendLogic extends BaseLogic
39 * @method :post 43 * @method :post
40 * @time :2023/12/4 15:47 44 * @time :2023/12/4 15:47
41 */ 45 */
42 - public function customModuleExtendSave(){ 46 + public function extendSave(){
  47 + if(isset($this->param['id']) && !empty($this->param['id'])){
  48 + $this->extendEdit();
  49 + }else{
  50 + $this->extendAdd();
  51 + }
  52 + return $this->success();
  53 + }
43 54
  55 + /**
  56 + * @remark :添加
  57 + * @name :extendAdd
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2023/12/7 14:09
  61 + */
  62 + public function extendAdd(){
  63 + $info = $this->model->read(['title'=>$this->param['title']]);
  64 + if($info !== false){
  65 + $this->fail('当前扩展名称已存在');
  66 + }
  67 + $key = 'pd_extended_field_';
  68 + $this->param['key'] = $this->getKey($key);
  69 + $this->param['project_id'] = $this->user['project_id'];
  70 + $this->param['operator_id'] = $this->user['id'];
  71 + $rs = $this->model->add($this->param);
  72 + if($rs === false){
  73 + $this->fail('系统错误,请联系管理员');
  74 + }
  75 + return $this->success();
  76 + }
  77 +
  78 + /**
  79 + * @remark :获取唯一key
  80 + * @name :getKey
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2023/11/9 15:55
  84 + */
  85 + public function getKey($key,$i = 1){
  86 + $info = $this->model->read(['key'=>$key.$i]);
  87 + if($info !== false){
  88 + return $this->getKey($key,$i+1);
  89 + }else{
  90 + return $key.$i;
  91 + }
  92 + }
  93 +
  94 + /**
  95 + * @remark :编辑
  96 + * @name :extendEdit
  97 + * @author :lyh
  98 + * @method :post
  99 + * @time :2023/12/7 14:09
  100 + */
  101 + public function extendEdit(){
  102 + $this->param['operator_id'] = $this->user['id'];
  103 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  104 + if($rs === false){
  105 + $this->fail('系统错误,请联系管理员');
  106 + }
  107 + return $this->success();
44 } 108 }
45 109
46 /** 110 /**
@@ -50,7 +114,11 @@ class CustomModuleExtendLogic extends BaseLogic @@ -50,7 +114,11 @@ class CustomModuleExtendLogic extends BaseLogic
50 * @method :post 114 * @method :post
51 * @time :2023/12/4 15:47 115 * @time :2023/12/4 15:47
52 */ 116 */
53 - public function customModuleExtendDel(){  
54 - 117 + public function extendDel(){
  118 + $rs = $this->model->del($this->param);
  119 + if($rs === false){
  120 + $this->fail('系统错误,请联系管理员');
  121 + }
  122 + return $this->success();
55 } 123 }
56 } 124 }
@@ -46,6 +46,7 @@ class CustomModuleLogic extends BaseLogic @@ -46,6 +46,7 @@ class CustomModuleLogic extends BaseLogic
46 * @time :2023/12/4 15:47 46 * @time :2023/12/4 15:47
47 */ 47 */
48 public function customModuleSave(){ 48 public function customModuleSave(){
  49 + $this->param = $this->handleParam($this->param);
49 if(isset($this->param['id']) && !empty($this->param['id'])){ 50 if(isset($this->param['id']) && !empty($this->param['id'])){
50 $this->moduleEdit(); 51 $this->moduleEdit();
51 }else{ 52 }else{
@@ -55,6 +56,21 @@ class CustomModuleLogic extends BaseLogic @@ -55,6 +56,21 @@ class CustomModuleLogic extends BaseLogic
55 } 56 }
56 57
57 /** 58 /**
  59 + * @name :(参数处理)paramProcessing
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/6/13 11:30
  63 + */
  64 + public function handleParam($param)
  65 + {
  66 + $param['operator_id'] = $this->user['id'];
  67 + if(!isset($param['id']) || empty($param['id'])){
  68 + $param['project_id'] = $this->user['project_id'];
  69 + }
  70 + return $this->success($param);
  71 + }
  72 +
  73 + /**
58 * @remark :新增 74 * @remark :新增
59 * @name :moduleAdd 75 * @name :moduleAdd
60 * @author :lyh 76 * @author :lyh
@@ -62,7 +78,6 @@ class CustomModuleLogic extends BaseLogic @@ -62,7 +78,6 @@ class CustomModuleLogic extends BaseLogic
62 * @time :2023/12/5 9:39 78 * @time :2023/12/5 9:39
63 */ 79 */
64 public function moduleAdd(){ 80 public function moduleAdd(){
65 - $this->param['project_id'] = $this->user['project_id'];  
66 $rs = $this->model->add($this->param); 81 $rs = $this->model->add($this->param);
67 if($rs === false){ 82 if($rs === false){
68 $this->fail('系统错误,请联系管理员'); 83 $this->fail('系统错误,请联系管理员');
@@ -287,19 +287,19 @@ class NewsLogic extends BaseLogic @@ -287,19 +287,19 @@ class NewsLogic extends BaseLogic
287 if (!$news) { 287 if (!$news) {
288 288
289 $category_id = ''; 289 $category_id = '';
290 - if ($data[2]) { 290 + if ($data[2]??'') {
291 //处理分类 291 //处理分类
292 $newsCategoryLogic = new NewsCategoryLogic(); 292 $newsCategoryLogic = new NewsCategoryLogic();
293 $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]); 293 $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
294 } 294 }
295 295
296 $text = ''; 296 $text = '';
297 - if($data[4]){ 297 + if($data[4]??''){
298 //处理内容中的图片 298 //处理内容中的图片
299 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result); 299 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result);
300 if($result[2]??[]){ 300 if($result[2]??[]){
301 foreach ($result[2] as $img){ 301 foreach ($result[2] as $img){
302 - $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); 302 + check_remote_url_down($img) && $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
303 } 303 }
304 } 304 }
305 305
@@ -307,20 +307,25 @@ class NewsLogic extends BaseLogic @@ -307,20 +307,25 @@ class NewsLogic extends BaseLogic
307 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result_video); 307 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result_video);
308 if($result_video[2]??[]){ 308 if($result_video[2]??[]){
309 foreach ($result_video[2] as $video){ 309 foreach ($result_video[2] as $video){
310 - $data[4] = str_replace($video,getImageUrl(CosService::uploadRemote($project_id,'image_news',$video)),$data[4]); 310 + check_remote_url_down($video) && $data[4] = str_replace($video,getImageUrl(CosService::uploadRemote($project_id,'image_news',$video)),$data[4]);
311 } 311 }
312 } 312 }
313 313
314 $text = $data[4]; 314 $text = $data[4];
315 } 315 }
316 316
  317 + $img = '';
  318 + if($data[5]??''){
  319 + $img = check_remote_url_down($data[5]) ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : $data[5];
  320 + }
  321 +
317 $id = $this->model->addReturnId( 322 $id = $this->model->addReturnId(
318 [ 323 [
319 'name' => $data[0], 324 'name' => $data[0],
320 'category_id' => $category_id, 325 'category_id' => $category_id,
321 'text' => $text, 326 'text' => $text,
322 'remark' => $data[3] ?? '', 327 'remark' => $data[3] ?? '',
323 - 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '', 328 + 'image' => $img,
324 'seo_title' => $data[6] ?? '', 329 'seo_title' => $data[6] ?? '',
325 'seo_keywords' => $data[7] ?? '', 330 'seo_keywords' => $data[7] ?? '',
326 'seo_description' => $data[8] ?? '', 331 'seo_description' => $data[8] ?? '',
@@ -332,7 +337,7 @@ class NewsLogic extends BaseLogic @@ -332,7 +337,7 @@ class NewsLogic extends BaseLogic
332 ] 337 ]
333 ); 338 );
334 //更新路由 339 //更新路由
335 - $route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_NEWS, $id, $project_id); 340 + $route = RouteMap::setRoute((isset($data[1]) && $data[1]) ? $data[1] : $data[0], RouteMap::SOURCE_NEWS, $id, $project_id);
336 $this->edit(['url' => $route], ['id' => $id]); 341 $this->edit(['url' => $route], ['id' => $id]);
337 342
338 return true; 343 return true;
@@ -106,6 +106,7 @@ class ProductLogic extends BaseLogic @@ -106,6 +106,7 @@ class ProductLogic extends BaseLogic
106 } 106 }
107 return $category_ids; 107 return $category_ids;
108 } 108 }
  109 +
109 /** 110 /**
110 * @remark :新增时处理字段 111 * @remark :新增时处理字段
111 * @name :addHandleParam 112 * @name :addHandleParam
@@ -599,14 +600,14 @@ class ProductLogic extends BaseLogic @@ -599,14 +600,14 @@ class ProductLogic extends BaseLogic
599 if (!$product) { 600 if (!$product) {
600 601
601 $category_id = ''; 602 $category_id = '';
602 - if ($data[2]) { 603 + if ($data[2]??'') {
603 //处理分类 604 //处理分类
604 $categoryLogic = new CategoryLogic(); 605 $categoryLogic = new CategoryLogic();
605 $category_id = $categoryLogic->importProductCategory($project_id, $data[2]); 606 $category_id = $categoryLogic->importProductCategory($project_id, $data[2]);
606 } 607 }
607 608
608 $keyword_id = ''; 609 $keyword_id = '';
609 - if($data[3]){ 610 + if($data[3]??''){
610 //处理关键词 611 //处理关键词
611 $keywordLogic = new KeywordLogic(); 612 $keywordLogic = new KeywordLogic();
612 $keyword_id = $keywordLogic->importProductKeyword($project_id, $data[3]); 613 $keyword_id = $keywordLogic->importProductKeyword($project_id, $data[3]);
@@ -614,12 +615,12 @@ class ProductLogic extends BaseLogic @@ -614,12 +615,12 @@ class ProductLogic extends BaseLogic
614 615
615 $gallery = []; 616 $gallery = [];
616 $thumb = ''; 617 $thumb = '';
617 - if($data[7]){ 618 + if($data[7]??''){
618 //处理图片 619 //处理图片
619 $img_arr = explode(',',$data[7]); 620 $img_arr = explode(',',$data[7]);
620 foreach ($img_arr as $v_img){ 621 foreach ($img_arr as $v_img){
621 if($v_img){ 622 if($v_img){
622 - $one_img = CosService::uploadRemote($project_id,'image_product',$v_img); 623 + $one_img = check_remote_url_down($v_img) ? CosService::uploadRemote($project_id,'image_product',$v_img) : $v_img;
623 if($one_img){ 624 if($one_img){
624 $one_gallery = [ 625 $one_gallery = [
625 'alt' => '这是一张产品图', 626 'alt' => '这是一张产品图',
@@ -637,12 +638,12 @@ class ProductLogic extends BaseLogic @@ -637,12 +638,12 @@ class ProductLogic extends BaseLogic
637 } 638 }
638 639
639 $intro = ''; 640 $intro = '';
640 - if($data[5]){ 641 + if($data[5]??''){
641 //处理短描述中的图片 642 //处理短描述中的图片
642 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro); 643 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro);
643 if($result_intro[2]??[]){ 644 if($result_intro[2]??[]){
644 foreach ($result_intro[2] as $vi_img){ 645 foreach ($result_intro[2] as $vi_img){
645 - $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]); 646 + check_remote_url_down($vi_img) && $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]);
646 } 647 }
647 } 648 }
648 649
@@ -650,7 +651,7 @@ class ProductLogic extends BaseLogic @@ -650,7 +651,7 @@ class ProductLogic extends BaseLogic
650 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro_video); 651 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro_video);
651 if($result_intro_video[2]??[]){ 652 if($result_intro_video[2]??[]){
652 foreach ($result_intro_video[2] as $vi_video){ 653 foreach ($result_intro_video[2] as $vi_video){
653 - $data[5] = str_replace($vi_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_video)),$data[5]); 654 + check_remote_url_down($vi_video) && $data[5] = str_replace($vi_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_video)),$data[5]);
654 } 655 }
655 } 656 }
656 657
@@ -658,12 +659,12 @@ class ProductLogic extends BaseLogic @@ -658,12 +659,12 @@ class ProductLogic extends BaseLogic
658 } 659 }
659 660
660 $content = ''; 661 $content = '';
661 - if($data[6]){ 662 + if($data[6]??''){
662 //处理内容中的图片 663 //处理内容中的图片
663 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content); 664 preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content);
664 if($result_content[2]??[]){ 665 if($result_content[2]??[]){
665 foreach ($result_content[2] as $vc_img){ 666 foreach ($result_content[2] as $vc_img){
666 - $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]); 667 + check_remote_url_down($vc_img) && $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]);
667 } 668 }
668 } 669 }
669 670
@@ -671,7 +672,7 @@ class ProductLogic extends BaseLogic @@ -671,7 +672,7 @@ class ProductLogic extends BaseLogic
671 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content_video); 672 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content_video);
672 if($result_content_video[2]??[]){ 673 if($result_content_video[2]??[]){
673 foreach ($result_content_video[2] as $vc_video){ 674 foreach ($result_content_video[2] as $vc_video){
674 - $data[6] = str_replace($vc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_video)),$data[6]); 675 + check_remote_url_down($vc_video) && $data[6] = str_replace($vc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_video)),$data[6]);
675 } 676 }
676 } 677 }
677 678
@@ -687,7 +688,7 @@ class ProductLogic extends BaseLogic @@ -687,7 +688,7 @@ class ProductLogic extends BaseLogic
687 688
688 //处理描述切换栏 689 //处理描述切换栏
689 $describe = []; 690 $describe = [];
690 - if($data[11]){ 691 + if($data[11]??''){
691 //处理描述切换栏中的图片 692 //处理描述切换栏中的图片
692 $describe = json_decode($data[11],true); 693 $describe = json_decode($data[11],true);
693 694
@@ -697,7 +698,7 @@ class ProductLogic extends BaseLogic @@ -697,7 +698,7 @@ class ProductLogic extends BaseLogic
697 698
698 if($result_desc[2]??[]){ 699 if($result_desc[2]??[]){
699 foreach ($result_desc[2] as $vdesc_img){ 700 foreach ($result_desc[2] as $vdesc_img){
700 - $v_desc['text'] = str_replace($vdesc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_img)),$v_desc['text']); 701 + check_remote_url_down($vdesc_img) && $v_desc['text'] = str_replace($vdesc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_img)),$v_desc['text']);
701 } 702 }
702 } 703 }
703 704
@@ -705,7 +706,7 @@ class ProductLogic extends BaseLogic @@ -705,7 +706,7 @@ class ProductLogic extends BaseLogic
705 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc_video); 706 preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc_video);
706 if($result_desc_video[2]??[]){ 707 if($result_desc_video[2]??[]){
707 foreach ($result_desc_video[2] as $vdesc_video){ 708 foreach ($result_desc_video[2] as $vdesc_video){
708 - $v_desc['text'] = str_replace($vdesc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_video)),$v_desc['text']); 709 + check_remote_url_down($vdesc_video) && $v_desc['text'] = str_replace($vdesc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_video)),$v_desc['text']);
709 } 710 }
710 } 711 }
711 } 712 }
@@ -729,7 +730,7 @@ class ProductLogic extends BaseLogic @@ -729,7 +730,7 @@ class ProductLogic extends BaseLogic
729 ] 730 ]
730 ); 731 );
731 //更新路由 732 //更新路由
732 - $route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id); 733 + $route = RouteMap::setRoute((isset($data[1]) && $data[1]) ? $data[1] : $data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id);
733 $this->edit(['route' => $route], ['id' => $id]); 734 $this->edit(['route' => $route], ['id' => $id]);
734 735
735 return true; 736 return true;
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Models\CustomModule; 10 namespace App\Models\CustomModule;
11 11
  12 +use App\Helper\Arr;
12 use App\Models\Base; 13 use App\Models\Base;
13 14
14 class CustomModuleContent extends Base 15 class CustomModuleContent extends Base
@@ -16,4 +17,8 @@ class CustomModuleContent extends Base @@ -16,4 +17,8 @@ class CustomModuleContent extends Base
16 protected $table = 'gl_custom_module_content'; 17 protected $table = 'gl_custom_module_content';
17 //连接数据库 18 //连接数据库
18 protected $connection = 'custom_mysql'; 19 protected $connection = 'custom_mysql';
  20 +
  21 + public function getCategoryIdAttribute($value){
  22 + return Arr::setToArr(trim($value,','));
  23 + }
19 } 24 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleExtentContent.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/7 14:38
  8 + */
  9 +
  10 +namespace App\Models\CustomModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class CustomModuleExtentContent extends Base
  15 +{
  16 + protected $table = 'gl_custom_module_extent_content';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
@@ -60,9 +60,20 @@ class RouteMap extends Base @@ -60,9 +60,20 @@ class RouteMap extends Base
60 } 60 }
61 $i=1; 61 $i=1;
62 $sign = generateRoute($title); 62 $sign = generateRoute($title);
63 - $route = $sign;  
64 - while(self::isExist($route, $source, $source_id, $project_id)){  
65 - $route = $sign .'-'.$i; 63 + $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
  64 + if($info === false){
  65 + if($source == self::SOURCE_PRODUCT_KEYWORD){
  66 + $suffix = '-tag';
  67 + }
  68 + if($source == self::SOURCE_PRODUCT){
  69 + $suffix = '-product';
  70 + }
  71 + }else{
  72 + $suffix = '';
  73 + }
  74 + $route = $sign.$suffix;
  75 + while(self::isExist($route, $source_id, $project_id)){
  76 + $route = $sign .'-'.$i.$suffix;
66 $i++; 77 $i++;
67 } 78 }
68 return $route; 79 return $route;
@@ -78,22 +89,13 @@ class RouteMap extends Base @@ -78,22 +89,13 @@ class RouteMap extends Base
78 * @author zbj 89 * @author zbj
79 * @date 2023/4/17 90 * @date 2023/4/17
80 */ 91 */
81 - protected static function isExist($route, $source, $source_id, $project_id){ 92 + protected static function isExist($route, $source_id, $project_id){
82 $fixed = ['search','api']; //固定的路由 93 $fixed = ['search','api']; //固定的路由
83 if(in_array($route, $fixed)){ 94 if(in_array($route, $fixed)){
84 return true; 95 return true;
85 } 96 }
86 - $path = '';  
87 - if($source == self::SOURCE_NEWS){  
88 - $path = self::SOURCE_NEWS;  
89 - }elseif ($source == self::SOURCE_BLOG){  
90 - $path = self::SOURCE_BLOG.'s';  
91 - }  
92 -  
93 $where = [ 97 $where = [
94 - 'project_id' => $project_id,  
95 - 'route' => $route,  
96 - 'path' => $path, 98 + 'project_id' => $project_id, 'route' => $route,
97 ]; 99 ];
98 $route = self::where($where)->first(); 100 $route = self::where($where)->first();
99 if($route){ 101 if($route){
@@ -122,25 +124,11 @@ class RouteMap extends Base @@ -122,25 +124,11 @@ class RouteMap extends Base
122 } 124 }
123 try { 125 try {
124 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); 126 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first();
125 - //上线项目 不能修改链接了  
126 -// if($route_map){  
127 -// $project = ProjectLogic::instance()->getInfo($project_id);  
128 -// if($project['type'] !== Project::STATUS_ONE){  
129 -// return $route_map->route;  
130 -// }  
131 -// }  
132 if(!$route_map){ 127 if(!$route_map){
133 $route_map = new self(); 128 $route_map = new self();
134 $route_map->source = $source; 129 $route_map->source = $source;
135 $route_map->source_id = $source_id; 130 $route_map->source_id = $source_id;
136 $route_map->project_id = $project_id; 131 $route_map->project_id = $project_id;
137 - if ($source == self::SOURCE_PRODUCT_KEYWORD){  
138 - $route = self::setKeywordRoute($route);  
139 - //查看当前路由是否存在  
140 - }elseif ($source == self::SOURCE_PRODUCT){  
141 - //产品单独处理路由  
142 - $route = self::setProductRoute($route);  
143 - }  
144 } 132 }
145 if($source == self::SOURCE_NEWS){ 133 if($source == self::SOURCE_NEWS){
146 $route_map->path = self::SOURCE_NEWS; 134 $route_map->path = self::SOURCE_NEWS;
@@ -156,45 +144,43 @@ class RouteMap extends Base @@ -156,45 +144,43 @@ class RouteMap extends Base
156 } 144 }
157 145
158 146
159 - /**  
160 - * @remark :产品新增单独处理路由  
161 - * @name :setProductRoute  
162 - * @author :lyh  
163 - * @method :post  
164 - * @time :2023/11/21 18:48  
165 - */  
166 - public static function setProductRoute($route,$i = 0){  
167 - $routes = $route.'-product';  
168 - $routeMapModel = new RouteMap();  
169 - $routeInfo = $routeMapModel->read(['route'=>$routes]);  
170 - if($routeInfo === false){  
171 - return $routes;  
172 - }else{  
173 - $i = $i + 1;  
174 - $route = $route.'-'.$i;  
175 - return self::setProductRoute($route,$i);  
176 - }  
177 - }  
178 -  
179 - /**  
180 - * @remark :关键字新增单独处理路由  
181 - * @name :setProductRoute  
182 - * @author :lyh  
183 - * @method :post  
184 - * @time :2023/11/21 18:48  
185 - */  
186 - public static function setKeywordRoute($route,$i = 0){  
187 - $routes = $route.'-tag';  
188 - $routeMapModel = new RouteMap();  
189 - $routeInfo = $routeMapModel->read(['route'=>$routes]);  
190 - if($routeInfo === false){  
191 - return $routes;  
192 - }else{  
193 - $i = $i + 1;  
194 - $route = $route.'-'.$i;  
195 - return self::setProductRoute($route,$i);  
196 - }  
197 - } 147 +// /**
  148 +// * @remark :产品新增单独处理路由
  149 +// * @name :setProductRoute
  150 +// * @author :lyh
  151 +// * @method :post
  152 +// * @time :2023/11/21 18:48
  153 +// */
  154 +// public static function setProductRoute($route,$i = 0){
  155 +// $routes = $route.'-'.$i.'-product';
  156 +// $routeMapModel = new RouteMap();
  157 +// $routeInfo = $routeMapModel->read(['route'=>$routes]);
  158 +// if($routeInfo === false){
  159 +// return $routes;
  160 +// }else{
  161 +// $i = $i + 1;
  162 +// return self::setProductRoute($route,$i);
  163 +// }
  164 +// }
  165 +//
  166 +// /**
  167 +// * @remark :关键字新增单独处理路由
  168 +// * @name :setProductRoute
  169 +// * @author :lyh
  170 +// * @method :post
  171 +// * @time :2023/11/21 18:48
  172 +// */
  173 +// public static function setKeywordRoute($route,$i = 0){
  174 +// $routes = $route.'-'.$i.'-tag';
  175 +// $routeMapModel = new RouteMap();
  176 +// $routeInfo = $routeMapModel->read(['route'=>$routes]);
  177 +// if($routeInfo === false){
  178 +// return $routes;
  179 +// }else{
  180 +// $i = $i + 1;
  181 +// return self::setKeywordRoute($route,$i);
  182 +// }
  183 +// }
198 184
199 /** 185 /**
200 * @param $route 186 * @param $route
@@ -440,10 +440,18 @@ Route::middleware(['bloginauth'])->group(function () { @@ -440,10 +440,18 @@ Route::middleware(['bloginauth'])->group(function () {
440 440
441 Route::prefix('content')->group(function () { 441 Route::prefix('content')->group(function () {
442 Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists'); 442 Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists');
  443 + Route::any('/getCategoryList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCategoryList'])->name('custom_content_getCategoryList');
443 Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info'); 444 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('/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 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
446 }); 447 });
  448 +
  449 + Route::prefix('extend')->group(function () {
  450 + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleExtentController::class, 'lists'])->name('custom_extend_lists');
  451 + Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleExtentController::class, 'info'])->name('custom_extend_info');
  452 + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleExtentController::class, 'save'])->name('custom_extend_save');
  453 + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleExtentController::class, 'del'])->name('custom_extend_del');
  454 + });
447 }); 455 });
448 }); 456 });
449 //无需登录验证的路由组 457 //无需登录验证的路由组