作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -35,20 +35,22 @@ class Translate extends Command
protected $description = 'translate';
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0],'id'=>['<=',1194]]);
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0],'id'=>['<=',451]]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$translateModel = new \App\Models\WebSetting\Translate();
$translateList = $translateModel->list([],'id',['id','url']);
foreach ($translateList as $value){
echo date('Y-m-d H:i:s') . '数据路由:'.$value['url'] . PHP_EOL;
$data = $this->getRouteSource($value['url']);
if($data === false){
continue;
if(!empty($translateList)){
foreach ($translateList as $value){
echo date('Y-m-d H:i:s') . '数据路由:'.$value['url'] . PHP_EOL;
$data = $this->getRouteSource($value['url']);
if($data === false){
continue;
}
$rs = $translateModel->edit($data,['id'=>$value['id']]);
gc_collect_cycles();
}
$rs = $translateModel->edit($data,['id'=>$value['id']]);
gc_collect_cycles();
}
DB::disconnect('custom_mysql');
}
... ... @@ -71,7 +73,7 @@ class Translate extends Command
$data['source'] = 1;
return $data;
}
$route = basename($route);
$route = $this->handleRoute($route);
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
if($routeInfo === false){
... ... @@ -81,6 +83,46 @@ class Translate extends Command
}
/**
* @remark :处理路由
* @name :handleRoute
* @author :lyh
* @method :post
* @time :2024/1/18 17:25
*/
public function handleRoute($url){
$str = trim($url,'/');
$route = 'index';
if(!empty($str)){
$arr = explode('/',$str);
$num = count($arr);
if($num == 1){
$route = $arr[0];
}elseif ($num == 2){
if(ctype_digit($arr[1])){//是数字的情况
$route = $arr[0];
}else{
$route = $arr[1];
}
}elseif($num == 3){
if(ctype_digit($arr[2])){//是数字的情况
$route = $arr[0];
}else{
if($arr[2] == 'page'){
$route = $arr[1];
}else{
$route = $arr[0];
}
}
}elseif ($num == 4){
if(ctype_digit($arr[3])){//是数字的情况
$route = $arr[1];
}
}
}
return $route;
}
/**
* @remark :返回数据
* @name :resultData
* @author :lyh
... ...
... ... @@ -54,6 +54,9 @@ class VisitController extends BaseController
* @time :2024/5/6 16:42
*/
public function downloadIndex(VisitLogic $logic){
if(isset($this->map['updated_date']) && is_array($this->map['updated_date'])){
$this->map['updated_date'] = ['between',$this->map['updated_date']];
}
$data = $logic->downloadItem($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -134,7 +134,7 @@ class FileController
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
$this->synchronizationFile($fileName);
$this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -145,9 +145,9 @@ class FileController
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($fileName){
public function synchronizationFile($fileName,$location){
//同步到大文件
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
return true;
}
... ... @@ -303,7 +303,7 @@ class FileController
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
$data[] = $this->responseData($this->path.'/'.$fileName, $name);
$this->synchronizationFile($fileName);
$this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
}
$this->response('资源',Code::SUCCESS,$data);
}
... ...
... ... @@ -41,7 +41,7 @@ class ImageController extends Controller
public $upload_location = 0;//同步到cos
public $upload_location = 0;//1:上传到cos
//上传图片类型
public $image_type = [
1 => 'image_product',
... ... @@ -215,7 +215,7 @@ class ImageController extends Controller
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
$this->synchronizationImage($fileName);
$this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -264,8 +264,8 @@ class ImageController extends Controller
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationImage($fileName){
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
public function synchronizationImage($fileName,$location){
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
return true;
}
... ... @@ -347,7 +347,7 @@ class ImageController extends Controller
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName);
$this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}
$this->response('图片资源',Code::SUCCESS,$data);
... ... @@ -472,8 +472,9 @@ class ImageController extends Controller
//根据项目上传标识区分上传到cos/本地
$projectModel = new Project();
$project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']);
if ($project_info['project_location'] != 0) {//危险项目时 上传到本地
$this->upload_location = 1;//上传到本地
if ($project_info['project_location'] != 0) {
//TODO::危险项目时
$this->upload_location = 1;//上传到cos
}
}
$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
}
$arr2 = [];
foreach ($text_array as $val) {
if($val == ' '){
if($val == ' ' || $val == ''){
continue;
}
if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){
... ... @@ -256,10 +256,12 @@ class TranslateLogic extends BaseLogic
}
$this->param['data'] = $data;
}
// try {
//解析路由
$sendData = $this->handleRoute($this->param['url']);
try {
$info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($info === false){
$sourceInfo = $this->getRouteSource($this->param['url']);
$sourceInfo = $this->getRouteSource($sendData['new_route']);
$param = [
'type'=>$this->param['type'],
'project_id'=>$this->user['project_id'],
... ... @@ -282,10 +284,10 @@ class TranslateLogic extends BaseLogic
//写日志
$userLogModel = new UserLog();
$userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]);
// }catch (\Exception $e){
// $this->fail('系统错误请联系管理员');
// }
$this->handleRoute($this->param['url']);
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
$this->sendMessage($sendData);
return $this->success();
}
... ... @@ -308,6 +310,9 @@ class TranslateLogic extends BaseLogic
$route = basename($route);
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
if($routeInfo === false){
return $data;
}
return $this->resultData($routeInfo,$data);
}
... ... @@ -415,6 +420,17 @@ class TranslateLogic extends BaseLogic
$data['new_route'] = $route;
$data['lang'] = $lang;
$data['project_id']= $this->user['project_id'];
$this->curlDelRoute($data);
return $this->success($data);
}
/**
* @remark :发送通知
* @name :send
* @author :lyh
* @method :post
* @time :2024/5/21 11:13
*/
public function sendMessage($data){
return $this->curlDelRoute($data);
}
}
... ...
... ... @@ -38,7 +38,7 @@ class SyncImageFileJob implements ShouldQueue
*/
public function handle()
{
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0);
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
$code = shell_exec($cmd);
if(200 != (int)$code){
... ...