|
...
|
...
|
@@ -9,10 +9,14 @@ |
|
|
|
|
|
|
|
namespace App\Console\Commands\Test;
|
|
|
|
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Template\BTemplateCom;
|
|
|
|
use App\Models\Template\BTemplateCommon;
|
|
|
|
use App\Models\Template\Setting;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class Translate extends Command
|
|
|
|
{
|
|
...
|
...
|
@@ -21,92 +25,107 @@ class Translate extends Command |
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'common_header';
|
|
|
|
protected $signature = 'translate';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'common_header';
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
protected $description = 'translate';
|
|
|
|
public function handle(){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
|
|
|
|
$data = [];
|
|
|
|
foreach ($list as $v){
|
|
|
|
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
|
|
|
|
ProjectServer::useProject($v['id']);
|
|
|
|
DB::table('gl_web_template_com')->truncate();
|
|
|
|
$templateComModel = new BTemplateCom();
|
|
|
|
$templateComModel->truncate();
|
|
|
|
$this->saveTemplateCom($v['id']);
|
|
|
|
$translateModel = new \App\Models\WebSetting\Translate();
|
|
|
|
$translateList = $translateModel->list();
|
|
|
|
foreach ($translateList as $value){
|
|
|
|
$data = $this->getRouteSource($value['url']);
|
|
|
|
$rs = $this->model->edit($data,['id'=>$value['id']]);
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据路由获取source+source_id
|
|
|
|
* @name :getRouteSource
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/17 15:11
|
|
|
|
*/
|
|
|
|
public function getRouteSource($route){
|
|
|
|
$data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0];
|
|
|
|
if(strtolower($route) == 'all'){
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
if($route == '/'){
|
|
|
|
$data['source'] = 1;
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
$route = basename($route);
|
|
|
|
$routeModel = new RouteMap();
|
|
|
|
$routeInfo = $routeModel->read(['route'=>$route]);
|
|
|
|
return $this->resultData($routeInfo,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function saveTemplateCom($project_id){
|
|
|
|
//获取当前项目选择的模版
|
|
|
|
$settingModel = new Setting();
|
|
|
|
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
|
|
|
|
echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
|
|
|
|
if($settingInfo !== false){
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
|
|
|
|
if(!empty($commonList)){
|
|
|
|
foreach ($commonList as $v){
|
|
|
|
$typeArr = [1, 2, 3];
|
|
|
|
foreach ($typeArr as $type){
|
|
|
|
if($type == 1){
|
|
|
|
$headData = [
|
|
|
|
'project_id'=>$v['project_id'],
|
|
|
|
'source'=>$v['type'] == 1 ? 99 : $v['type'],
|
|
|
|
'common_type'=>1,
|
|
|
|
'template_id'=>$v['template_id'],
|
|
|
|
'html'=>$v['head_html'],
|
|
|
|
'html_style'=>$v['head_css'],
|
|
|
|
'is_custom'=>$v['is_custom'],
|
|
|
|
'is_list'=>$v['is_list']
|
|
|
|
];
|
|
|
|
$templateComModel = new BTemplateCom();
|
|
|
|
$templateComModel->add($headData);
|
|
|
|
}elseif ($type == 2){
|
|
|
|
$footerData = [
|
|
|
|
'project_id'=>$v['project_id'],
|
|
|
|
'source'=>$v['type'] == 1 ? 99 : $v['type'],
|
|
|
|
'common_type'=>2,
|
|
|
|
'template_id'=>$v['template_id'],
|
|
|
|
'html'=>$v['footer_html'],
|
|
|
|
'html_style'=>$v['footer_css'],
|
|
|
|
'is_custom'=>$v['is_custom'],
|
|
|
|
'is_list'=>$v['is_list']
|
|
|
|
];
|
|
|
|
$templateComModel = new BTemplateCom();
|
|
|
|
$templateComModel->add($footerData);
|
|
|
|
}elseif ($type == 3){
|
|
|
|
$otherData = [
|
|
|
|
'project_id'=>$v['project_id'],
|
|
|
|
'source'=>$v['type'] == 1 ? 99 : $v['type'],
|
|
|
|
'common_type'=>3,
|
|
|
|
'template_id'=>$v['template_id'],
|
|
|
|
'html'=>$v['other'],
|
|
|
|
'html_style'=>null,
|
|
|
|
'is_custom'=>$v['is_custom'],
|
|
|
|
'is_list'=>$v['is_list']
|
|
|
|
];
|
|
|
|
$templateComModel = new BTemplateCom();
|
|
|
|
$templateComModel->add($otherData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
/**
|
|
|
|
* @remark :返回数据
|
|
|
|
* @name :resultData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/20 11:54
|
|
|
|
*/
|
|
|
|
public function resultData($routeInfo,$data){
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_CATE){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_BLOG){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_BLOG_CATE){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_NEWS){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_NEWS_CATE){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($routeInfo['source'] == RouteMap::SOURCE_MODULE_CATE){
|
|
|
|
if($routeInfo['source_id']){
|
|
|
|
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|