Merge remote-tracking branch 'origin/master' into akun
正在显示
6 个修改的文件
包含
91 行增加
和
29 行删除
| @@ -35,20 +35,22 @@ class Translate extends Command | @@ -35,20 +35,22 @@ class Translate extends Command | ||
| 35 | protected $description = 'translate'; | 35 | protected $description = 'translate'; |
| 36 | public function handle(){ | 36 | public function handle(){ |
| 37 | $projectModel = new Project(); | 37 | $projectModel = new Project(); |
| 38 | - $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0],'id'=>['<=',1194]]); | 38 | + $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0],'id'=>['<=',451]]); |
| 39 | foreach ($list as $v){ | 39 | foreach ($list as $v){ |
| 40 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 40 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| 41 | ProjectServer::useProject($v['id']); | 41 | ProjectServer::useProject($v['id']); |
| 42 | $translateModel = new \App\Models\WebSetting\Translate(); | 42 | $translateModel = new \App\Models\WebSetting\Translate(); |
| 43 | $translateList = $translateModel->list([],'id',['id','url']); | 43 | $translateList = $translateModel->list([],'id',['id','url']); |
| 44 | - foreach ($translateList as $value){ | ||
| 45 | - echo date('Y-m-d H:i:s') . '数据路由:'.$value['url'] . PHP_EOL; | ||
| 46 | - $data = $this->getRouteSource($value['url']); | ||
| 47 | - if($data === false){ | ||
| 48 | - continue; | 44 | + if(!empty($translateList)){ |
| 45 | + foreach ($translateList as $value){ | ||
| 46 | + echo date('Y-m-d H:i:s') . '数据路由:'.$value['url'] . PHP_EOL; | ||
| 47 | + $data = $this->getRouteSource($value['url']); | ||
| 48 | + if($data === false){ | ||
| 49 | + continue; | ||
| 50 | + } | ||
| 51 | + $rs = $translateModel->edit($data,['id'=>$value['id']]); | ||
| 52 | + gc_collect_cycles(); | ||
| 49 | } | 53 | } |
| 50 | - $rs = $translateModel->edit($data,['id'=>$value['id']]); | ||
| 51 | - gc_collect_cycles(); | ||
| 52 | } | 54 | } |
| 53 | DB::disconnect('custom_mysql'); | 55 | DB::disconnect('custom_mysql'); |
| 54 | } | 56 | } |
| @@ -71,7 +73,7 @@ class Translate extends Command | @@ -71,7 +73,7 @@ class Translate extends Command | ||
| 71 | $data['source'] = 1; | 73 | $data['source'] = 1; |
| 72 | return $data; | 74 | return $data; |
| 73 | } | 75 | } |
| 74 | - $route = basename($route); | 76 | + $route = $this->handleRoute($route); |
| 75 | $routeModel = new RouteMap(); | 77 | $routeModel = new RouteMap(); |
| 76 | $routeInfo = $routeModel->read(['route'=>$route]); | 78 | $routeInfo = $routeModel->read(['route'=>$route]); |
| 77 | if($routeInfo === false){ | 79 | if($routeInfo === false){ |
| @@ -81,6 +83,46 @@ class Translate extends Command | @@ -81,6 +83,46 @@ class Translate extends Command | ||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | /** | 85 | /** |
| 86 | + * @remark :处理路由 | ||
| 87 | + * @name :handleRoute | ||
| 88 | + * @author :lyh | ||
| 89 | + * @method :post | ||
| 90 | + * @time :2024/1/18 17:25 | ||
| 91 | + */ | ||
| 92 | + public function handleRoute($url){ | ||
| 93 | + $str = trim($url,'/'); | ||
| 94 | + $route = 'index'; | ||
| 95 | + if(!empty($str)){ | ||
| 96 | + $arr = explode('/',$str); | ||
| 97 | + $num = count($arr); | ||
| 98 | + if($num == 1){ | ||
| 99 | + $route = $arr[0]; | ||
| 100 | + }elseif ($num == 2){ | ||
| 101 | + if(ctype_digit($arr[1])){//是数字的情况 | ||
| 102 | + $route = $arr[0]; | ||
| 103 | + }else{ | ||
| 104 | + $route = $arr[1]; | ||
| 105 | + } | ||
| 106 | + }elseif($num == 3){ | ||
| 107 | + if(ctype_digit($arr[2])){//是数字的情况 | ||
| 108 | + $route = $arr[0]; | ||
| 109 | + }else{ | ||
| 110 | + if($arr[2] == 'page'){ | ||
| 111 | + $route = $arr[1]; | ||
| 112 | + }else{ | ||
| 113 | + $route = $arr[0]; | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + }elseif ($num == 4){ | ||
| 117 | + if(ctype_digit($arr[3])){//是数字的情况 | ||
| 118 | + $route = $arr[1]; | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + return $route; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 84 | * @remark :返回数据 | 126 | * @remark :返回数据 |
| 85 | * @name :resultData | 127 | * @name :resultData |
| 86 | * @author :lyh | 128 | * @author :lyh |
| @@ -54,6 +54,9 @@ class VisitController extends BaseController | @@ -54,6 +54,9 @@ class VisitController extends BaseController | ||
| 54 | * @time :2024/5/6 16:42 | 54 | * @time :2024/5/6 16:42 |
| 55 | */ | 55 | */ |
| 56 | public function downloadIndex(VisitLogic $logic){ | 56 | public function downloadIndex(VisitLogic $logic){ |
| 57 | + if(isset($this->map['updated_date']) && is_array($this->map['updated_date'])){ | ||
| 58 | + $this->map['updated_date'] = ['between',$this->map['updated_date']]; | ||
| 59 | + } | ||
| 57 | $data = $logic->downloadItem($this->map,$this->page,$this->row,$this->order); | 60 | $data = $logic->downloadItem($this->map,$this->page,$this->row,$this->order); |
| 58 | $this->response('success',Code::SUCCESS,$data); | 61 | $this->response('success',Code::SUCCESS,$data); |
| 59 | } | 62 | } |
| @@ -134,7 +134,7 @@ class FileController | @@ -134,7 +134,7 @@ class FileController | ||
| 134 | $amazonS3Service->uploadFiles($files,$this->path,$fileName); | 134 | $amazonS3Service->uploadFiles($files,$this->path,$fileName); |
| 135 | } | 135 | } |
| 136 | $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); | 136 | $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); |
| 137 | - $this->synchronizationFile($fileName); | 137 | + $this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0); |
| 138 | $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); | 138 | $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| @@ -145,9 +145,9 @@ class FileController | @@ -145,9 +145,9 @@ class FileController | ||
| 145 | * @method :post | 145 | * @method :post |
| 146 | * @time :2024/4/8 11:10 | 146 | * @time :2024/4/8 11:10 |
| 147 | */ | 147 | */ |
| 148 | - public function synchronizationFile($fileName){ | 148 | + public function synchronizationFile($fileName,$location){ |
| 149 | //同步到大文件 | 149 | //同步到大文件 |
| 150 | - SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]); | 150 | + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]); |
| 151 | return true; | 151 | return true; |
| 152 | } | 152 | } |
| 153 | 153 | ||
| @@ -303,7 +303,7 @@ class FileController | @@ -303,7 +303,7 @@ class FileController | ||
| 303 | $mime = $file->getMimeType(); | 303 | $mime = $file->getMimeType(); |
| 304 | $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name); | 304 | $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name); |
| 305 | $data[] = $this->responseData($this->path.'/'.$fileName, $name); | 305 | $data[] = $this->responseData($this->path.'/'.$fileName, $name); |
| 306 | - $this->synchronizationFile($fileName); | 306 | + $this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0); |
| 307 | } | 307 | } |
| 308 | $this->response('资源',Code::SUCCESS,$data); | 308 | $this->response('资源',Code::SUCCESS,$data); |
| 309 | } | 309 | } |
| @@ -41,7 +41,7 @@ class ImageController extends Controller | @@ -41,7 +41,7 @@ class ImageController extends Controller | ||
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | - public $upload_location = 0;//同步到cos | 44 | + public $upload_location = 0;//1:上传到cos |
| 45 | //上传图片类型 | 45 | //上传图片类型 |
| 46 | public $image_type = [ | 46 | public $image_type = [ |
| 47 | 1 => 'image_product', | 47 | 1 => 'image_product', |
| @@ -215,7 +215,7 @@ class ImageController extends Controller | @@ -215,7 +215,7 @@ class ImageController extends Controller | ||
| 215 | $amazonS3Service->uploadFiles($files,$this->path,$fileName); | 215 | $amazonS3Service->uploadFiles($files,$this->path,$fileName); |
| 216 | } | 216 | } |
| 217 | $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); | 217 | $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); |
| 218 | - $this->synchronizationImage($fileName); | 218 | + $this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0); |
| 219 | return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); | 219 | return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| @@ -264,8 +264,8 @@ class ImageController extends Controller | @@ -264,8 +264,8 @@ class ImageController extends Controller | ||
| 264 | * @method :post | 264 | * @method :post |
| 265 | * @time :2024/4/8 11:10 | 265 | * @time :2024/4/8 11:10 |
| 266 | */ | 266 | */ |
| 267 | - public function synchronizationImage($fileName){ | ||
| 268 | - SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]); | 267 | + public function synchronizationImage($fileName,$location){ |
| 268 | + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]); | ||
| 269 | return true; | 269 | return true; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| @@ -347,7 +347,7 @@ class ImageController extends Controller | @@ -347,7 +347,7 @@ class ImageController extends Controller | ||
| 347 | } | 347 | } |
| 348 | //批量存储 | 348 | //批量存储 |
| 349 | $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); | 349 | $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); |
| 350 | - $this->synchronizationImage($fileName); | 350 | + $this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0); |
| 351 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); | 351 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); |
| 352 | } | 352 | } |
| 353 | $this->response('图片资源',Code::SUCCESS,$data); | 353 | $this->response('图片资源',Code::SUCCESS,$data); |
| @@ -472,8 +472,9 @@ class ImageController extends Controller | @@ -472,8 +472,9 @@ class ImageController extends Controller | ||
| 472 | //根据项目上传标识区分上传到cos/本地 | 472 | //根据项目上传标识区分上传到cos/本地 |
| 473 | $projectModel = new Project(); | 473 | $projectModel = new Project(); |
| 474 | $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']); | 474 | $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']); |
| 475 | - if ($project_info['project_location'] != 0) {//危险项目时 上传到本地 | ||
| 476 | - $this->upload_location = 1;//上传到本地 | 475 | + if ($project_info['project_location'] != 0) { |
| 476 | + //TODO::危险项目时 | ||
| 477 | + $this->upload_location = 1;//上传到cos | ||
| 477 | } | 478 | } |
| 478 | } | 479 | } |
| 479 | $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); | 480 | $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); |
| @@ -65,7 +65,7 @@ class TranslateLogic extends BaseLogic | @@ -65,7 +65,7 @@ class TranslateLogic extends BaseLogic | ||
| 65 | } | 65 | } |
| 66 | $arr2 = []; | 66 | $arr2 = []; |
| 67 | foreach ($text_array as $val) { | 67 | foreach ($text_array as $val) { |
| 68 | - if($val == ' '){ | 68 | + if($val == ' ' || $val == ''){ |
| 69 | continue; | 69 | continue; |
| 70 | } | 70 | } |
| 71 | if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){ | 71 | if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){ |
| @@ -256,10 +256,12 @@ class TranslateLogic extends BaseLogic | @@ -256,10 +256,12 @@ class TranslateLogic extends BaseLogic | ||
| 256 | } | 256 | } |
| 257 | $this->param['data'] = $data; | 257 | $this->param['data'] = $data; |
| 258 | } | 258 | } |
| 259 | -// try { | 259 | + //解析路由 |
| 260 | + $sendData = $this->handleRoute($this->param['url']); | ||
| 261 | + try { | ||
| 260 | $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | 262 | $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); |
| 261 | if($info === false){ | 263 | if($info === false){ |
| 262 | - $sourceInfo = $this->getRouteSource($this->param['url']); | 264 | + $sourceInfo = $this->getRouteSource($sendData['new_route']); |
| 263 | $param = [ | 265 | $param = [ |
| 264 | 'type'=>$this->param['type'], | 266 | 'type'=>$this->param['type'], |
| 265 | 'project_id'=>$this->user['project_id'], | 267 | 'project_id'=>$this->user['project_id'], |
| @@ -282,10 +284,10 @@ class TranslateLogic extends BaseLogic | @@ -282,10 +284,10 @@ class TranslateLogic extends BaseLogic | ||
| 282 | //写日志 | 284 | //写日志 |
| 283 | $userLogModel = new UserLog(); | 285 | $userLogModel = new UserLog(); |
| 284 | $userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]); | 286 | $userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]); |
| 285 | -// }catch (\Exception $e){ | ||
| 286 | -// $this->fail('系统错误请联系管理员'); | ||
| 287 | -// } | ||
| 288 | - $this->handleRoute($this->param['url']); | 287 | + }catch (\Exception $e){ |
| 288 | + $this->fail('系统错误请联系管理员'); | ||
| 289 | + } | ||
| 290 | + $this->sendMessage($sendData); | ||
| 289 | return $this->success(); | 291 | return $this->success(); |
| 290 | } | 292 | } |
| 291 | 293 | ||
| @@ -308,6 +310,9 @@ class TranslateLogic extends BaseLogic | @@ -308,6 +310,9 @@ class TranslateLogic extends BaseLogic | ||
| 308 | $route = basename($route); | 310 | $route = basename($route); |
| 309 | $routeModel = new RouteMap(); | 311 | $routeModel = new RouteMap(); |
| 310 | $routeInfo = $routeModel->read(['route'=>$route]); | 312 | $routeInfo = $routeModel->read(['route'=>$route]); |
| 313 | + if($routeInfo === false){ | ||
| 314 | + return $data; | ||
| 315 | + } | ||
| 311 | return $this->resultData($routeInfo,$data); | 316 | return $this->resultData($routeInfo,$data); |
| 312 | } | 317 | } |
| 313 | 318 | ||
| @@ -415,6 +420,17 @@ class TranslateLogic extends BaseLogic | @@ -415,6 +420,17 @@ class TranslateLogic extends BaseLogic | ||
| 415 | $data['new_route'] = $route; | 420 | $data['new_route'] = $route; |
| 416 | $data['lang'] = $lang; | 421 | $data['lang'] = $lang; |
| 417 | $data['project_id']= $this->user['project_id']; | 422 | $data['project_id']= $this->user['project_id']; |
| 418 | - $this->curlDelRoute($data); | 423 | + return $this->success($data); |
| 424 | + } | ||
| 425 | + | ||
| 426 | + /** | ||
| 427 | + * @remark :发送通知 | ||
| 428 | + * @name :send | ||
| 429 | + * @author :lyh | ||
| 430 | + * @method :post | ||
| 431 | + * @time :2024/5/21 11:13 | ||
| 432 | + */ | ||
| 433 | + public function sendMessage($data){ | ||
| 434 | + return $this->curlDelRoute($data); | ||
| 419 | } | 435 | } |
| 420 | } | 436 | } |
| @@ -38,7 +38,7 @@ class SyncImageFileJob implements ShouldQueue | @@ -38,7 +38,7 @@ class SyncImageFileJob implements ShouldQueue | ||
| 38 | */ | 38 | */ |
| 39 | public function handle() | 39 | public function handle() |
| 40 | { | 40 | { |
| 41 | - $file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0); | 41 | + $file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']); |
| 42 | $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php'; | 42 | $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php'; |
| 43 | $code = shell_exec($cmd); | 43 | $code = shell_exec($cmd); |
| 44 | if(200 != (int)$code){ | 44 | if(200 != (int)$code){ |
-
请 注册 或 登录 后发表评论