作者 张关杰

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

@@ -149,6 +149,11 @@ class ProjectUpdate extends Command @@ -149,6 +149,11 @@ class ProjectUpdate extends Command
149 foreach ($items as $item) { 149 foreach ($items as $item) {
150 $route = $this->get_url_route($item['url'] ?? ''); 150 $route = $this->get_url_route($item['url'] ?? '');
151 if ($route) { 151 if ($route) {
  152 + //判断路由是否存在
  153 + $route_info = RouteMap::where('project_id', $project_id)->where('route', $route)->where('path', '')->first();
  154 + if ($route_info) {
  155 + continue;
  156 + }
152 $keyword = $model->read(['route' => $route], 'id'); 157 $keyword = $model->read(['route' => $route], 'id');
153 if (!$keyword) { 158 if (!$keyword) {
154 try { 159 try {
@@ -59,11 +59,11 @@ class UpdateMainHtml extends Command @@ -59,11 +59,11 @@ class UpdateMainHtml extends Command
59 */ 59 */
60 public function handle(){ 60 public function handle(){
61 $projectModel = new Project(); 61 $projectModel = new Project();
62 - $list = $projectModel->list(['id'=>99]); 62 + $list = $projectModel->list(['id'=>223]);
63 foreach ($list as $v){ 63 foreach ($list as $v){
64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
65 ProjectServer::useProject($v['id']); 65 ProjectServer::useProject($v['id']);
66 - $this->editRoute(); 66 + $this->setBlogCustomContent();
67 DB::disconnect('custom_mysql'); 67 DB::disconnect('custom_mysql');
68 } 68 }
69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
@@ -85,8 +85,8 @@ class UpdateMainHtml extends Command @@ -85,8 +85,8 @@ class UpdateMainHtml extends Command
85 $data[] = [ 85 $data[] = [
86 'name'=>$v['name'], 86 'name'=>$v['name'],
87 'route'=>$v['alias'], 87 'route'=>$v['alias'],
88 - 'project_id'=>99,  
89 - 'operator_id'=>366, 88 + 'project_id'=>223,
  89 + 'operator_id'=>569,
90 'seo_title'=>$v['seo_title'], 90 'seo_title'=>$v['seo_title'],
91 'seo_keywords'=>$v['seo_keywords'], 91 'seo_keywords'=>$v['seo_keywords'],
92 'seo_description'=>$v['seo_des'], 92 'seo_description'=>$v['seo_des'],
@@ -118,8 +118,8 @@ class UpdateMainHtml extends Command @@ -118,8 +118,8 @@ class UpdateMainHtml extends Command
118 'remark'=>$v['remark'], 118 'remark'=>$v['remark'],
119 'route'=>$v['url'], 119 'route'=>$v['url'],
120 'image'=>$v['image'], 120 'image'=>$v['image'],
121 - 'project_id'=>99,  
122 - 'operator_id'=>366, 121 + 'project_id'=>223,
  122 + 'operator_id'=>569,
123 'seo_title'=>$v['seo_title'], 123 'seo_title'=>$v['seo_title'],
124 'seo_keywords'=>$v['seo_keywords'], 124 'seo_keywords'=>$v['seo_keywords'],
125 'seo_description'=>$v['seo_description'], 125 'seo_description'=>$v['seo_description'],
@@ -51,14 +51,14 @@ class UpdateRoute extends Command @@ -51,14 +51,14 @@ class UpdateRoute extends Command
51 */ 51 */
52 public function handle(){ 52 public function handle(){
53 $projectModel = new Project(); 53 $projectModel = new Project();
54 - $list = $projectModel->list(['id'=>475]); 54 + $list = $projectModel->list(['id'=>183]);
55 foreach ($list as $v){ 55 foreach ($list as $v){
56 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 56 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
57 ProjectServer::useProject($v['id']); 57 ProjectServer::useProject($v['id']);
58 // $this->getProduct(); 58 // $this->getProduct();
59 -// $this->setProductKeyword(); 59 + $this->setProductKeyword();
60 // $this->getRouteMap(); 60 // $this->getRouteMap();
61 - $this->getProductCategory(); 61 +// $this->getProductCategory();
62 DB::disconnect('custom_mysql'); 62 DB::disconnect('custom_mysql');
63 } 63 }
64 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 64 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
@@ -101,24 +101,24 @@ class UpdateRoute extends Command @@ -101,24 +101,24 @@ class UpdateRoute extends Command
101 * @method :post 101 * @method :post
102 * @time :2023/12/8 11:13 102 * @time :2023/12/8 11:13
103 */ 103 */
104 -// public function getProductKeyword(){  
105 -// $keywordModel = new Keyword();  
106 -// $lists = $keywordModel->list(['status'=>1,'route'=>'']);  
107 -// if(!empty($lists)){  
108 -// foreach ($lists as $v){  
109 -// $tag = "-tag";  
110 -// if (!(substr($v['route'], -strlen($tag)) === $tag)) {  
111 -// echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;  
112 -// $route = $v['route'].$tag;  
113 -// // 如果不是以 '-tag' 结尾,则拼接上 '-tag'  
114 -// $routeModel = new RouteMap();  
115 -// $routeModel->edit(['route'=>$route],['source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,'source_id'=>$v['id']]);  
116 -// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);  
117 -// echo date('Y-m-d H:i:s') . 'end'.$v['id'] . PHP_EOL;  
118 -// }  
119 -// }  
120 -// }  
121 -// } 104 + public function getProductKeyword(){
  105 + $keywordModel = new Keyword();
  106 + $lists = $keywordModel->list(['status'=>1,'route'=>'']);
  107 + if(!empty($lists)){
  108 + foreach ($lists as $v){
  109 + $tag = "-tag";
  110 + if (!(substr($v['route'], -strlen($tag)) === $tag)) {
  111 + echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;
  112 + $route = $v['route'].$tag;
  113 + // 如果不是以 '-tag' 结尾,则拼接上 '-tag'
  114 + $routeModel = new RouteMap();
  115 + $routeModel->edit(['route'=>$route],['source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,'source_id'=>$v['id']]);
  116 + $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
  117 + echo date('Y-m-d H:i:s') . 'end'.$v['id'] . PHP_EOL;
  118 + }
  119 + }
  120 + }
  121 + }
122 122
123 public function getProduct(){ 123 public function getProduct(){
124 $productModel = new Product(); 124 $productModel = new Product();
@@ -49,12 +49,15 @@ class CustomModuleLogic extends BaseLogic @@ -49,12 +49,15 @@ class CustomModuleLogic extends BaseLogic
49 * @time :2023/12/4 15:47 49 * @time :2023/12/4 15:47
50 */ 50 */
51 public function customModuleSave(){ 51 public function customModuleSave(){
  52 + ProjectServer::useProject($this->param['project_id']);
52 $this->param = $this->handleParam($this->param); 53 $this->param = $this->handleParam($this->param);
  54 + $this->checkIsName($this->param['name'],$this->param['id'] ?? 0);
53 if(isset($this->param['id']) && !empty($this->param['id'])){ 55 if(isset($this->param['id']) && !empty($this->param['id'])){
54 $this->moduleEdit(); 56 $this->moduleEdit();
55 }else{ 57 }else{
56 $this->moduleAdd(); 58 $this->moduleAdd();
57 } 59 }
  60 + DB::disconnect('custom_mysql');
58 return $this->success(); 61 return $this->success();
59 } 62 }
60 63
@@ -81,12 +84,10 @@ class CustomModuleLogic extends BaseLogic @@ -81,12 +84,10 @@ class CustomModuleLogic extends BaseLogic
81 * @time :2023/12/5 9:39 84 * @time :2023/12/5 9:39
82 */ 85 */
83 public function moduleAdd(){ 86 public function moduleAdd(){
84 - ProjectServer::useProject($this->param['project_id']);  
85 $rs = (new CustomModule())->add($this->param); 87 $rs = (new CustomModule())->add($this->param);
86 if($rs === false){ 88 if($rs === false){
87 $this->fail('系统错误,请联系管理员'); 89 $this->fail('系统错误,请联系管理员');
88 } 90 }
89 - DB::disconnect('custom_mysql');  
90 return $this->success(); 91 return $this->success();
91 } 92 }
92 93
@@ -98,16 +99,32 @@ class CustomModuleLogic extends BaseLogic @@ -98,16 +99,32 @@ class CustomModuleLogic extends BaseLogic
98 * @time :2023/12/5 9:39 99 * @time :2023/12/5 9:39
99 */ 100 */
100 public function moduleEdit(){ 101 public function moduleEdit(){
101 - ProjectServer::useProject($this->param['project_id']);  
102 $rs = (new CustomModule())->edit($this->param,['id'=>$this->param['id']]); 102 $rs = (new CustomModule())->edit($this->param,['id'=>$this->param['id']]);
103 if($rs === false){ 103 if($rs === false){
104 $this->fail('系统错误,请联系管理员'); 104 $this->fail('系统错误,请联系管理员');
105 } 105 }
106 - DB::disconnect('custom_mysql');  
107 return $this->success(); 106 return $this->success();
108 } 107 }
109 108
110 /** 109 /**
  110 + * @remark :验证名称是否存在
  111 + * @name :checkIsName
  112 + * @author :lyh
  113 + * @method :post
  114 + * @time :2024/1/6 14:06
  115 + */
  116 + public function checkIsName($name,$id = 0){
  117 + $param['name'] = $name;
  118 + if(!empty($id)){
  119 + $param['id'] = ['id'=>['!=',$id],];
  120 + }
  121 + $info = (new CustomModule())->read($param);
  122 + if($info !== false){
  123 + $this->fail('当前名称已存在');
  124 + }
  125 + return $this->success();
  126 + }
  127 + /**
111 * @remark :删除数据 128 * @remark :删除数据
112 * @name :ModuleDel 129 * @name :ModuleDel
113 * @author :lyh 130 * @author :lyh
@@ -148,14 +148,16 @@ class KeywordLogic extends BaseLogic @@ -148,14 +148,16 @@ class KeywordLogic extends BaseLogic
148 $this->model = new Keyword(); 148 $this->model = new Keyword();
149 $info = $this->model->read(['title'=>$v]); 149 $info = $this->model->read(['title'=>$v]);
150 if($info === false){ 150 if($info === false){
  151 + $route = $this->specialRouteCheck($v);
151 $param['project_id'] = $this->user['project_id']; 152 $param['project_id'] = $this->user['project_id'];
152 $param['created_at'] = date('Y-m-d H:i:s'); 153 $param['created_at'] = date('Y-m-d H:i:s');
153 $param['updated_at'] = $param['created_at']; 154 $param['updated_at'] = $param['created_at'];
154 $param['title'] = $v; 155 $param['title'] = $v;
  156 + $param['route'] = $route;
155 $id = $this->model->insertGetId($param); 157 $id = $this->model->insertGetId($param);
156 - $route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);  
157 -// $this->curlDelRoute(['new_route'=>$route]);  
158 - $this->model->edit(['route'=>$route],['id'=>$id]); 158 + $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
  159 +//// $this->curlDelRoute(['new_route'=>$route]);
  160 +// $this->model->edit(['route'=>$route],['id'=>$id]);
159 } 161 }
160 } 162 }
161 }catch (\Exception $e){ 163 }catch (\Exception $e){
@@ -165,6 +167,32 @@ class KeywordLogic extends BaseLogic @@ -165,6 +167,32 @@ class KeywordLogic extends BaseLogic
165 } 167 }
166 168
167 /** 169 /**
  170 + * @remark :
  171 + * @name :specialRouteCheck
  172 + * @author :lyh
  173 + * @method :post
  174 + * @time :2024/1/6 14:50
  175 + */
  176 + public function specialRouteCheck($title)
  177 + {
  178 + if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
  179 + $title = Translate::tran($title, 'en');
  180 + }
  181 + $suffix = '-tag';
  182 + $i = 1;
  183 + $sign = generateRoute($title);
  184 + $route = $sign . $suffix;
  185 + resetRoute:
  186 + $log = RouteMap::getRouteInfo($route, $this->user['project_id']);
  187 + if ($log) {
  188 + $route = $sign .'-'.$i.$suffix;
  189 + $i++;
  190 + goto resetRoute;
  191 + }
  192 + return $route;
  193 + }
  194 +
  195 + /**
168 * @remark :删除标签 196 * @remark :删除标签
169 * @name :keywordDelete 197 * @name :keywordDelete
170 * @author :lyh 198 * @author :lyh
@@ -199,7 +227,9 @@ class KeywordLogic extends BaseLogic @@ -199,7 +227,9 @@ class KeywordLogic extends BaseLogic
199 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); 227 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
200 //生成一条删除路由记录 228 //生成一条删除路由记录
201 $info = $this->model->read(['id'=>$id],['id','route']); 229 $info = $this->model->read(['id'=>$id],['id','route']);
202 - $this->curlDelRoute(['route'=>$info['route']]); 230 + if($info !== false){
  231 + $this->curlDelRoute(['route'=>$info['route']]);
  232 + }
203 return $this->success(); 233 return $this->success();
204 } 234 }
205 235